diff options
| author | Eli Ribble <eliribble@google.com> | 2018-12-18 21:21:12 -0800 |
|---|---|---|
| committer | Eli Ribble <eliribble@google.com> | 2018-12-19 11:06:35 -0800 |
| commit | d4b13c280b5cabd19899b0a6f53ef9041f9d01aa (patch) | |
| tree | 53e2af9c86f4d9043c81cadfab894ea0b87ca2ad | |
| parent | 6e53844f1edd3c9a3898f0af74fcc8da04b7de48 (diff) | |
| download | git-repo-d4b13c280b5cabd19899b0a6f53ef9041f9d01aa.tar.gz | |
Leverage the next keyword from python 2.7
This is literally what the next keyword is for.
https://www.python.org/dev/peps/pep-3114/
Change-Id: I843755910b847737b077ff2361ba3e04409db0f0
| -rw-r--r-- | .pydevproject | 2 | ||||
| -rw-r--r-- | event_log.py | 4 | ||||
| -rwxr-xr-x | repo | 13 |
3 files changed, 10 insertions, 9 deletions
diff --git a/.pydevproject b/.pydevproject index 27c2485a..837d5449 100644 --- a/.pydevproject +++ b/.pydevproject | |||
| @@ -5,6 +5,6 @@ | |||
| 5 | <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | 5 | <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> |
| 6 | <path>/git-repo</path> | 6 | <path>/git-repo</path> |
| 7 | </pydev_pathproperty> | 7 | </pydev_pathproperty> |
| 8 | <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property> | 8 | <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> |
| 9 | <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | 9 | <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> |
| 10 | </pydev_project> | 10 | </pydev_project> |
diff --git a/event_log.py b/event_log.py index 2f1b180b..508b18ee 100644 --- a/event_log.py +++ b/event_log.py | |||
| @@ -18,8 +18,6 @@ from __future__ import print_function | |||
| 18 | import json | 18 | import json |
| 19 | import multiprocessing | 19 | import multiprocessing |
| 20 | 20 | ||
| 21 | from pyversion import is_python3 | ||
| 22 | |||
| 23 | TASK_COMMAND = 'command' | 21 | TASK_COMMAND = 'command' |
| 24 | TASK_SYNC_NETWORK = 'sync-network' | 22 | TASK_SYNC_NETWORK = 'sync-network' |
| 25 | TASK_SYNC_LOCAL = 'sync-local' | 23 | TASK_SYNC_LOCAL = 'sync-local' |
| @@ -73,7 +71,7 @@ class EventLog(object): | |||
| 73 | A dictionary of the event added to the log. | 71 | A dictionary of the event added to the log. |
| 74 | """ | 72 | """ |
| 75 | event = { | 73 | event = { |
| 76 | 'id': (kind, self._next_id.__next__() if is_python3() else self._next_id.next()), | 74 | 'id': (kind, next(self._next_id)), |
| 77 | 'name': name, | 75 | 'name': name, |
| 78 | 'task_name': task_name, | 76 | 'task_name': task_name, |
| 79 | 'start_time': start, | 77 | 'start_time': start, |
| @@ -113,7 +113,7 @@ repodir = '.repo' # name of repo's private directory | |||
| 113 | S_repo = 'repo' # special repo repository | 113 | S_repo = 'repo' # special repo repository |
| 114 | S_manifests = 'manifests' # special manifest repository | 114 | S_manifests = 'manifests' # special manifest repository |
| 115 | REPO_MAIN = S_repo + '/main.py' # main script | 115 | REPO_MAIN = S_repo + '/main.py' # main script |
| 116 | MIN_PYTHON_VERSION = (2, 6) # minimum supported python version | 116 | MIN_PYTHON_VERSION = (2, 7) # minimum supported python version |
| 117 | GITC_CONFIG_FILE = '/gitc/.config' | 117 | GITC_CONFIG_FILE = '/gitc/.config' |
| 118 | GITC_FS_ROOT_DIR = '/gitc/manifest-rw/' | 118 | GITC_FS_ROOT_DIR = '/gitc/manifest-rw/' |
| 119 | 119 | ||
| @@ -152,9 +152,12 @@ def _print(*objects, **kwargs): | |||
| 152 | # Python version check | 152 | # Python version check |
| 153 | ver = sys.version_info | 153 | ver = sys.version_info |
| 154 | if (ver[0], ver[1]) < MIN_PYTHON_VERSION: | 154 | if (ver[0], ver[1]) < MIN_PYTHON_VERSION: |
| 155 | _print('error: Python version %s unsupported.\n' | 155 | _print('error: Python version {} unsupported.\n' |
| 156 | 'Please use Python 2.6 - 2.7 instead.' | 156 | 'Please use Python {}.{} instead.'.format( |
| 157 | % sys.version.split(' ')[0], file=sys.stderr) | 157 | sys.version.split(' ')[0], |
| 158 | MIN_PYTHON_VERSION[0], | ||
| 159 | MIN_PYTHON_VERSION[1], | ||
| 160 | ), file=sys.stderr) | ||
| 158 | sys.exit(1) | 161 | sys.exit(1) |
| 159 | 162 | ||
| 160 | home_dot_repo = os.path.expanduser('~/.repoconfig') | 163 | home_dot_repo = os.path.expanduser('~/.repoconfig') |
| @@ -909,6 +912,6 @@ def main(orig_args): | |||
| 909 | if __name__ == '__main__': | 912 | if __name__ == '__main__': |
| 910 | if ver[0] == 3: | 913 | if ver[0] == 3: |
| 911 | _print('warning: Python 3 support is currently experimental. YMMV.\n' | 914 | _print('warning: Python 3 support is currently experimental. YMMV.\n' |
| 912 | 'Please use Python 2.6 - 2.7 instead.', | 915 | 'Please use Python 2.7 instead.', |
| 913 | file=sys.stderr) | 916 | file=sys.stderr) |
| 914 | main(sys.argv[1:]) | 917 | main(sys.argv[1:]) |
