Safer determination of short hostname; Raise a GurlError instead of allowing an unhandled exception if a download rename fails

This commit is contained in:
Greg Neagle
2018-08-15 13:44:43 -07:00
parent f438b5def9
commit 2794253104
2 changed files with 15 additions and 8 deletions

View File

@@ -304,7 +304,11 @@ def get_url(url, destinationpath,
connection.headers['http_result_description'] = description
if str(connection.status).startswith('2') and temp_download_exists:
os.rename(tempdownloadpath, destinationpath)
try:
os.rename(tempdownloadpath, destinationpath)
except OSError, err:
# Re-raise the error as a GurlError
raise GurlError(-1, str(err))
return connection.headers
elif connection.status == 304:
# unchanged on server

View File

@@ -170,13 +170,16 @@ def get_primary_manifest(alternate_id=''):
if not manifest:
# try the short hostname
clientidentifier = hostname.split('.')[0]
display.display_detail(
'Request failed. Trying %s...', clientidentifier)
try:
manifest = get_manifest(
clientidentifier, suppress_errors=True)
except ManifestNotRetrievedException:
pass
if clientidentifier:
# need this test because of crazy people who give their
# machines hostnames that start with a period!
display.display_detail(
'Request failed. Trying %s...', clientidentifier)
try:
manifest = get_manifest(
clientidentifier, suppress_errors=True)
except ManifestNotRetrievedException:
pass
if not manifest:
# try the machine serial number