Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support http/ftp protocol.

  • Loading branch information...
commit 23a5fe3f234c7f85fc1c38400faf6ead0210f5f7 1 parent 6d2c18d
@elleryq authored
Showing with 23 additions and 6 deletions.
  1. +23 −6 gcintsinlib/__init__.py
View
29 gcintsinlib/__init__.py
@@ -26,10 +26,13 @@ def parse_file_and_get_list( f ):
"""
r = []
if f:
- for line in f:
- t = line.split()
- r.append( tuple(t) )
- f.close()
+ try:
+ for line in f:
+ t = line.split()
+ r.append( tuple(t) )
+ f.close()
+ except e:
+ print( e.reason )
return r
def get_list_from_current_tsin32():
@@ -45,9 +48,23 @@ def get_list_from_remote( remote_filename ):
"""
Parse the text file in Dropbox and get a list.
"""
+ from urlparse import urlparse
+ r = urlparse( remote_filename )
+ f = None
+ if r.scheme=="":
+ if os.path.exists( r.path ):
+ f = open( r.path )
+ else:
+ print( "%s is not found." % remote_filename )
+ elif r.scheme in ["http", "ftp", "https"]:
+ from urllib2 import Request, urlopen
+ req = Request( r.geturl() )
+ try:
+ f = urlopen(req)
+ except e:
+ print e.reason
tsin = []
- if os.path.exists( remote_filename ):
- f = open( remote_filename )
+ if f:
tsin = parse_file_and_get_list( f )
return tsin
Please sign in to comment.
Something went wrong with that request. Please try again.