Added logger debug message when file not found when deleting

This commit is contained in:
PCoder 2017-09-13 02:41:19 +05:30
parent 2983940d0f
commit 511a1551d5
2 changed files with 9 additions and 5 deletions

View file

@ -108,8 +108,10 @@ class UserHostingKeyForm(forms.ModelForm):
raise forms.ValidationError(KEY_ERROR_MESSAGE)
try:
os.remove(tmp_public_key_file.name)
except OSError:
pass
except FileNotFoundError:
logger.debug(
"{} could not be deleted because it doesn't exist".format(
tmp_public_key_file.name))
return openssh_pubkey_str
def clean_name(self):

View file

@ -1,5 +1,5 @@
import tempfile
import os
import tempfile
import cdist
from cdist.integration import configure_hosts_simple
@ -70,8 +70,10 @@ def save_ssh_key(self, hosts, keys):
return_value = False
try:
os.remove(tmp_manifest.name)
except OSError:
pass
except FileNotFoundError:
logger.debug(
"{} could not be deleted because it doesn't exist".format(
tmp_manifest.name))
return return_value