File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7171 print ('Failed to run the query to generate output file.' )
7272 exit (1 )
7373
74- # Remove the leading " and trailing " bytes from the file
75- len = os .stat (outputFile ).st_size
76- f = open (outputFile , "rb" )
77- try :
78- quote = f .read (6 )
79- if quote != b"\x02 \x01 \x86 '\x85 '" :
80- print ("Unexpected start characters in file." , quote )
81- contents = f .read (len - 21 )
82- quote = f .read (15 )
83- if quote != b'\x0e \x01 \x08 #select\x01 \x01 \x00 s\x00 ' :
84- print ("Unexpected end character in file." , quote )
85- finally :
86- f .close ()
74+ # Remove the leading and trailing bytes from the file
75+ length = os .stat (outputFile ).st_size
76+ if length < 20 :
77+ contents = b''
78+ else :
79+ f = open (outputFile , "rb" )
80+ try :
81+ countTillSlash = 0
82+ foundSlash = False
83+ slash = f .read (1 )
84+ while slash != b'' :
85+ if slash == b'/' :
86+ foundSlash = True
87+ break
88+ countTillSlash += 1
89+ slash = f .read (1 )
90+
91+ if not foundSlash :
92+ countTillSlash = 0
93+
94+ f .seek (0 )
95+ quote = f .read (countTillSlash )
96+ print ("Start characters in file skipped." , quote )
97+ post = b'\x0e \x01 \x08 #select\x01 \x01 \x00 s\x00 '
98+ contents = f .read (length - len (post ) - countTillSlash )
99+ quote = f .read (len (post ))
100+ if quote != post :
101+ print ("Unexpected end character in file." , quote )
102+ finally :
103+ f .close ()
87104
88105f = open (outputFile , "wb" )
89106f .write (contents )
You can’t perform that action at this time.
0 commit comments