mirror of
https://github.com/clearlinux/autospec.git
synced 2026-08-22 07:08:04 +00:00
Check http return code from license server
This change verifies that the HTTP returning code from license server is a 200 otherwise any code returned by the server will be accepted as a successful response and the returned error page will be interpreted as a valid license hash. Additonally this change narrows the exception emitted by pycurl perform method from Exception to pycurl.error. Signed-off-by: Alex Jaramillo <alex.v.jaramillo@intel.com>
This commit is contained in:
committed by
William Douglas
parent
6a04257351
commit
fdfded7916
+8
-4
@@ -97,13 +97,17 @@ def license_from_copying_hash(copying, srcdir):
|
||||
c.setopt(c.FOLLOWLOCATION, 1)
|
||||
try:
|
||||
c.perform()
|
||||
except Exception as excep:
|
||||
code = c.getinfo(pycurl.HTTP_CODE)
|
||||
if code != 200:
|
||||
print_fatal("Fetching license from {} returned {}"
|
||||
.format(config.license_fetch, code))
|
||||
exit(1)
|
||||
except pycurl.error as excep:
|
||||
print_fatal("Failed to fetch license from {}: {}"
|
||||
.format(config.license_fetch, excep))
|
||||
exit(1)
|
||||
finally:
|
||||
c.close()
|
||||
sys.exit(1)
|
||||
|
||||
c.close()
|
||||
|
||||
response = buffer.getvalue()
|
||||
page = response.decode('utf-8').strip()
|
||||
|
||||
Reference in New Issue
Block a user