Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def debug_func(self, *args, **kwargs):
if not self.on_error:
return runcall(self.func, *args, **kwargs)
try:
if has_ipdb:
with launch_ipdb_on_exception():
return self.func(*args, **kwargs)
else:
return self.func(*args, **kwargs)
except Exception as e:
traceback.print_exc(file=sys.stderr)
Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__).set_trace()
subprocess.call("git rev-parse HEAD", shell=True, stdout=out_file)
subprocess.call("git --no-pager diff", shell=True, stdout=out_file)
out_file.write('\n\n')
out_file.write(' '.join(sys.argv))
out_file.write('\n\n')
json.dump(vars(args), out_file)
out_file.write('\n\n')
log(sys.stdout)
# if 'save_dir' in vars(args) and args.save_dir:
# with open(os.path.join(args.save_dir, 'invoke.log'), 'w') as f:
# log(f)
if args.ipdb:
import ipdb
ipdb.runcall(entry_function, args)
elif args.pdb:
import pdb
pdb.runcall(entry_function, args)
else:
entry_function(args)