Click here to Skip to main content
15,891,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a python code. I use cmd file to execute my python code. In the cmd file, I am going to get errorlevel from my python code.

What I have tried:

infile = "FeatureByte.txt"
Array = ["6J", "yB", "ss", "11"]

with open(infile, "r") as input_file:
	output_list = []
	for rec in input_file.read().splitlines():
	   rec = rec[:-3]  
	   FBlist = [rec[i:i+2] for i in range(0, len(rec), 2)] 
	   output_list.append(FBlist)
	   print(output_list)

FBlist_set = set(FBlist)
Array_set = set (Array)

if Array_set & FBlist_set:
	print ("Found")
	exit(0)
else:
	print ("Not Found")
exit(1)



This is my cmd file :
set logfile=C:\Users\Log.txt
set PYTHONPATH="C:\Users\AppData\Local\Programs\Python\Python37-32"
set PYTHONEXE="%PYTHONPATH%\Python -B"


"C:\Users\AppData\Local\Programs\Python\Python37-32\python.exe" -B C:\Users\Desktop\Pyth.py

echo %ERRORLEVEL% >> "%logfile%"

From these both code, I always get 1 inside my Log.txt file.
Posted
Updated 27-Feb-19 0:26am
Comments
Richard MacCutchan 27-Feb-19 6:10am    
That probably means that your if expression goes to the else clause. What is the output of the program?

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900