summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/main.py b/main.py
index c5f1e9c3..a6538c2a 100755
--- a/main.py
+++ b/main.py
@@ -37,6 +37,7 @@ except ImportError:
37 kerberos = None 37 kerberos = None
38 38
39from color import SetDefaultColoring 39from color import SetDefaultColoring
40import event_log
40from trace import SetTrace 41from trace import SetTrace
41from git_command import git, GitCommand 42from git_command import git, GitCommand
42from git_config import init_ssh, close_ssh 43from git_config import init_ssh, close_ssh
@@ -54,7 +55,7 @@ from error import NoSuchProjectError
54from error import RepoChangedException 55from error import RepoChangedException
55import gitc_utils 56import gitc_utils
56from manifest_xml import GitcManifest, XmlManifest 57from manifest_xml import GitcManifest, XmlManifest
57from pager import RunPager 58from pager import RunPager, TerminatePager
58from wrapper import WrapperPath, Wrapper 59from wrapper import WrapperPath, Wrapper
59 60
60from subcmds import all_commands 61from subcmds import all_commands
@@ -85,6 +86,9 @@ global_options.add_option('--time',
85global_options.add_option('--version', 86global_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')
89global_options.add_option('--event-log',
90 dest='event_log', action='store',
91 help='filename of event log to append timeline to')
88 92
89class _Repo(object): 93class _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
530if __name__ == '__main__': 548if __name__ == '__main__':