Server may return 'Bad Machine'. Handle this in the new client
An issue appeared when an illegal machine id was passed, causing a raw text response from the server which fails to be converted into a dictionary later on. This is now handled by returning to the main loop, and resetting the machine id. This should never happen I had thought, but seems it can. One possible reason was failed FileIO, so now we only update the machine.txt when the ID has actually changed. Resolves #43
This commit is contained in:
1 parent
861914fd07
commit
4aac7910a0
1 file changed
+11
-3
+11
-3
@@ -458,13 +458,21 @@ def completeWorkload(workRequestData, arguments):
|
|||||||
print('[ERROR] Invalid Login Credentials')
|
print('[ERROR] Invalid Login Credentials')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
# Bad machines will be registered again
|
||||||
|
if data == 'Bad Machine':
|
||||||
|
workRequestData['machineid'] = 'None'
|
||||||
|
print('[NOTE] Invalid Machine ID')
|
||||||
|
return
|
||||||
|
|
||||||
# Convert response into a dictionary
|
# Convert response into a dictionary
|
||||||
data = ast.literal_eval(data)
|
data = ast.literal_eval(data)
|
||||||
|
|
||||||
# Update machine ID in case we got registered
|
# Update machine ID in case we got registered
|
||||||
workRequestData['machineid'] = data['machine']['id']
|
if workRequestData['machineid'] != data['machine']['id']:
|
||||||
with open('machine.txt', 'w') as fout:
|
workRequestData['machineid'] = data['machine']['id']
|
||||||
fout.write(str(workRequestData['machineid']))
|
with open('machine.txt', 'w') as fout:
|
||||||
|
fout.write(str(workRequestData['machineid']))
|
||||||
|
|
||||||
# Handle the actual workload's completion
|
# Handle the actual workload's completion
|
||||||
processWorkload(arguments, data)
|
processWorkload(arguments, data)
|
||||||
|
|||||||
Reference in new issue
Block a user