summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmain.py20
-rw-r--r--subcmds/sync.py4
-rw-r--r--wrapper.py30
3 files changed, 37 insertions, 17 deletions
diff --git a/main.py b/main.py
index e4cdeb0f..6ec7158d 100755
--- a/main.py
+++ b/main.py
@@ -46,6 +46,7 @@ from error import NoSuchProjectError
46from error import RepoChangedException 46from error import RepoChangedException
47from manifest_xml import XmlManifest 47from manifest_xml import XmlManifest
48from pager import RunPager 48from pager import RunPager
49from wrapper import WrapperPath, Wrapper
49 50
50from subcmds import all_commands 51from subcmds import all_commands
51 52
@@ -169,21 +170,10 @@ class _Repo(object):
169 170
170 return result 171 return result
171 172
173
172def _MyRepoPath(): 174def _MyRepoPath():
173 return os.path.dirname(__file__) 175 return os.path.dirname(__file__)
174 176
175def _MyWrapperPath():
176 return os.path.join(os.path.dirname(__file__), 'repo')
177
178_wrapper_module = None
179def WrapperModule():
180 global _wrapper_module
181 if not _wrapper_module:
182 _wrapper_module = imp.load_source('wrapper', _MyWrapperPath())
183 return _wrapper_module
184
185def _CurrentWrapperVersion():
186 return WrapperModule().VERSION
187 177
188def _CheckWrapperVersion(ver, repo_path): 178def _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
219def _CheckRepoDir(repo_dir): 209def _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
59from git_command import GIT, git_require 59from git_command import GIT, git_require
60from git_refs import R_HEADS, HEAD 60from git_refs import R_HEADS, HEAD
61from main import WrapperModule
62from project import Project 61from project import Project
63from project import RemoteSpec 62from project import RemoteSpec
64from command import Command, MirrorSafeCommand 63from command import Command, MirrorSafeCommand
65from error import RepoChangedException, GitError, ManifestParseError 64from error import RepoChangedException, GitError, ManifestParseError
66from project import SyncBuffer 65from project import SyncBuffer
67from progress import Progress 66from progress import Progress
67from 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
701def _PostRepoUpgrade(manifest, quiet=False): 701def _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
17from __future__ import print_function
18import imp
19import os
20
21
22def WrapperPath():
23 return os.path.join(os.path.dirname(__file__), 'repo')
24
25_wrapper_module = None
26def Wrapper():
27 global _wrapper_module
28 if not _wrapper_module:
29 _wrapper_module = imp.load_source('wrapper', WrapperPath())
30 return _wrapper_module