@@ -503,71 +503,71 @@ def handle_live_pirs(infile, fsize):
503
503
# End of code taken from extract360.py.
504
504
505
505
def getFileOrURL (filename , url ):
506
- # Check if a file named filename exists on disk.
507
- # If so, return its contents. If not, download it, save it, and return its contents.
508
- try :
509
- f = open (filename )
510
- print "Found" , filename , "cached on disk, using local copy"
511
- retval = f .read ()
512
- return retval
513
- except IOError , e :
514
- pass
515
- print "Downloading" , filename , "from" , url
516
- req = Request (url )
517
- try :
518
- response = urlopen (req )
519
- except URLError , e :
520
- if hasattr (e , 'reason' ):
521
- print "Failed to reach download server. Reason:" , e .reason
522
- elif hasattr (e , 'code' ):
523
- print "The server couldn't fulfill the request. Error code:" , e .code
524
- print "Reading response..."
525
- retval = response .read ()
526
- # Save downloaded file to disk
527
- f = open (filename , "wb" )
528
- f .write (retval )
529
- f .close ()
530
- print "done, saved to" , filename
531
- return retval
506
+ # Check if a file named filename exists on disk.
507
+ # If so, return its contents. If not, download it, save it, and return its contents.
508
+ try :
509
+ f = open (filename )
510
+ print "Found" , filename , "cached on disk, using local copy"
511
+ retval = f .read ()
512
+ return retval
513
+ except IOError , e :
514
+ pass
515
+ print "Downloading" , filename , "from" , url
516
+ req = Request (url )
517
+ try :
518
+ response = urlopen (req )
519
+ except URLError , e :
520
+ if hasattr (e , 'reason' ):
521
+ print "Failed to reach download server. Reason:" , e .reason
522
+ elif hasattr (e , 'code' ):
523
+ print "The server couldn't fulfill the request. Error code:" , e .code
524
+ print "Reading response..."
525
+ retval = response .read ()
526
+ # Save downloaded file to disk
527
+ f = open (filename , "wb" )
528
+ f .write (retval )
529
+ f .close ()
530
+ print "done, saved to" , filename
531
+ return retval
532
532
533
533
def extractPirsFromZip (systemupdate ):
534
- print "Extracting $SystemUpdate/FFFE07DF00000001 from system update file..."
535
- updatefile = StringIO .StringIO (systemupdate )
536
- z = zipfile .ZipFile (updatefile )
537
- #print z.namelist()
538
- pirs = z .open ("$SystemUpdate/FFFE07DF00000001" ).read ()
539
- print "done."
540
- return pirs
534
+ print "Extracting $SystemUpdate/FFFE07DF00000001 from system update file..."
535
+ updatefile = StringIO .StringIO (systemupdate )
536
+ z = zipfile .ZipFile (updatefile )
537
+ #print z.namelist()
538
+ pirs = z .open ("$SystemUpdate/FFFE07DF00000001" ).read ()
539
+ print "done."
540
+ return pirs
541
541
542
542
if __name__ == "__main__" :
543
- target = "audios.bin"
544
- if len (sys .argv ) == 2 :
545
- target = sys .argv [1 ]
546
- if not os .path .isfile (target ):
547
- fw = getFileOrURL ("SystemUpdate.zip" , "http://www.xbox.com/system-update-usb" )
548
- pirs = extractPirsFromZip (fw )
549
-
550
- lang = ["English" , "Japanese" , "German" , "French" , "Spanish" , "Italian" ,
551
- "Korean" , "Chinese" , "Portuguese" ]
552
- sio = StringIO .StringIO (pirs )
553
- basename = "FFFE07DF00000001"
554
- sio .name = basename
555
- pwd = os .getcwd ()
556
- handle_live_pirs (sio , len (pirs )- 4 )
557
-
558
- os .chdir (pwd )
559
- print "Moving audios.bin to current folder"
560
- os .rename (os .path .join (basename + ".dir" , "audios.bin" ), target )
561
-
562
- print "Cleaning up"
563
- os .unlink (basename + ".txt" )
564
- for root , dirs , files in os .walk (basename + ".dir" ):
565
- for name in files :
566
- os .remove (os .path .join (root , name ))
567
- for name in dirs :
568
- os .rmdir (os .path .join (root , name ))
569
- os .rmdir (root )
570
- os .unlink ("SystemUpdate.zip" )
571
- print "Done!"
572
- else :
573
- print "Already have audios.bin"
543
+ target = "audios.bin"
544
+ if len (sys .argv ) == 2 :
545
+ target = sys .argv [1 ]
546
+ if not os .path .isfile (target ):
547
+ fw = getFileOrURL ("SystemUpdate.zip" , "http://www.xbox.com/system-update-usb" )
548
+ pirs = extractPirsFromZip (fw )
549
+
550
+ lang = ["English" , "Japanese" , "German" , "French" , "Spanish" , "Italian" ,
551
+ "Korean" , "Chinese" , "Portuguese" ]
552
+ sio = StringIO .StringIO (pirs )
553
+ basename = "FFFE07DF00000001"
554
+ sio .name = basename
555
+ pwd = os .getcwd ()
556
+ handle_live_pirs (sio , len (pirs )- 4 )
557
+
558
+ os .chdir (pwd )
559
+ print "Moving audios.bin to current folder"
560
+ os .rename (os .path .join (basename + ".dir" , "audios.bin" ), target )
561
+
562
+ print "Cleaning up"
563
+ os .unlink (basename + ".txt" )
564
+ for root , dirs , files in os .walk (basename + ".dir" ):
565
+ for name in files :
566
+ os .remove (os .path .join (root , name ))
567
+ for name in dirs :
568
+ os .rmdir (os .path .join (root , name ))
569
+ os .rmdir (root )
570
+ os .unlink ("SystemUpdate.zip" )
571
+ print "Done!"
572
+ else :
573
+ print "Already have audios.bin"
0 commit comments