diff options
-rwxr-xr-x | main.py | 20 | ||||
-rw-r--r-- | subcmds/sync.py | 4 | ||||
-rw-r--r-- | wrapper.py | 30 |
3 files changed, 37 insertions, 17 deletions
@@ -46,6 +46,7 @@ from error import NoSuchProjectError | |||
46 | from error import RepoChangedException | 46 | from error import RepoChangedException |
47 | from manifest_xml import XmlManifest | 47 | from manifest_xml import XmlManifest |
48 | from pager import RunPager | 48 | from pager import RunPager |
49 | from wrapper import WrapperPath, Wrapper | ||
49 | 50 | ||
50 | from subcmds import all_commands | 51 | from subcmds import all_commands |
51 | 52 | ||
@@ -169,21 +170,10 @@ class _Repo(object): | |||
169 | 170 | ||
170 | return result | 171 | return result |
171 | 172 | ||
173 | |||
172 | def _MyRepoPath(): | 174 | def _MyRepoPath(): |
173 | return os.path.dirname(__file__) | 175 | return os.path.dirname(__file__) |
174 | 176 | ||
175 | def _MyWrapperPath(): | ||
176 | return os.path.join(os.path.dirname(__file__), 'repo') | ||
177 | |||
178 | _wrapper_module = None | ||
179 | def WrapperModule(): | ||
180 | global _wrapper_module | ||
181 | if not _wrapper_module: | ||
182 | _wrapper_module = imp.load_source('wrapper', _MyWrapperPath()) | ||
183 | return _wrapper_module | ||
184 | |||
185 | def _CurrentWrapperVersion(): | ||
186 | return WrapperModule().VERSION | ||
187 | 177 | ||
188 | def _CheckWrapperVersion(ver, repo_path): | 178 | def _CheckWrapperVersion(ver, repo_path): |
189 | if not repo_path: | 179 | if not repo_path: |
@@ -193,7 +183,7 @@ def _CheckWrapperVersion(ver, repo_path): | |||
193 | print('no --wrapper-version argument', file=sys.stderr) | 183 | print('no --wrapper-version argument', file=sys.stderr) |
194 | sys.exit(1) | 184 | sys.exit(1) |
195 | 185 | ||
196 | exp = _CurrentWrapperVersion() | 186 | exp = Wrapper().VERSION |
197 | ver = tuple(map(int, ver.split('.'))) | 187 | ver = tuple(map(int, ver.split('.'))) |
198 | if len(ver) == 1: | 188 | if len(ver) == 1: |
199 | ver = (0, ver[0]) | 189 | ver = (0, ver[0]) |
@@ -205,7 +195,7 @@ def _CheckWrapperVersion(ver, repo_path): | |||
205 | !!! You must upgrade before you can continue: !!! | 195 | !!! You must upgrade before you can continue: !!! |
206 | 196 | ||
207 | cp %s %s | 197 | cp %s %s |
208 | """ % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr) | 198 | """ % (exp_str, WrapperPath(), repo_path), file=sys.stderr) |
209 | sys.exit(1) | 199 | sys.exit(1) |
210 | 200 | ||
211 | if exp > ver: | 201 | if exp > ver: |
@@ -214,7 +204,7 @@ def _CheckWrapperVersion(ver, repo_path): | |||
214 | ... You should upgrade soon: | 204 | ... You should upgrade soon: |
215 | 205 | ||
216 | cp %s %s | 206 | cp %s %s |
217 | """ % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr) | 207 | """ % (exp_str, WrapperPath(), repo_path), file=sys.stderr) |
218 | 208 | ||
219 | def _CheckRepoDir(repo_dir): | 209 | def _CheckRepoDir(repo_dir): |
220 | if not repo_dir: | 210 | if not repo_dir: |
diff --git a/subcmds/sync.py b/subcmds/sync.py index e138be05..27c8c728 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -58,13 +58,13 @@ except ImportError: | |||
58 | 58 | ||
59 | from git_command import GIT, git_require | 59 | from git_command import GIT, git_require |
60 | from git_refs import R_HEADS, HEAD | 60 | from git_refs import R_HEADS, HEAD |
61 | from main import WrapperModule | ||
62 | from project import Project | 61 | from project import Project |
63 | from project import RemoteSpec | 62 | from project import RemoteSpec |
64 | from command import Command, MirrorSafeCommand | 63 | from command import Command, MirrorSafeCommand |
65 | from error import RepoChangedException, GitError, ManifestParseError | 64 | from error import RepoChangedException, GitError, ManifestParseError |
66 | from project import SyncBuffer | 65 | from project import SyncBuffer |
67 | from progress import Progress | 66 | from progress import Progress |
67 | from wrapper import Wrapper | ||
68 | 68 | ||
69 | _ONE_DAY_S = 24 * 60 * 60 | 69 | _ONE_DAY_S = 24 * 60 * 60 |
70 | 70 | ||
@@ -699,7 +699,7 @@ later is required to fix a server side protocol bug. | |||
699 | print(self.manifest.notice) | 699 | print(self.manifest.notice) |
700 | 700 | ||
701 | def _PostRepoUpgrade(manifest, quiet=False): | 701 | def _PostRepoUpgrade(manifest, quiet=False): |
702 | wrapper = WrapperModule() | 702 | wrapper = Wrapper() |
703 | if wrapper.NeedSetupGnuPG(): | 703 | if wrapper.NeedSetupGnuPG(): |
704 | wrapper.SetupGnuPG(quiet) | 704 | wrapper.SetupGnuPG(quiet) |
705 | for project in manifest.projects: | 705 | for project in manifest.projects: |
diff --git a/wrapper.py b/wrapper.py new file mode 100644 index 00000000..e7e276ec --- /dev/null +++ b/wrapper.py | |||
@@ -0,0 +1,30 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # | ||
3 | # Copyright (C) 2014 The Android Open Source Project | ||
4 | # | ||
5 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | # you may not use this file except in compliance with the License. | ||
7 | # You may obtain a copy of the License at | ||
8 | # | ||
9 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | # | ||
11 | # Unless required by applicable law or agreed to in writing, software | ||
12 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | # See the License for the specific language governing permissions and | ||
15 | # limitations under the License. | ||
16 | |||
17 | from __future__ import print_function | ||
18 | import imp | ||
19 | import os | ||
20 | |||
21 | |||
22 | def WrapperPath(): | ||
23 | return os.path.join(os.path.dirname(__file__), 'repo') | ||
24 | |||
25 | _wrapper_module = None | ||
26 | def Wrapper(): | ||
27 | global _wrapper_module | ||
28 | if not _wrapper_module: | ||
29 | _wrapper_module = imp.load_source('wrapper', WrapperPath()) | ||
30 | return _wrapper_module | ||