removed try except
This commit is contained in:
@@ -306,16 +306,13 @@ class ConfigRestoreHandler(bbctrl.APIHandler):
|
|||||||
|
|
||||||
files_path = os.path.join(temp_dir, zip_file['filename'])
|
files_path = os.path.join(temp_dir, zip_file['filename'])
|
||||||
|
|
||||||
try:
|
|
||||||
with open(files_path, 'wb') as f:
|
with open(files_path, 'wb') as f:
|
||||||
f.write(zip_file['body'])
|
f.write(zip_file['body'])
|
||||||
|
|
||||||
except Exception as e: self.log.exception(f"Internal error: {str(e)}")
|
|
||||||
|
|
||||||
if not os.path.exists(self.get_upload()):
|
if not os.path.exists(self.get_upload()):
|
||||||
os.mkdir(self.get_upload())
|
os.mkdir(self.get_upload())
|
||||||
|
|
||||||
try:
|
|
||||||
with zipfile.ZipFile(files_path, 'r') as zip_ref:
|
with zipfile.ZipFile(files_path, 'r') as zip_ref:
|
||||||
zip_ref.extractall(temp_dir+'/extracted')
|
zip_ref.extractall(temp_dir+'/extracted')
|
||||||
|
|
||||||
@@ -329,18 +326,16 @@ class ConfigRestoreHandler(bbctrl.APIHandler):
|
|||||||
if file =="config.json":
|
if file =="config.json":
|
||||||
with open(file_path, 'r') as json_file:
|
with open(file_path, 'r') as json_file:
|
||||||
json_data = json.load(json_file)
|
json_data = json.load(json_file)
|
||||||
|
json_data["macros_list"] = [{"file_name": item["file_name"]} for item in json_data["gcode_list"]]
|
||||||
keys_to_remove = ['non_macros_list','gcode_list']
|
keys_to_remove = ['non_macros_list','gcode_list']
|
||||||
for key in keys_to_remove:
|
for key in keys_to_remove:
|
||||||
if key in json_data:
|
if key in json_data:
|
||||||
del json_data[key]
|
del json_data[key]
|
||||||
|
|
||||||
self.get_ctrl().config.save(json_data)
|
self.get_ctrl().config.save(json_data)
|
||||||
|
|
||||||
#moving the gcodes from temp to uploads
|
#moving the gcodes from temp to uploads
|
||||||
elif file.endswith(extension):
|
# elif file.endswith(extension):
|
||||||
shutil.move(file_path,self.get_upload(file))
|
# shutil.move(file_path,self.get_upload(file))
|
||||||
except Exception as e:
|
|
||||||
self.log.exception(f"Internal error: {str(e)}")
|
|
||||||
|
|
||||||
shutil.rmtree(temp_dir)
|
shutil.rmtree(temp_dir)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user