mirror of
https://github.com/munki/munki.git
synced 2026-01-05 22:20:00 -06:00
Safer determination of short hostname; Raise a GurlError instead of allowing an unhandled exception if a download rename fails
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user