Commit 19d1eba8 authored by Kirill Smelkov's avatar Kirill Smelkov

tracing/pyruntraced: pymain moved -> pygolang

To -> pygolang@32a21d5b
parent 87228e62
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2018 Nexedi SA and Contributors. # Copyright (C) 2018-2019 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com> # Kirill Smelkov <kirr@nexedi.com>
# #
# This program is free software: you can Use, Study, Modify and Redistribute # This program is free software: you can Use, Study, Modify and Redistribute
...@@ -236,7 +236,8 @@ def trace_entry(func, eventname): ...@@ -236,7 +236,8 @@ def trace_entry(func, eventname):
# ---------------------------------------- # ----------------------------------------
import os, sys, code, runpy import os, sys
from gpython import pymain
def usage(out): def usage(out):
print >>out, "Usage: pyruntraced <fd> <trace>* -- ..." print >>out, "Usage: pyruntraced <fd> <trace>* -- ..."
...@@ -288,47 +289,8 @@ def main(): ...@@ -288,47 +289,8 @@ def main():
# tracing code. # tracing code.
execfile(t, globals()) execfile(t, globals())
# now mimic `python ...`
# now mimic `python ...` # XXX -> mimicpython(argv) ? pythonmain(argv) ? pymain(argv)
# interactive console
if not argv:
code.interact()
return
# -c command
if argv[0] == '-c':
sys.argv = argv[0:1] + argv[2:] # python leaves '-c' as argv[0]
# exec with the same globals `python -c ...` does
g = {'__name__': '__main__',
'__doc__': None,
'__package__': None}
exec argv[1] in g
# -m module
elif argv[0] == '-m':
# search sys.path for module and run corresponding .py file as script
sys.argv = argv[1:]
runpy.run_module(sys.argv[0], init_globals={'__doc__': None}, run_name='__main__')
elif argv[0].startswith('-'):
die("invalid option '%s'" % argv[0])
# file
else:
sys.argv = argv
filepath = argv[0]
# exec with same globals `python file.py` does
# XXX use runpy.run_path() instead?
g = {'__name__': '__main__',
'__file__': filepath,
'__doc__': None,
'__package__': None}
execfile(filepath, g)
return
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment