diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/init.py | 8 | ||||
| -rw-r--r-- | subcmds/status.py | 11 | ||||
| -rw-r--r-- | subcmds/sync.py | 17 | ||||
| -rw-r--r-- | subcmds/upload.py | 7 |
4 files changed, 20 insertions, 23 deletions
diff --git a/subcmds/init.py b/subcmds/init.py index 1f915268..a44fb7a9 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
| @@ -19,11 +19,11 @@ import platform | |||
| 19 | import re | 19 | import re |
| 20 | import shutil | 20 | import shutil |
| 21 | import sys | 21 | import sys |
| 22 | try: | 22 | |
| 23 | # For python3 | 23 | from pyversion import is_python3 |
| 24 | if is_python3(): | ||
| 24 | import urllib.parse | 25 | import urllib.parse |
| 25 | except ImportError: | 26 | else: |
| 26 | # For python2 | ||
| 27 | import imp | 27 | import imp |
| 28 | import urlparse | 28 | import urlparse |
| 29 | urllib = imp.new_module('urllib') | 29 | urllib = imp.new_module('urllib') |
diff --git a/subcmds/status.py b/subcmds/status.py index 9810337f..41c4429a 100644 --- a/subcmds/status.py +++ b/subcmds/status.py | |||
| @@ -21,12 +21,13 @@ except ImportError: | |||
| 21 | import dummy_threading as _threading | 21 | import dummy_threading as _threading |
| 22 | 22 | ||
| 23 | import glob | 23 | import glob |
| 24 | try: | 24 | |
| 25 | # For python2 | 25 | from pyversion import is_python3 |
| 26 | import StringIO as io | 26 | if is_python3(): |
| 27 | except ImportError: | ||
| 28 | # For python3 | ||
| 29 | import io | 27 | import io |
| 28 | else: | ||
| 29 | import StringIO as io | ||
| 30 | |||
| 30 | import itertools | 31 | import itertools |
| 31 | import os | 32 | import os |
| 32 | import sys | 33 | import sys |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 8fb94885..b34787d2 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -24,22 +24,17 @@ import socket | |||
| 24 | import subprocess | 24 | import subprocess |
| 25 | import sys | 25 | import sys |
| 26 | import time | 26 | import time |
| 27 | try: | 27 | |
| 28 | # For python3 | 28 | from pyversion import is_python3 |
| 29 | if is_python3(): | ||
| 29 | import urllib.parse | 30 | import urllib.parse |
| 30 | except ImportError: | 31 | import xmlrpc.client |
| 31 | # For python2 | 32 | else: |
| 32 | import imp | 33 | import imp |
| 33 | import urlparse | 34 | import urlparse |
| 35 | import xmlrpclib | ||
| 34 | urllib = imp.new_module('urllib') | 36 | urllib = imp.new_module('urllib') |
| 35 | urllib.parse = urlparse | 37 | urllib.parse = urlparse |
| 36 | try: | ||
| 37 | # For python3 | ||
| 38 | import xmlrpc.client | ||
| 39 | except ImportError: | ||
| 40 | # For python2 | ||
| 41 | import imp | ||
| 42 | import xmlrpclib | ||
| 43 | xmlrpc = imp.new_module('xmlrpc') | 38 | xmlrpc = imp.new_module('xmlrpc') |
| 44 | xmlrpc.client = xmlrpclib | 39 | xmlrpc.client = xmlrpclib |
| 45 | 40 | ||
diff --git a/subcmds/upload.py b/subcmds/upload.py index a34938e5..13b87784 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -23,10 +23,11 @@ from editor import Editor | |||
| 23 | from error import HookError, UploadError | 23 | from error import HookError, UploadError |
| 24 | from project import RepoHook | 24 | from project import RepoHook |
| 25 | 25 | ||
| 26 | try: | 26 | from pyversion import is_python3 |
| 27 | if not is_python3(): | ||
| 28 | # pylint:disable=W0622 | ||
| 27 | input = raw_input | 29 | input = raw_input |
| 28 | except NameError: | 30 | # pylint:enable=W0622 |
| 29 | pass | ||
| 30 | 31 | ||
| 31 | UNUSUAL_COMMIT_THRESHOLD = 5 | 32 | UNUSUAL_COMMIT_THRESHOLD = 5 |
| 32 | 33 | ||
