mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
prepare_report: Unify error/missing data handling between JS and Python versions
This commit is contained in:
@@ -28,16 +28,19 @@ for optimize in [False, True]:
|
||||
args += ['--optimize']
|
||||
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(out, err) = proc.communicate(json.dumps(input_json).encode('utf-8'))
|
||||
try:
|
||||
result = json.loads(out.decode('utf-8').strip())
|
||||
|
||||
result = json.loads(out.decode('utf-8').strip())
|
||||
if (
|
||||
'contracts' not in result or
|
||||
len(result['contracts']) == 0 or
|
||||
all(len(file_results) == 0 for file_name, file_results in result['contracts'].items())
|
||||
):
|
||||
REPORT_FILE.write(f + ": ERROR\n")
|
||||
else:
|
||||
for filename in sorted(result['contracts'].keys()):
|
||||
for contractName in sorted(result['contracts'][filename].keys()):
|
||||
contractData = result['contracts'][filename][contractName]
|
||||
if 'evm' in contractData and 'bytecode' in contractData['evm']:
|
||||
REPORT_FILE.write(filename + ':' + contractName + ' ' +
|
||||
contractData['evm']['bytecode']['object'] + '\n')
|
||||
else:
|
||||
REPORT_FILE.write(filename + ':' + contractName + ' NO BYTECODE\n')
|
||||
REPORT_FILE.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n')
|
||||
except KeyError:
|
||||
REPORT_FILE.write(f + ": ERROR\n")
|
||||
bytecode = result['contracts'][filename][contractName].get('evm', {}).get('bytecode', {}).get('object', 'NO BYTECODE')
|
||||
metadata = result['contracts'][filename][contractName]['metadata']
|
||||
|
||||
REPORT_FILE.write(filename + ':' + contractName + ' ' + bytecode + '\n')
|
||||
REPORT_FILE.write(filename + ':' + contractName + ' ' + metadata + '\n')
|
||||
|
||||
Reference in New Issue
Block a user