I am making a tool to check different devices for their correct device information. As you can see here the overall result is either appended or written down to the file as either 1 or 0. What it should ideally be doing is appending or writing down PASS OR FAIL in this case 1 is pass and 0 is fail. can anyone give me a few suggestions on how I can achieve this. or if you professionals could give me an example code block that would be much appreciated too.
What I have tried so far:
I set OVERALL_STATUS = 1 to OVERALL_STATUS = PASS OVERALL_STATUS = 0
DEVICE_TYPE_STATUS = 0 after else. but then it does not print the correct answer.
It prints "overall result PASS",
but it is actually supposed ot be "Fail"
PS: please go easy on me guys I and apologize in advance for not using the correct terms
OVERALL_STATUS = 1
STATUS_LIST = []
DEVICE_TYPE_STATUS = 1
DEVICE_TYPE_LIST = []
# Order number
print("Desired Order number:",d_ordernum)
print("Order number from scancode :",scan_code_cropped_artikel)
print("Ordernumber from wbm: ", ord_nmr)
if d_ordernum == ord_nmr == scan_code_cropped_artikel:
print("Order number PASS")
else:
print("Order number FAIL")
OVERALL_STATUS = 0
STATUS_LIST.append('Order Number FAIL')
print(100*"")
print("Desired device type:",d_dev_typ)
print("Device type from wbm: ", dev_typ)
if d_dev_typ == dev_typ:
print("Device type PASS")
else:
print("Device type FAIL")
OVERALL_STATUS = 0
DEVICE_TYPE_STATUS = 0
STATUS_LIST.append("Device type FAIL")
print(100*"")
if OVERALL_STATUS:
print('Overall Result PASS')
else:
print('Overall Result FAIL, ' + ', '.join(STATUS_LIST))
header = ["Timestamp:","Overall result:","Soll-orderno:","Desired-HW-Version:","Desired-SF-Version:","Desired-productcode:","Desired-device-type:","Scancode:","Wbm-orderno:","Wbm-HW-Version:","Wbm-SF-Version:","Wbm-mac-address:","combined-product-code:","wbm-device-type:","test-device-type:"]
toWrite = [
[now ,OVERALL_STATUS,d_ordernum,d_hw_version,d_sf_version,pc_praefix,d_dev_typ,scancode_string,ord_nmr,v,b,mac_addr,product_code,dev_typ,DEVICE_TYPE_STATUS]
]
file_exists = os.path.isfile(d_output_file)
if file_exists:
with open (d_output_file, 'a') as f:
writer = csv.writer(f)
writer.writerows(toWrite)
if not file_exists:
with open (d_output_file, 'a') as f:
writer = csv.writer(f)
writer.writerow(header)
writer.writerows(toWrite)
output in the CSV file:
Timestamp:,Overall result:,Soll-orderno:,Desired-HW-Version:,Desired-SF-Version:,Desired-productcode:,Desired-device-type:,Scancode:,Wbm-orderno:,Wbm-HW-Version:,Wbm-SF-Version:,Wbm-mac-address:,combined-product-code:,wbm-device-type:,test-device-type:
2021-05-03 14:55:46,0,58184,1.0,1.0.0,7A2F7,TREE M-5TX PN IP67,58184#99AF0M000F9EF41A80,58184,1.00,1.0.0,00:0F:9E:F4:1A:80,7A2F7-1.0.0-1.00,TREE M-5TX PN IP67,1
2021-05-03 15:04:21,0,58184,1.0,1.0.0,7A2F7,TREE M-5TX PN IP67,58184#99AF0M000F9EF41A80,58184,1.00,1.0.0,00:0F:9E:F4:1A:80,7A2F7-1.0.0-1.00,TREE M-5TX PN IP67,1
2021-05-03 15:06:05,0,58184,1.0,1.0.0,7A2F7,TREE M-5TX PN IP67,58184#99AF0M000F9EF41A80,58184,1.00,1.0.0,00:0F:9E:F4:1A:80,7A2F7-1.0.0-1.00,TREE M-5TX PN IP67,1