10
10
import os
11
11
import subprocess
12
12
import sys
13
+ import time
13
14
14
15
v1_platforms = {
15
16
'oculusvr3dofstore' ,
@@ -72,13 +73,30 @@ def main(name, argv):
72
73
print "Target " , target
73
74
cmd = ["curl" , "-F" , "input=@" + apk , "-o" , target , "-H" , "Authorization: " + cred , sign_url ]
74
75
75
- try :
76
- print subprocess .check_output (cmd )
77
- except subprocess .CalledProcessError as err :
78
- cmd = ' ' .join (err .cmd ).replace (cred , "XXX" )
79
- print "Signing apk failed:" , cmd
80
- print "Output:" , err .output
81
- sys .exit (err .returncode )
76
+ signTryCount = 0
77
+ done = False
78
+ while not done and signTryCount < 5 :
79
+ if signTryCount > 0 :
80
+ print "Waiting 5 seconds before trying to sign apk again..."
81
+ time .sleep (5 )
82
+ signTryCount = signTryCount + 1
83
+ try :
84
+ print subprocess .check_output (cmd )
85
+ except subprocess .CalledProcessError as err :
86
+ cleanCmd = ' ' .join (err .cmd ).replace (cred , "XXX" )
87
+ print "Signing apk failed:" , cleanCmd
88
+ print "Output:" , err .output
89
+ continue
90
+ fileinfo = subprocess .check_output (['file' , target ])
91
+ if fileinfo .find ("ASCII text" ) != - 1 :
92
+ print 'Error returned from autograph:'
93
+ print subprocess .check_output (['cat' , target ])
94
+ else :
95
+ done = True
96
+
97
+ if not done :
98
+ print "Failed to sign apk after multiple tries"
99
+ sys .exit (2 )
82
100
83
101
if align :
84
102
split = os .path .splitext (target )
@@ -91,10 +109,6 @@ def main(name, argv):
91
109
print subprocess .check_output (['apksigner' , 'verify' , '--verbose' , target ])
92
110
except subprocess .CalledProcessError as err :
93
111
print "Verifying apk failed"
94
- fileinfo = subprocess .check_output (['file' , target ])
95
- if fileinfo .find ("ASCII text" ) != - 1 :
96
- print 'Error returned from autograph:'
97
- print subprocess .check_output (['cat' , target ])
98
112
sys .exit (err .returncode )
99
113
print "Archiving" , target
100
114
os .rename (target , artifacts_path + "/" + os .path .basename (target ))
0 commit comments