@@ -47,44 +47,28 @@ def submit_image(result: TestResult, hardware: str, timestamp: str, file: str,
4747 Submits a new candidate image to the provided URL. This function logs a method
4848 indicating whether the image submission succeeded
4949 """
50- nRetries = 10
51- for attempt in range (1 , nRetries + 1 ):
52- try :
53- with open (file , "rb" ) as f :
54- res = requests .post (
55- url ,
56- timeout = 300 ,
57- data = {
58- "group" : result .group ,
59- "name" : result .name ,
60- "hardware" : hardware ,
61- "runnerID" : runner ,
62- "timestamp" : timestamp ,
63- "timing" : result .timing ,
64- "commitHash" : result .commit
65- },
66- files = {
67- "file" : f ,
68- "log" : result .error
69- }
70- )
71- if res .status_code == 200 :
72- print ("Image submitted successfully" )
73- return
74- elif res .status_code in (502 , 503 , 504 ):
75- print (f"Image submission attempt { attempt } /{ nRetries } failed with error { res .status_code } , retrying..." )
76- else :
77- print (f"Image submission failed with error { res .status_code } " )
78- print (res .text )
79- return
80- except requests .exceptions .Timeout :
81- print (f"Image submission attempt { attempt } /{ nRetries } timed out, retrying..." )
82- except requests .exceptions .RequestException as e :
83- print (f"Image submission attempt { attempt } /{ nRetries } failed with error: { e } " )
84- return
85- if attempt < nRetries :
86- time .sleep (5 )
87- print (f"Image submission failed after { nRetries } attempts" )
50+ with open (file , "rb" ) as f :
51+ res = requests .post (
52+ url ,
53+ data = {
54+ "group" : result .group ,
55+ "name" : result .name ,
56+ "hardware" : hardware ,
57+ "runnerID" : runner ,
58+ "timestamp" : timestamp ,
59+ "timing" : result .timing ,
60+ "commitHash" : result .commit
61+ },
62+ files = {
63+ "file" : f ,
64+ "log" : result .error
65+ }
66+ )
67+ if res .status_code == 200 :
68+ print ("Image submitted successfully" )
69+ else :
70+ print (f"Image submission failed with error { res .status_code } " )
71+ print (res .text )
8872
8973
9074
0 commit comments