I moved my python scripts from 2.7 to 3 using 2to3 module, and now I am trying them out...Can some explain what I need to change here?
found_qr = None
while not found_qr:
keep_alive(1,5)
time.sleep(4)
process = None
stdout_list = None
process = subprocess.Popen('grep -E -o ".Source QR CODE :.{0,65}" ' + latest_file + ' | tail -1', shell=True, stdout=subprocess.PIPE,)
stdout_list = process.communicate()
stdout_list = stdout_list[0]
if stdout_list.find("Source QR CODE") == -1:
found_qr = None
else:
found_qr = 'found!'
I am getting this error:
if stdout_list.find("Source QR CODE") == -1:
TypeError: argument should be integer or bytes-like object, not 'str'
any idea? thanks!
Update: Here is a similar issue I am seeing:
keep_alive(1,1)
process = subprocess.Popen('grep -E -o ".Source QR CODE :.{0,65}" ' + latest_file + ' | tail -1', shell=True, stdout=subprocess.PIPE,)
stdout_list = process.communicate()
qr_code = stdout_list[0].replace('Source QR CODE : ','')
qr_code = qr_code.replace(' ','')
qr_code = qr_code.replace('\n', '')
qr_code = str(qr_code)
TypeError: a bytes-like object is required, not 'str'