PageRenderTime 95ms CodeModel.GetById 50ms app.highlight 2ms RepoModel.GetById 23ms app.codeStats 0ms

/tools/data_source/fetch.py

https://bitbucket.org/h_morita_dbcls/galaxy-central
Python | 26 lines | 16 code | 6 blank | 4 comment | 3 complexity | 3bf2e98d702a10c3af25eed9265da55c MD5 | raw file
 1#!/usr/bin/env python
 2
 3"""
 4Script that just echos the command line.
 5"""
 6
 7import sys, os, urllib
 8
 9assert sys.version_info[:2] >= ( 2, 4 )
10
11BUFFER = 1048576
12
13url      = sys.argv[1]
14out_name = sys.argv[2]
15
16out = open(out_name, 'wt')
17try:
18    page = urllib.urlopen(url)
19    while 1:
20        data = page.read(BUFFER)
21        if not data:
22            break
23        out.write(data)
24except Exception, e:
25    print 'Error getting the data -> %s' % e
26out.close()