diff options
Diffstat (limited to 'main.py')
-rwxr-xr-x | main.py | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -37,6 +37,7 @@ except ImportError: | |||
37 | kerberos = None | 37 | kerberos = None |
38 | 38 | ||
39 | from color import SetDefaultColoring | 39 | from color import SetDefaultColoring |
40 | import event_log | ||
40 | from trace import SetTrace | 41 | from trace import SetTrace |
41 | from git_command import git, GitCommand | 42 | from git_command import git, GitCommand |
42 | from git_config import init_ssh, close_ssh | 43 | from git_config import init_ssh, close_ssh |
@@ -54,7 +55,7 @@ from error import NoSuchProjectError | |||
54 | from error import RepoChangedException | 55 | from error import RepoChangedException |
55 | import gitc_utils | 56 | import gitc_utils |
56 | from manifest_xml import GitcManifest, XmlManifest | 57 | from manifest_xml import GitcManifest, XmlManifest |
57 | from pager import RunPager | 58 | from pager import RunPager, TerminatePager |
58 | from wrapper import WrapperPath, Wrapper | 59 | from wrapper import WrapperPath, Wrapper |
59 | 60 | ||
60 | from subcmds import all_commands | 61 | from subcmds import all_commands |
@@ -85,6 +86,9 @@ global_options.add_option('--time', | |||
85 | global_options.add_option('--version', | 86 | global_options.add_option('--version', |
86 | dest='show_version', action='store_true', | 87 | dest='show_version', action='store_true', |
87 | help='display this version of repo') | 88 | help='display this version of repo') |
89 | global_options.add_option('--event-log', | ||
90 | dest='event_log', action='store', | ||
91 | help='filename of event log to append timeline to') | ||
88 | 92 | ||
89 | class _Repo(object): | 93 | class _Repo(object): |
90 | def __init__(self, repodir): | 94 | def __init__(self, repodir): |
@@ -176,6 +180,8 @@ class _Repo(object): | |||
176 | RunPager(config) | 180 | RunPager(config) |
177 | 181 | ||
178 | start = time.time() | 182 | start = time.time() |
183 | cmd_event = cmd.event_log.Add(name, event_log.TASK_COMMAND, start) | ||
184 | cmd.event_log.SetParent(cmd_event) | ||
179 | try: | 185 | try: |
180 | result = cmd.Execute(copts, cargs) | 186 | result = cmd.Execute(copts, cargs) |
181 | except (DownloadError, ManifestInvalidRevisionError, | 187 | except (DownloadError, ManifestInvalidRevisionError, |
@@ -198,8 +204,13 @@ class _Repo(object): | |||
198 | else: | 204 | else: |
199 | print('error: project group must be enabled for the project in the current directory', file=sys.stderr) | 205 | print('error: project group must be enabled for the project in the current directory', file=sys.stderr) |
200 | result = 1 | 206 | result = 1 |
207 | except SystemExit as e: | ||
208 | if e.code: | ||
209 | result = e.code | ||
210 | raise | ||
201 | finally: | 211 | finally: |
202 | elapsed = time.time() - start | 212 | finish = time.time() |
213 | elapsed = finish - start | ||
203 | hours, remainder = divmod(elapsed, 3600) | 214 | hours, remainder = divmod(elapsed, 3600) |
204 | minutes, seconds = divmod(remainder, 60) | 215 | minutes, seconds = divmod(remainder, 60) |
205 | if gopts.time: | 216 | if gopts.time: |
@@ -209,6 +220,12 @@ class _Repo(object): | |||
209 | print('real\t%dh%dm%.3fs' % (hours, minutes, seconds), | 220 | print('real\t%dh%dm%.3fs' % (hours, minutes, seconds), |
210 | file=sys.stderr) | 221 | file=sys.stderr) |
211 | 222 | ||
223 | cmd.event_log.FinishEvent(cmd_event, finish, | ||
224 | result is None or result == 0) | ||
225 | if gopts.event_log: | ||
226 | cmd.event_log.Write(os.path.abspath( | ||
227 | os.path.expanduser(gopts.event_log))) | ||
228 | |||
212 | return result | 229 | return result |
213 | 230 | ||
214 | 231 | ||
@@ -525,6 +542,7 @@ def _Main(argv): | |||
525 | print('fatal: %s' % e, file=sys.stderr) | 542 | print('fatal: %s' % e, file=sys.stderr) |
526 | result = 128 | 543 | result = 128 |
527 | 544 | ||
545 | TerminatePager() | ||
528 | sys.exit(result) | 546 | sys.exit(result) |
529 | 547 | ||
530 | if __name__ == '__main__': | 548 | if __name__ == '__main__': |