Made it far less likely for the UI to lock up

This commit is contained in:
David Carley
2021-03-23 21:19:45 -07:00
parent 47cec0dae3
commit a46230656e
13 changed files with 62 additions and 46 deletions

View File

@@ -128,7 +128,7 @@ class AVREmu(object):
except Exception:
self.close()
self.log.exception('Failed to start bbemu')
self.log.exception('Internal error: Failed to start bbemu')
def set_handlers(self, read_cb, write_cb):

View File

@@ -429,7 +429,7 @@ class Camera(object):
self._close_dev()
self.log.info('Closed camera')
except: self.log.exception('Exception while closing camera')
except: self.log.exception('Internal error: Exception while closing camera')
finally: self.dev = None

View File

@@ -72,7 +72,7 @@ class CommandQueue():
try:
if cb is not None: cb(*args, **kwargs)
except Exception:
self.log.exception('During command queue callback')
self.log.exception('Internal error: Command queue callback error')

View File

@@ -52,7 +52,7 @@ class Config(object):
encoding = 'utf-8') as f:
self.template = json.load(f)
except Exception: self.log.exception()
except Exception: self.log.exception('Internal error: Failed to load config template')
def get(self, name, default = None):
@@ -73,7 +73,7 @@ class Config(object):
try:
self.upgrade(config)
except Exception: self.log.exception()
except Exception: self.log.exception('Internal error: Failed to upgrade config')
except Exception as e:
self.log.warning('%s', e)

View File

@@ -67,7 +67,7 @@ class Ctrl(object):
os.environ['GCODE_SCRIPT_PATH'] = self.get_upload()
except Exception: self.log.get('Ctrl').exception()
except Exception: self.log.get('Ctrl').exception('Internal error: Control initialization failed')
def __del__(self): print('Ctrl deleted')

View File

@@ -79,7 +79,11 @@ class FileHandler(bbctrl.APIHandler):
if not filename: raise HTTPError(400, 'Missing filename')
filename = os.path.basename(filename)
with open(self.get_upload(filename).encode('utf8'), 'r') as f:
self.write(f.read())
try:
with open(self.get_upload(filename).encode('utf8'), 'r') as f:
self.write(f.read())
except Exception:
self.get_ctrl().state.select_file('')
raise HTTPError(400, "Unable to read file - doesn't appear to be GCode.")
self.get_ctrl().state.select_file(filename)

View File

@@ -101,8 +101,8 @@ class Logger(object):
def exception(self, *args, **kwargs):
msg = traceback.format_exc()
if len(args): msg = args[0] % args[1:] + '\n' + msg
self._log(ERROR, msg, **kwargs)
self._log(INFO, msg, **kwargs)
self._log(ERROR, *args, **kwargs)
class Log(object):
def __init__(self, args, ioloop, path):

View File

@@ -99,6 +99,6 @@ class MonitorTemp(object):
self.update_camera(temp)
self.log_warnings(temp)
except: self.log.exception()
except: self.log.exception('Internal error: Temperature status')
self.ioloop.call_later(5, self.callback)

View File

@@ -357,7 +357,7 @@ class Planner():
self.cmdq.clear()
except:
self.log.exception()
self.log.exception('Internal error: Planner stop')
self.reset()
@@ -374,7 +374,7 @@ class Planner():
self.planner.restart(id, position)
except:
self.log.exception()
self.log.exception('Internal error: Planner restart')
self.stop()
@@ -391,5 +391,5 @@ class Planner():
self.stop()
except:
self.log.exception()
self.log.exception('Internal error: Planner next')
self.stop()

View File

@@ -134,7 +134,7 @@ class Plan(object):
return meta, positions, speeds
except:
self.preplanner.log.exception()
self.preplanner.log.exception('Internal error: Preplanner read')
# Clean
for path in self.files:
@@ -203,8 +203,7 @@ class Plan(object):
self.future.set_result(self._read())
except:
self.preplanner.log.exception()
self.preplanner.log.exception("Failed to load file - doesn't appear to be GCode.")
class Preplanner(object):