def setSavingModel(self, value): api.devlog("setSavingModel: %s" % value) self._saving_model_flag = value if value: self._saving_model_lock.acquire() else: try: self._saving_model_lock.release() except RuntimeError: pass
def addUpdate(self, old_object, new_object, command_id): # Returns True if the update was resolved without user interaction try: mergeAction = old_object.addUpdate(new_object, command_id) if mergeAction: if old_object not in self.objects_with_updates: self.objects_with_updates.append(old_object) notifier.conflictUpdate(1) return False except Exception as ex: api.devlog("(%s).addUpdate(%s, %s) - failed" % (self, old_object, new_object)) return False self.mappers_manager.update(old_object, command_id) notifier.editHost(old_object) return True
def _processAction(self, action, parameters, sync=False): """ decodes and performs the action given It works kind of a dispatcher """ if sync: self._sync_api_request = True api.devlog("_processAction - %s - parameters = %s" % (action, str(parameters))) action_callback = self._actionDispatcher[action] res = self._dispatchActionWithLock(action_callback, *parameters) # finally we notify the widgets about this change # if res: # notify only if action was done successfuly # self._notifyModelUpdated(*parameters) # else: if not res: api.devlog("Action code %d failed. Parameters = %s" % (action, str(parameters))) if sync: self._sync_api_request = False
def _devlog(self, msg, *args, **kwargs): # I have no idea what I am doing api.devlog(msg) return True
def stop_server(self): api.devlog("server stopping...") self._must_stop = True
def serve_forever(self): while not self._must_stop: self.handle_request() api.devlog("server forever stopped by flag")
def run(self): self.serve_forever() api.devlog("serve_forever ended")
def handle(self): try: api.devlog("-" * 60) api.devlog("[XMLRPCHandler] - request = %s" % str(self.request)) api.devlog("[XMLRPCHandler] - client_address = %s" % str(self.client_address)) api.devlog("[XMLRPCHandler] - server = %s" % str(self.server)) api.devlog("-" * 60) SimpleXMLRPCRequestHandler.handle(self) except Exception: api.devlog( "[XMLRPCHandler] - An error ocurred while handling a request\n%s" % traceback.format_exc())