Improve error handling a little.
This commit is contained in:
parent
79f945800e
commit
cfe3ef63a0
|
@ -2,7 +2,7 @@
|
|||
|
||||
import pycurl
|
||||
from io import BytesIO
|
||||
from utils import notify,debug
|
||||
from utils import notify,debug,error
|
||||
|
||||
# args should be a dictionary of arguments
|
||||
# return page bytes, response code
|
||||
|
@ -21,7 +21,11 @@ def download (platform, url, args, verbosity, return_http_code=False):
|
|||
# c.setopt(pycurl.CIPHERS, args["ciphers"]
|
||||
|
||||
notify ("Downloading " + url + "...", verbosity, platform)
|
||||
try:
|
||||
c.perform()
|
||||
except pycurl.error as e:
|
||||
error (str(e), verbosity, platform)
|
||||
return None
|
||||
response_code = c.getinfo(c.RESPONSE_CODE)
|
||||
c.close()
|
||||
debug (url + " downloaded!", verbosity, platform)
|
||||
|
|
|
@ -73,6 +73,9 @@ for url in sys.argv[arg_count+1:]:
|
|||
elif network:
|
||||
from download_page import download
|
||||
page = download (None, url, args, verbosity)
|
||||
if page is None:
|
||||
error ("Failed to download " + url, verbosity)
|
||||
continue
|
||||
|
||||
# try to get feed for common software like PeerTube
|
||||
debug ("Attempting to determine software from page...", verbosity)
|
||||
|
|
Loading…
Reference in New Issue