/tools/data_source/fetch.py

https://bitbucket.org/h_morita_dbcls/galaxy-central · Python · 26 lines · 16 code · 6 blank · 4 comment · 4 complexity · 3bf2e98d702a10c3af25eed9265da55c MD5 · raw file

  1. #!/usr/bin/env python
  2. """
  3. Script that just echos the command line.
  4. """
  5. import sys, os, urllib
  6. assert sys.version_info[:2] >= ( 2, 4 )
  7. BUFFER = 1048576
  8. url = sys.argv[1]
  9. out_name = sys.argv[2]
  10. out = open(out_name, 'wt')
  11. try:
  12. page = urllib.urlopen(url)
  13. while 1:
  14. data = page.read(BUFFER)
  15. if not data:
  16. break
  17. out.write(data)
  18. except Exception, e:
  19. print 'Error getting the data -> %s' % e
  20. out.close()