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
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" ) ;
}