11# Copyright 2010 Twitter, Inc.
22# Copyright 2010 Larry Gadea <[email protected] > 3+ # Copyright 2010 Matt Freels <[email protected] > 34#
45# Licensed under the Apache License, Version 2.0 (the "License"); you may
56# not use this file except in compliance with the License. You may obtain
2728 psyco .full ()
2829 except :
2930 pass
30-
31+
3132from BitTornado .download_bt1 import BT1Download , defaults , parse_params , get_usage , get_response
3233from BitTornado .RawServer import RawServer , UPnP_ERROR
3334from random import seed
@@ -91,17 +92,17 @@ def __init__(self):
9192
9293 def finished (self ):
9394 global doneFlag
94-
95+
9596 self .done = True
9697 self .percentDone = '100'
9798 self .timeEst = 'Download Succeeded!'
9899 self .downRate = ''
99100 #self.display()
100-
101+
101102 global isPeer
102-
103+
103104 print "done and done"
104-
105+
105106 if isPeer :
106107 if os .fork ():
107108 os ._exit (0 )
@@ -118,7 +119,7 @@ def finished(self):
118119
119120 t = threading .Timer (30.0 , ok_close_now )
120121 t .start ()
121-
122+
122123 def failed (self ):
123124 self .done = True
124125 self .percentDone = '0'
@@ -135,12 +136,12 @@ def error(self, errormsg):
135136 print errormsg
136137 doneFlag .set ()
137138
138- def display (self , dpflag = Event (), fractionDone = None , timeEst = None ,
139+ def display (self , dpflag = Event (), fractionDone = None , timeEst = None ,
139140 downRate = None , upRate = None , activity = None ,
140141 statistics = None , ** kws ):
141142 if self .last_update_time + 0.1 > clock () and fractionDone not in (0.0 , 1.0 ) and activity is not None :
142143 return
143- self .last_update_time = clock ()
144+ self .last_update_time = clock ()
144145 if fractionDone is not None :
145146 self .percentDone = str (float (int (fractionDone * 1000 )) / 10 )
146147 if timeEst is not None :
@@ -174,7 +175,7 @@ def display(self, dpflag = Event(), fractionDone = None, timeEst = None,
174175 #print 'seed status: ', self.seedStatus
175176 #print 'peer status: ', self.peerStatus
176177 #stdout.flush()
177- dpflag .set ()
178+ dpflag .set ()
178179
179180 def chooseFile (self , default , size , saveas , dir ):
180181 self .file = '%s (%.1f MB)' % (default , float (size ) / (1 << 20 ))
@@ -212,7 +213,7 @@ def run(params):
212213
213214 myid = createPeerID ()
214215 seed (myid )
215-
216+
216217 global doneFlag
217218 doneFlag = Event ()
218219 def disp_exception (text ):
@@ -245,7 +246,7 @@ def disp_exception(text):
245246 dow = BT1Download (h .display , h .finished , h .error , disp_exception , doneFlag ,
246247 config , response , infohash , myid , rawserver , listen_port ,
247248 configdir )
248-
249+
249250 if not dow .saveAs (h .chooseFile , h .newpath ):
250251 break
251252
@@ -283,9 +284,9 @@ def disp_exception(text):
283284 sys .exit (1 )
284285
285286 argv = ["--responsefile" , sys .argv [2 ],
286- "--saveas" , sys .argv [3 ],
287+ "--saveas" , sys .argv [3 ],
287288 "--ip" , sys .argv [4 ]]
288-
289+
289290 isPeer = sys .argv [1 ] == "peer"
290-
291+
291292 run (argv [1 :])
0 commit comments