Skip to content

Commit

Permalink
catch HTTPError and URLError in the curl plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
oconnor663 committed Nov 30, 2017
1 parent aa6fc75 commit 967af6f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions peru/resources/plugins/curl/curl_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import stat
import sys
import tarfile
from urllib.error import HTTPError, URLError
from urllib.parse import urlsplit
import urllib.request
import zipfile
Expand Down Expand Up @@ -157,13 +158,18 @@ def main():
url = os.environ['PERU_MODULE_URL']
sha1 = os.environ['PERU_MODULE_SHA1']
command = os.environ['PERU_PLUGIN_COMMAND']
if command == 'sync':
plugin_sync(url, sha1)
elif command == 'reup':
plugin_reup(url, sha1)
else:
raise RuntimeError('unknown command: ' + repr(command))
try:
if command == 'sync':
plugin_sync(url, sha1)
elif command == 'reup':
plugin_reup(url, sha1)
else:
raise RuntimeError('unknown command: ' + repr(command))
except (HTTPError, URLError) as e:
print("Error fetching", url)
print(e)
return 1


if __name__ == '__main__':
main()
sys.exit(main())

0 comments on commit 967af6f

Please sign in to comment.