checksum enhancement for -d option (#1579)

* Added input file SHA1 info being printed on screen when running a trick sim with -d option (basically verifying the input)

* Added additional checks to exclude trace info printout for file in /opt or .trick/ or not a real file such as <xxx> as the filename.
This commit is contained in:
Hong Chen 2023-10-05 10:56:02 -05:00 committed by GitHub
parent d38dcf00d9
commit 73cc7aabfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -140,6 +140,11 @@ int Trick::IPPython::init() {
}
if ( verify_input ) {
std::stringstream ss ;
ss << "import hashlib" << std::endl ;
ss << "input_file = " << "'" << input_file.c_str() << "'" << std::endl;
ss << "print('{0} SHA1: {1}'.format(input_file,hashlib.sha1(open(input_file, 'rb').read()).hexdigest()))" << std::endl ;
PyRun_SimpleString(ss.str().c_str()) ;
exec_terminate_with_return(ret , __FILE__ , __LINE__ , "Input file verification complete\n" ) ;
}

View File

@ -177,7 +177,7 @@ def traceit(frame, event, arg):
if event == "line":
lineno = frame.f_lineno
filename = frame.f_code.co_filename
if ( not filename.startswith(exclude_dir) and not filename.startswith("/usr")):
if ( not filename.startswith(exclude_dir) and not filename.startswith("/usr") and not filename.startswith("/opt") and not filename.startswith("<") and not filename.startswith(".trick/") ):
if (filename.endswith(".pyc") or
filename.endswith(".pyo")):
filename = filename[:-1]