def _real_call(self, client, req_id, fcall_str): client.send_update(req_id, SC_CLIENT_CALL, SS_CLIENT_CALL, fcall_str) rsp = client.read_response() if rsp.code == SC_SERVER_RET: return rsp.content elif rsp.code == SC_SERVER_MORE: buf = rsp.content while True: client.send_update(req_id, SC_CLIENT_MORE, SS_CLIENT_MORE, '') rsp = client.read_response() if rsp.code == SC_SERVER_MORE: buf += rsp.content elif rsp.code == SC_SERVER_RET: buf += rsp.content break else: raise SearpcError("Error received: %s %s (In Read More)" % (rsp.code, rsp.code_msg)) return buf elif rsp.code == SC_PROC_DEAD: raise DeadProcError() else: raise SearpcError("Error received: %s %s" % (rsp.code, rsp.code_msg))
def check_file_lock(repo_id, file_path, username): """ Check if file is locked to current user According to returned value of seafile_api.check_file_lock: 0: not locked 1: locked by other 2: locked by me -1: error Return (is_locked, locked_by_me) """ if not is_pro_version() or not ENABLE_FOLDER_PERM: return (False, False) return_value = seafile_api.check_file_lock(repo_id, file_path.lstrip('/'), username) if return_value == 0: return (False, False) elif return_value == 1: return (True , False) elif return_value == 2: return (True, True) else: raise SearpcError('check file lock error')
def _start_service(self, client): req_id = client.get_request_id() req_str = self.service_name if self.is_remote: req_str = "remote " + self.remote_peer_id + " " + self.service_name client.send_request(req_id, req_str) rsp = client.read_response() if rsp.code != "200": raise SearpcError("Error received: %s %s (In _start_service)" % (rsp.code, rsp.code_msg)) return req_id