エディタを試してみますが、いかがですか?


   
   
   
   
  1. #!/usr/bin/python    
  2. #coding:utf-8   
  3.    
  4.    
  5. """    
  6. urllib     
  7. file:ratelimit-urllib.py   
  8. Fetch a url rate limited    
  9.    
  10. Syntax: rate URL local_file_name    
  11.    
  12. python ratelimit-urllib.py 200 http://localhost/share/netbeans-7.0-ml-linux.sh  1.sh   
  13.    
  14. """    
  15.    
  16. import os    
  17. import sys    
  18. import urllib    
  19. from time import time, sleep    
  20.    
  21. class RateLimit(object):    
  22.     """Rate limit a url fetch"""    
  23.     def __init__(self, rate_limit):    
  24.         """rate limit in kBytes / second"""    
  25.         self.rate_limit = rate_limit    
  26.         self.start = time()    
  27.     def __call__(self, block_count, block_size, total_size):    
  28.         total_kb = total_size / 1024    
  29.         downloaded_kb = (block_count * block_size) / 1024    
  30.         elapsed_time = time() - self.start    
  31.         if elapsed_time != 0:    
  32.             #    
  33.             rate = downloaded_kb / elapsed_time    
  34.             print "%d kb of %d kb downloaded %f.1 kBytes/s
    "
     % (downloaded_kb ,total_kb, rate),    
  35.             expected_time = downloaded_kb / self.rate_limit    
  36.             sleep_time = expected_time - elapsed_time    
  37.             print "Sleep for", sleep_time    
  38.             #    
  39.             if sleep_time > 0:    
  40.                 sleep(sleep_time)    
  41.    
  42. def main():    
  43.     """Fetch the contents of urls"""    
  44.     if len(sys.argv) != 4:    
  45.         print 'Syntax: %s "rate in kBytes/s" URL "local output path"' % sys.argv[0]    
  46.         raise SystemExit(1)    
  47.     rate_limit, url, out_path = sys.argv[1:]    
  48.     rate_limit = float(rate_limit)    
  49.     print "Fetching %r to %r with rate limit %.1f" % (url, out_path, rate_limit)    
  50.     # ,    
  51.     urllib.urlretrieve(url, out_path, reporthook=RateLimit(rate_limit))    
  52.    
  53. if __name__ == "__main__": main()    
 
   
   
   
   
  1. @Override   
  2. public boolean onKeyDown(int keyCode, KeyEvent event) {   
  3.     if (keyCode == KeyEvent.KEYCODE_BACK) {   
  4.         exit();   
  5.         return true;   
  6.     }   
  7.     return super.onKeyDown(keyCode, event);   
  8. }