Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import platform as pf
print(pf.python_version(), end=line_end)
if args.location:
print(settings.PACKAGE_BASE_PATH, end=line_end)
if args.logfile or args.open_log:
print(settings.GLOBAL_LOGFILE_PATH, end=line_end)
if not os.path.exists(settings.GLOBAL_LOGFILE_PATH):
print("no logfile found - run: "
"evo_config set global_logfile_enabled", end=line_end)
sys.exit(1)
if args.open_log:
import webbrowser
webbrowser.open(settings.GLOBAL_LOGFILE_PATH)
if args.clear_log:
from evo.tools import user
if user.confirm("clear logfile? (y/n)"):
open(settings.GLOBAL_LOGFILE_PATH, mode='w')
elif args.subcommand == "cat_log":
if os.name == "nt":
print("cat_log feature not available on Windows")
sys.exit(1)
if not args.message and sys.stdin.isatty():
if not os.path.exists(settings.GLOBAL_LOGFILE_PATH):
print("no logfile found - run: "
"evo_config set global_logfile_enabled", end=line_end)
else:
print(open(settings.GLOBAL_LOGFILE_PATH).read(), end="")
elif not settings.SETTINGS.global_logfile_enabled:
print("logfile disabled", end=line_end)
sys.exit(1)
else:
# In case logging couldn't be configured, print & exit directly.
import traceback
traceback.print_exc()
sys.exit(1)
logger.exception("Unhandled error in " + main_module.__name__)
print("")
err_msg = "evo module " + main_module.__name__ + " crashed"
from evo.tools import settings
if settings.SETTINGS.global_logfile_enabled:
err_msg += " - see " + settings.GLOBAL_LOGFILE_PATH
else:
err_msg += " - no logfile written (disabled)"
logger.error(err_msg)
from evo.tools import user
if not args.no_warnings:
if settings.SETTINGS.global_logfile_enabled and user.confirm(
"Open logfile? (y/n)"):
import webbrowser
webbrowser.open(settings.GLOBAL_LOGFILE_PATH)
sys.exit(1)
first_title = df.loc["info", "title"][0] if not args.ignore_title else ""
first_file = args.result_files[0]
if not args.no_warnings and not args.ignore_title:
checks = df.loc["info", "title"] != first_title
for i, differs in enumerate(checks):
if not differs:
continue
else:
mismatching_title = df.loc["info", "title"][i]
mismatching_file = args.result_files[i]
logger.debug(SEP)
logger.warning(
CONFLICT_TEMPLATE.format(first_file, first_title,
mismatching_title,
mismatching_file))
if not user.confirm(
"You can use --ignore_title to just aggregate data.\n"
"Go on anyway? - enter 'y' or any other key to exit"):
sys.exit()
logger.debug(SEP)
logger.debug("Aggregated dataframe:\n{}".format(
df.to_string(line_width=80)))
# show a statistics overview
logger.debug(SEP)
if not args.ignore_title:
logger.info("\n" + first_title + "\n\n")
logger.info(df.loc["stats"].T.to_string(line_width=80) + "\n")
if args.save_table:
logger.debug(SEP)
"(e.g. -vp)\n{0}".format(SEP, other_args))
data = generate(other_args)
log_info_dict_json(data, colored=not args.no_color)
if args.out and user.check_and_confirm_overwrite(args.out):
with open(args.out, 'w') as out:
out.write(json.dumps(data, indent=4, sort_keys=True))
elif not args.out:
logger.warning("\n(-o | --out) not specified - saving nothing")
else:
logger.error("No command line arguments given (see --help)")
elif args.subcommand == "reset":
if not os.access(config, os.W_OK):
logger.error("No permission to modify" + config)
sys.exit()
if args.y or user.confirm(
"Reset the package settings to the default settings? (y/n)"):
settings.reset()
logger.info("{0}\nPackage settings after reset:\n{0}".format(SEP))
show(settings.DEFAULT_PATH, colored=not args.no_color)
if args.save_plot:
logger.debug(SEP)
plot_collection.export(args.save_plot,
confirm_overwrite=not args.no_warnings)
if args.to_html:
import mpld3
logger.debug(SEP + "\nhtml export\n")
for name, fig in plot_collection.figures.items():
html = mpld3.fig_to_html(fig)
out = name + ".html"
with open(out, 'w') as f:
logger.debug(out)
f.write(html)
if not args.no_warnings:
logger.debug(SEP)
if user.confirm("Save changes & overwrite original file " +
args.in_file + "? (y/n)"):
plot_collection.serialize(args.in_file, confirm_overwrite=False)