def handle_expand_path(args): path = os.path.expanduser(args['path']) if not os.path.exists(path): send_error(Error.ENOENT, 'Path not found') elif not os.path.isdir(path): send_error(Error.ENOTDIR, 'Not a directory') else: send_response_header({'path': path})
def run_worker(): messageUnpacker = prepare_message_reader() for message in messageUnpacker: try: [opcode, args] = message handler = message_handlers.get(opcode, None) if handler != None: handler(args) else: send_error(Error.EINVAL, "Unknown opcode: " + str(opcode)) except CodedError as err: send_error(err.code, err.message) except OSError as err: logging.warning(err) send_error(process_error(err.errno), err.strerror) except BaseException as err: logging.warning(err) send_error(Error.EINVAL, str(err) + '\n' + traceback.format_exc()) finally: sys.stdout.flush()
def run_watcher(): try: get_libc() watcher = Watcher() watcher.run() except CodedError as err: send_error(err.code, err.message) except OSError as err: logging.warning(err) send_error(process_error(err.errno), err.strerror) except BaseException as err: logging.warning(err) if hasattr(err, '__traceback__'): logging.warning(''.join(traceback.format_tb(err.__traceback__))) send_error(Error.EINVAL, str(err) + '\n' + traceback.format_exc())