1818NVDA_LIB = os .path .join (NVDA_SOURCE , "lib" )
1919NVDA_LIB64 = os .path .join (NVDA_SOURCE , "lib64" )
2020ZIP_FILE = os .path .join (SCRIPT_DIR , "mozillaSyms.zip" )
21- URL = ' https://symbols.mozilla.org/upload/'
21+ URL = " https://symbols.mozilla.org/upload/"
2222
2323# The dlls for which symbols are to be uploaded to Mozilla.
2424# This only needs to include dlls injected into Mozilla products.
2727 "ISimpleDOM.dll" ,
2828 "nvdaHelperRemote.dll" ,
2929]
30- DLL_FILES = [f
30+ DLL_FILES = [
31+ f
3132 for dll in DLL_NAMES
3233 # We need both the 32 bit and 64 bit symbols.
33- for f in (os .path .join (NVDA_LIB , dll ), os .path .join (NVDA_LIB64 , dll ))]
34+ for f in (os .path .join (NVDA_LIB , dll ), os .path .join (NVDA_LIB64 , dll ))
35+ ]
36+
3437
3538class ProcError (Exception ):
3639 def __init__ (self , returncode , stderr ):
3740 self .returncode = returncode
3841 self .stderr = stderr
3942
43+
4044def check_output (command ):
41- proc = subprocess .Popen (command ,
42- stdout = subprocess .PIPE ,
43- stderr = subprocess .PIPE ,
44- text = True )
45+ proc = subprocess .Popen (command , stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True )
4546 stdout , stderr = proc .communicate ()
4647 if proc .returncode != 0 :
4748 raise ProcError (proc .returncode , stderr )
4849 return stdout
4950
51+
5052def processFile (path ):
51- print ("dump_syms %s" % path )
53+ print ("dump_syms %s" % path )
5254 try :
5355 stdout = check_output ([DUMP_SYMS , path ])
5456 except ProcError as e :
5557 print ('Error: running "%s %s": %s' % (DUMP_SYMS , path , e .stderr ))
5658 return None , None , None
57- bits = stdout .splitlines ()[0 ].split (' ' , 4 )
59+ bits = stdout .splitlines ()[0 ].split (" " , 4 )
5860 if len (bits ) != 5 :
5961 return None , None , None
6062 _ , platform , cpu_arch , debug_id , debug_file = bits
6163 # debug_file will have a .pdb extension; e.g. nvdaHelperRemote.dll.pdb.
6264 # The output file format should have a .sym extension instead.
6365 # Strip .pdb and add .sym.
64- sym_file = debug_file [:- 4 ] + ' .sym'
66+ sym_file = debug_file [:- 4 ] + " .sym"
6567 filename = os .path .join (debug_file , debug_id , sym_file )
6668 debug_filename = os .path .join (debug_file , debug_id , debug_file )
6769 return filename , stdout , debug_filename
6870
71+
6972def generate ():
7073 count = 0
71- with zipfile .ZipFile (ZIP_FILE , 'w' , zipfile .ZIP_DEFLATED ) as zf :
74+ with zipfile .ZipFile (ZIP_FILE , "w" , zipfile .ZIP_DEFLATED ) as zf :
7275 for f in DLL_FILES :
7376 filename , contents , debug_filename = processFile (f )
7477 if not (filename and contents ):
75- print (' Error dumping symbols' )
78+ print (" Error dumping symbols" )
7679 raise RuntimeError
7780 zf .writestr (filename , contents )
7881 count += 1
79- print (' Added %d files to %s' % (count , ZIP_FILE ))
82+ print (" Added %d files to %s" % (count , ZIP_FILE ))
8083
8184
8285def upload ():
@@ -85,37 +88,36 @@ def upload():
8588 if i > 0 :
8689 print ("Sleeping for 15 seconds before next attempt." )
8790 import time
91+
8892 time .sleep (15 )
8993 try :
9094 r = requests .post (
9195 URL ,
92- files = {' symbols.zip' : open (ZIP_FILE , 'rb' )},
93- headers = {' Auth-Token' : os .getenv (' mozillaSymsAuthToken' )},
94- allow_redirects = False
96+ files = {" symbols.zip" : open (ZIP_FILE , "rb" )},
97+ headers = {" Auth-Token" : os .getenv (" mozillaSymsAuthToken" )},
98+ allow_redirects = False ,
9599 )
96100 break # success
97101 except Exception as e :
98102 print (f"Attempt { i + 1 } failed: { e !r} " )
99103 errors .append (repr (e ))
100104 else : # no break in for loop
101- allErrors = "\n " .join (
102- f"Attempt { index + 1 } error: \n { e } "
103- for index , e in enumerate (errors )
104- )
105+ allErrors = "\n " .join (f"Attempt { index + 1 } error: \n { e } " for index , e in enumerate (errors ))
105106 raise RuntimeError (allErrors )
106107
107108 if 200 <= r .status_code < 300 :
108- print (' Uploaded successfully!' )
109+ print (" Uploaded successfully!" )
109110 elif r .status_code < 400 :
110- print (' Error: bad auth token? (%d)' % r .status_code )
111+ print (" Error: bad auth token? (%d)" % r .status_code )
111112 raise RuntimeError
112113 else :
113- print (' Error: %d' % r .status_code )
114+ print (" Error: %d" % r .status_code )
114115 print (r .text )
115116 raise RuntimeError
116117 return 0
117118
118- if __name__ == '__main__' :
119+
120+ if __name__ == "__main__" :
119121 try :
120122 generate ()
121123 upload ()
0 commit comments