mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-01 07:26:37 +00:00
Upadte to python3.
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
|
||||
from rpcclient import SeafileRpcClient as RpcClient
|
||||
from rpcclient import SeafileThreadedRpcClient as ThreadedRpcClient
|
||||
from rpcclient import MonitorRpcClient as MonitorRpcClient
|
||||
from rpcclient import SeafServerRpcClient as ServerRpcClient
|
||||
from rpcclient import SeafServerThreadedRpcClient as ServerThreadedRpcClient
|
||||
from .rpcclient import SeafServerThreadedRpcClient as ServerThreadedRpcClient
|
||||
|
||||
class TaskType(object):
|
||||
DOWNLOAD = 0
|
||||
|
@@ -1,327 +1,9 @@
|
||||
from pysearpc import searpc_func, SearpcError, NamedPipeClient
|
||||
|
||||
import ccnet
|
||||
from pysearpc import searpc_func, SearpcError
|
||||
class SeafServerThreadedRpcClient(NamedPipeClient):
|
||||
|
||||
class SeafileRpcClient(ccnet.RpcClientBase):
|
||||
"""RPC used in client"""
|
||||
|
||||
def __init__(self, ccnet_client_pool, *args, **kwargs):
|
||||
ccnet.RpcClientBase.__init__(self, ccnet_client_pool, "seafile-rpcserver",
|
||||
*args, **kwargs)
|
||||
|
||||
@searpc_func("object", [])
|
||||
def seafile_get_session_info():
|
||||
pass
|
||||
get_session_info = seafile_get_session_info
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def seafile_calc_dir_size(path):
|
||||
pass
|
||||
calc_dir_size = seafile_calc_dir_size
|
||||
|
||||
@searpc_func("int64", [])
|
||||
def seafile_get_total_block_size():
|
||||
pass
|
||||
get_total_block_size = seafile_get_total_block_size;
|
||||
|
||||
@searpc_func("string", ["string"])
|
||||
def seafile_get_config(key):
|
||||
pass
|
||||
get_config = seafile_get_config
|
||||
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_set_config(key, value):
|
||||
pass
|
||||
set_config = seafile_set_config
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def seafile_get_config_int(key):
|
||||
pass
|
||||
get_config_int = seafile_get_config_int
|
||||
|
||||
@searpc_func("int", ["string", "int"])
|
||||
def seafile_set_config_int(key, value):
|
||||
pass
|
||||
set_config_int = seafile_set_config_int
|
||||
|
||||
@searpc_func("int", ["int"])
|
||||
def seafile_set_upload_rate_limit(limit):
|
||||
pass
|
||||
set_upload_rate_limit = seafile_set_upload_rate_limit
|
||||
|
||||
@searpc_func("int", ["int"])
|
||||
def seafile_set_download_rate_limit(limit):
|
||||
pass
|
||||
set_download_rate_limit = seafile_set_download_rate_limit
|
||||
|
||||
### repo
|
||||
@searpc_func("objlist", ["int", "int"])
|
||||
def seafile_get_repo_list():
|
||||
pass
|
||||
get_repo_list = seafile_get_repo_list
|
||||
|
||||
@searpc_func("object", ["string"])
|
||||
def seafile_get_repo():
|
||||
pass
|
||||
get_repo = seafile_get_repo
|
||||
|
||||
@searpc_func("string", ["string", "string", "string", "string", "string", "int"])
|
||||
def seafile_create_repo(name, desc, passwd, base, relay_id, keep_history):
|
||||
pass
|
||||
create_repo = seafile_create_repo
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def seafile_destroy_repo(repo_id):
|
||||
pass
|
||||
remove_repo = seafile_destroy_repo
|
||||
|
||||
@searpc_func("objlist", ["string", "string", "string", "int"])
|
||||
def seafile_diff():
|
||||
pass
|
||||
get_diff = seafile_diff
|
||||
|
||||
@searpc_func("object", ["string", "int", "string"])
|
||||
def seafile_get_commit(repo_id, version, commit_id):
|
||||
pass
|
||||
get_commit = seafile_get_commit
|
||||
|
||||
@searpc_func("objlist", ["string", "int", "int"])
|
||||
def seafile_get_commit_list():
|
||||
pass
|
||||
get_commit_list = seafile_get_commit_list
|
||||
|
||||
@searpc_func("objlist", ["string"])
|
||||
def seafile_branch_gets(repo_id):
|
||||
pass
|
||||
branch_gets = seafile_branch_gets
|
||||
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_branch_add(repo_id, branch):
|
||||
pass
|
||||
branch_add = seafile_branch_add
|
||||
|
||||
##### clone related
|
||||
@searpc_func("string", ["string", "string"])
|
||||
def gen_default_worktree(worktree_parent, repo_name):
|
||||
pass
|
||||
|
||||
@searpc_func("string", ["string", "int", "string", "string", "string", "string", "string", "string", "string", "string", "string", "int", "string"])
|
||||
def seafile_clone(repo_id, repo_version, peer_id, repo_name, worktree, token, password, magic, peer_addr, peer_port, email, random_key, enc_version, more_info):
|
||||
pass
|
||||
clone = seafile_clone
|
||||
|
||||
@searpc_func("string", ["string", "int", "string", "string", "string", "string", "string", "string", "string", "string", "string", "int", "string"])
|
||||
def seafile_download(repo_id, repo_version, peer_id, repo_name, wt_parent, token, password, magic, peer_addr, peer_port, email, random_key, enc_version, more_info):
|
||||
pass
|
||||
download = seafile_download
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def seafile_cancel_clone_task(repo_id):
|
||||
pass
|
||||
cancel_clone_task = seafile_cancel_clone_task
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def seafile_remove_clone_task(repo_id):
|
||||
pass
|
||||
remove_clone_task = seafile_remove_clone_task
|
||||
|
||||
@searpc_func("objlist", [])
|
||||
def seafile_get_clone_tasks():
|
||||
pass
|
||||
get_clone_tasks = seafile_get_clone_tasks
|
||||
|
||||
@searpc_func("object", ["string"])
|
||||
def seafile_find_transfer_task(repo_id):
|
||||
pass
|
||||
find_transfer_task = seafile_find_transfer_task
|
||||
|
||||
@searpc_func("object", ["string"])
|
||||
def seafile_get_checkout_task(repo_id):
|
||||
pass
|
||||
get_checkout_task = seafile_get_checkout_task
|
||||
|
||||
### sync
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_sync(repo_id, peer_id):
|
||||
pass
|
||||
sync = seafile_sync
|
||||
|
||||
@searpc_func("object", ["string"])
|
||||
def seafile_get_repo_sync_task():
|
||||
pass
|
||||
get_repo_sync_task = seafile_get_repo_sync_task
|
||||
|
||||
@searpc_func("object", ["string"])
|
||||
def seafile_get_repo_sync_info():
|
||||
pass
|
||||
get_repo_sync_info = seafile_get_repo_sync_info
|
||||
|
||||
@searpc_func("int", [])
|
||||
def seafile_is_auto_sync_enabled():
|
||||
pass
|
||||
is_auto_sync_enabled = seafile_is_auto_sync_enabled
|
||||
|
||||
###### Property Management #########
|
||||
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_set_repo_passwd(repo_id, passwd):
|
||||
pass
|
||||
set_repo_passwd = seafile_set_repo_passwd
|
||||
|
||||
@searpc_func("int", ["string", "string", "string"])
|
||||
def seafile_set_repo_property(repo_id, key, value):
|
||||
pass
|
||||
set_repo_property = seafile_set_repo_property
|
||||
|
||||
@searpc_func("string", ["string", "string"])
|
||||
def seafile_get_repo_property(repo_id, key):
|
||||
pass
|
||||
get_repo_property = seafile_get_repo_property
|
||||
|
||||
@searpc_func("string", ["string"])
|
||||
def seafile_get_repo_relay_address(repo_id):
|
||||
pass
|
||||
get_repo_relay_address = seafile_get_repo_relay_address
|
||||
|
||||
@searpc_func("string", ["string"])
|
||||
def seafile_get_repo_relay_port(repo_id):
|
||||
pass
|
||||
get_repo_relay_port = seafile_get_repo_relay_port
|
||||
|
||||
@searpc_func("int", ["string", "string", "string"])
|
||||
def seafile_update_repo_relay_info(repo_id, addr, port):
|
||||
pass
|
||||
update_repo_relay_info = seafile_update_repo_relay_info
|
||||
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_set_repo_token(repo_id, token):
|
||||
pass
|
||||
set_repo_token = seafile_set_repo_token
|
||||
|
||||
@searpc_func("string", ["string"])
|
||||
def seafile_get_repo_token(repo_id):
|
||||
pass
|
||||
get_repo_token = seafile_get_repo_token
|
||||
|
||||
@searpc_func("object", ["int", "string", "string"])
|
||||
def seafile_generate_magic_and_random_key(enc_version, repo_id, password):
|
||||
pass
|
||||
generate_magic_and_random_key = seafile_generate_magic_and_random_key
|
||||
|
||||
class SeafileThreadedRpcClient(ccnet.RpcClientBase):
|
||||
"""RPC used in client that run in a thread"""
|
||||
|
||||
def __init__(self, ccnet_client_pool, *args, **kwargs):
|
||||
ccnet.RpcClientBase.__init__(self, ccnet_client_pool,
|
||||
"seafile-threaded-rpcserver",
|
||||
*args, **kwargs)
|
||||
|
||||
@searpc_func("int", ["string", "string", "string"])
|
||||
def seafile_edit_repo():
|
||||
pass
|
||||
edit_repo = seafile_edit_repo
|
||||
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_reset(repo_id, commit_id):
|
||||
pass
|
||||
reset = seafile_reset
|
||||
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_revert(repo_id, commit_id):
|
||||
pass
|
||||
revert = seafile_revert
|
||||
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_add(repo_id, path):
|
||||
pass
|
||||
add = seafile_add
|
||||
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_rm():
|
||||
pass
|
||||
rm = seafile_rm
|
||||
|
||||
@searpc_func("string", ["string", "string"])
|
||||
def seafile_commit(repo_id, description):
|
||||
pass
|
||||
commit = seafile_commit
|
||||
|
||||
|
||||
class MonitorRpcClient(ccnet.RpcClientBase):
|
||||
|
||||
def __init__(self, ccnet_client_pool):
|
||||
ccnet.RpcClientBase.__init__(self, ccnet_client_pool, "monitor-rpcserver")
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def monitor_get_repos_size(repo_ids):
|
||||
pass
|
||||
get_repos_size = monitor_get_repos_size
|
||||
|
||||
|
||||
class SeafServerRpcClient(ccnet.RpcClientBase):
|
||||
|
||||
def __init__(self, ccnet_client_pool, *args, **kwargs):
|
||||
ccnet.RpcClientBase.__init__(self, ccnet_client_pool, "seafserv-rpcserver",
|
||||
*args, **kwargs)
|
||||
|
||||
# token for web access to repo
|
||||
@searpc_func("string", ["string", "string", "string", "string", "int"])
|
||||
def seafile_web_get_access_token(repo_id, obj_id, op, username, use_onetime=1):
|
||||
pass
|
||||
web_get_access_token = seafile_web_get_access_token
|
||||
|
||||
@searpc_func("object", ["string"])
|
||||
def seafile_web_query_access_token(token):
|
||||
pass
|
||||
web_query_access_token = seafile_web_query_access_token
|
||||
|
||||
@searpc_func("string", ["string"])
|
||||
def seafile_query_zip_progress(token):
|
||||
pass
|
||||
query_zip_progress = seafile_query_zip_progress
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def cancel_zip_task(token):
|
||||
pass
|
||||
|
||||
###### GC ####################
|
||||
@searpc_func("int", [])
|
||||
def seafile_gc():
|
||||
pass
|
||||
gc = seafile_gc
|
||||
|
||||
@searpc_func("int", [])
|
||||
def seafile_gc_get_progress():
|
||||
pass
|
||||
gc_get_progress = seafile_gc_get_progress
|
||||
|
||||
# password management
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_is_passwd_set(repo_id, user):
|
||||
pass
|
||||
is_passwd_set = seafile_is_passwd_set
|
||||
|
||||
@searpc_func("object", ["string", "string"])
|
||||
def seafile_get_decrypt_key(repo_id, user):
|
||||
pass
|
||||
get_decrypt_key = seafile_get_decrypt_key
|
||||
|
||||
# Copy tasks
|
||||
|
||||
@searpc_func("object", ["string"])
|
||||
def get_copy_task(task_id):
|
||||
pass
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def cancel_copy_task(task_id):
|
||||
pass
|
||||
|
||||
class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
|
||||
|
||||
def __init__(self, ccnet_client_pool, *args, **kwargs):
|
||||
ccnet.RpcClientBase.__init__(self, ccnet_client_pool,
|
||||
"seafserv-threaded-rpcserver",
|
||||
*args, **kwargs)
|
||||
def __init__(self, pipe_path):
|
||||
NamedPipeClient.__init__(self, pipe_path, "seafserv-threaded-rpcserver")
|
||||
|
||||
# repo manipulation
|
||||
@searpc_func("string", ["string", "string", "string", "string", "int"])
|
||||
@@ -1055,3 +737,55 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
|
||||
@searpc_func("int", ["string"])
|
||||
def get_repo_status(repo_id):
|
||||
pass
|
||||
|
||||
# token for web access to repo
|
||||
@searpc_func("string", ["string", "string", "string", "string", "int"])
|
||||
def seafile_web_get_access_token(repo_id, obj_id, op, username, use_onetime=1):
|
||||
pass
|
||||
web_get_access_token = seafile_web_get_access_token
|
||||
|
||||
@searpc_func("object", ["string"])
|
||||
def seafile_web_query_access_token(token):
|
||||
pass
|
||||
web_query_access_token = seafile_web_query_access_token
|
||||
|
||||
@searpc_func("string", ["string"])
|
||||
def seafile_query_zip_progress(token):
|
||||
pass
|
||||
query_zip_progress = seafile_query_zip_progress
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def cancel_zip_task(token):
|
||||
pass
|
||||
|
||||
###### GC ####################
|
||||
@searpc_func("int", [])
|
||||
def seafile_gc():
|
||||
pass
|
||||
gc = seafile_gc
|
||||
|
||||
@searpc_func("int", [])
|
||||
def seafile_gc_get_progress():
|
||||
pass
|
||||
gc_get_progress = seafile_gc_get_progress
|
||||
|
||||
# password management
|
||||
@searpc_func("int", ["string", "string"])
|
||||
def seafile_is_passwd_set(repo_id, user):
|
||||
pass
|
||||
is_passwd_set = seafile_is_passwd_set
|
||||
|
||||
@searpc_func("object", ["string", "string"])
|
||||
def seafile_get_decrypt_key(repo_id, user):
|
||||
pass
|
||||
get_decrypt_key = seafile_get_decrypt_key
|
||||
|
||||
# Copy tasks
|
||||
|
||||
@searpc_func("object", ["string"])
|
||||
def get_copy_task(task_id):
|
||||
pass
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def cancel_copy_task(task_id):
|
||||
pass
|
||||
|
@@ -1,19 +1,18 @@
|
||||
|
||||
import service
|
||||
from service import ccnet_rpc, seafserv_rpc, seafserv_threaded_rpc, ccnet_threaded_rpc
|
||||
from service import send_command, check_quota, web_get_access_token, \
|
||||
from . import service
|
||||
from .service import seafserv_threaded_rpc, ccnet_threaded_rpc
|
||||
from .service import send_command, check_quota, web_get_access_token, \
|
||||
unset_repo_passwd, get_user_quota_usage, get_user_share_usage, \
|
||||
get_user_quota
|
||||
from service import get_emailusers, count_emailusers, get_session_info, \
|
||||
from .service import get_emailusers, count_emailusers, \
|
||||
get_emailuser_with_import
|
||||
from service import get_org_groups, get_personal_groups_by_user, \
|
||||
from .service import get_org_groups, get_personal_groups_by_user, \
|
||||
get_group_repoids, get_personal_groups, list_share_repos, remove_share, \
|
||||
check_group_staff, remove_group_user, get_group, get_org_id_by_group, \
|
||||
get_group_members, get_shared_groups_by_repo, is_group_user, \
|
||||
get_org_group_repos, get_group_repos, get_org_groups_by_user, is_org_group,\
|
||||
del_org_group_repo, get_org_groups_by_repo, get_org_group_repoids, \
|
||||
get_group_repos_by_owner, unshare_group_repo
|
||||
from service import get_repos, get_repo, get_commits, get_branches, remove_repo, \
|
||||
from .service import get_repos, get_repo, get_commits, get_branches, remove_repo, \
|
||||
get_org_repos, is_repo_owner, create_org_repo, is_inner_pub_repo, \
|
||||
list_org_inner_pub_repos, get_org_id_by_repo_id, list_org_shared_repos, \
|
||||
list_personal_shared_repos, is_personal_repo, list_inner_pub_repos, \
|
||||
@@ -23,21 +22,21 @@ from service import get_repos, get_repo, get_commits, get_branches, remove_repo,
|
||||
get_repo_history_limit, list_inner_pub_repos_by_owner, unset_inner_pub_repo,\
|
||||
count_inner_pub_repos, edit_repo, list_dir_by_path, create_repo, remove_repo
|
||||
|
||||
from service import get_binding_peerids, is_valid_filename, check_permission,\
|
||||
from .service import get_binding_peerids, is_valid_filename, check_permission,\
|
||||
is_passwd_set
|
||||
from service import create_org, get_orgs_by_user, get_org_by_url_prefix, \
|
||||
from .service import create_org, get_orgs_by_user, get_org_by_url_prefix, \
|
||||
get_user_current_org, add_org_user, remove_org_user, get_org_by_id, \
|
||||
get_org_id_by_repo_id, is_org_staff, get_org_users_by_url_prefix, \
|
||||
org_user_exists, list_org_repos_by_owner
|
||||
|
||||
from service import get_related_users_by_repo, get_related_users_by_org_repo
|
||||
from service import post_empty_file, del_file
|
||||
from .service import get_related_users_by_repo, get_related_users_by_org_repo
|
||||
from .service import post_empty_file, del_file
|
||||
|
||||
from service import CCNET_CONF_PATH, CCNET_SERVER_ADDR, CCNET_SERVER_PORT, \
|
||||
from .service import CCNET_CONF_PATH, CCNET_SERVER_ADDR, CCNET_SERVER_PORT, \
|
||||
MAX_UPLOAD_FILE_SIZE, MAX_DOWNLOAD_DIR_SIZE, FILE_SERVER_ROOT, \
|
||||
CALC_SHARE_USAGE, SERVICE_URL, FILE_SERVER_PORT, SERVER_ID, \
|
||||
SEAFILE_CENTRAL_CONF_DIR, LDAP_HOST
|
||||
|
||||
from service import send_message
|
||||
from .service import send_message
|
||||
|
||||
from api import seafile_api, ccnet_api
|
||||
from .api import seafile_api, ccnet_api
|
||||
|
@@ -1,5 +1,4 @@
|
||||
|
||||
from service import seafserv_rpc, seafserv_threaded_rpc, ccnet_threaded_rpc
|
||||
from .service import seafserv_threaded_rpc, ccnet_threaded_rpc
|
||||
from pysearpc import SearpcError
|
||||
import json
|
||||
|
||||
@@ -34,8 +33,8 @@ class SeafileAPI(object):
|
||||
Return: the access token in string
|
||||
"""
|
||||
onetime = 1 if bool(use_onetime) else 0
|
||||
return seafserv_rpc.web_get_access_token(repo_id, obj_id, op, username,
|
||||
onetime)
|
||||
return seafserv_threaded_rpc.web_get_access_token(repo_id, obj_id, op, username,
|
||||
onetime)
|
||||
|
||||
def query_fileserver_access_token(self, token):
|
||||
"""Get the WebAccess object
|
||||
@@ -44,17 +43,17 @@ class SeafileAPI(object):
|
||||
|
||||
Return: the WebAccess object (lib/webaccess.vala)
|
||||
"""
|
||||
return seafserv_rpc.web_query_access_token(token)
|
||||
return seafserv_threaded_rpc.web_query_access_token(token)
|
||||
|
||||
def query_zip_progress(self, token):
|
||||
"""Query zip progress for download-dir, download-multi
|
||||
token: obtained by get_fileserver_access_token
|
||||
Return: json formated string `{"zipped":, "total":}`, otherwise None.
|
||||
"""
|
||||
return seafserv_rpc.query_zip_progress(token)
|
||||
return seafserv_threaded_rpc.query_zip_progress(token)
|
||||
|
||||
def cancel_zip_task(self, token):
|
||||
return seafserv_rpc.cancel_zip_task(token)
|
||||
return seafserv_threaded_rpc.cancel_zip_task(token)
|
||||
|
||||
# password
|
||||
|
||||
@@ -62,13 +61,13 @@ class SeafileAPI(object):
|
||||
"""
|
||||
Return non-zero if True, otherwise 0.
|
||||
"""
|
||||
return seafserv_rpc.is_passwd_set(repo_id, username)
|
||||
return seafserv_threaded_rpc.is_passwd_set(repo_id, username)
|
||||
|
||||
def get_decrypt_key(self, repo_id, username):
|
||||
"""
|
||||
Return: a CryptKey object (lib/crypt.vala)
|
||||
"""
|
||||
return seafserv_rpc.get_decrypt_key(repo_id, username)
|
||||
return seafserv_threaded_rpc.get_decrypt_key(repo_id, username)
|
||||
|
||||
def change_repo_passwd(self, repo_id, old_passwd, new_passwd, user):
|
||||
return seafserv_threaded_rpc.change_repo_passwd(repo_id, old_passwd,
|
||||
@@ -311,10 +310,10 @@ class SeafileAPI(object):
|
||||
replace, username, need_progress, synchronous)
|
||||
|
||||
def get_copy_task(self, task_id):
|
||||
return seafserv_rpc.get_copy_task(task_id)
|
||||
return seafserv_threaded_rpc.get_copy_task(task_id)
|
||||
|
||||
def cancel_copy_task(self, task_id):
|
||||
return seafserv_rpc.cancel_copy_task(task_id)
|
||||
return seafserv_threaded_rpc.cancel_copy_task(task_id)
|
||||
|
||||
def rename_file(self, repo_id, parent_dir, oldname, newname, username):
|
||||
return seafserv_threaded_rpc.rename_file(repo_id, parent_dir,
|
||||
|
@@ -3,8 +3,8 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import ConfigParser
|
||||
from urlparse import urlparse
|
||||
import configparser
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import ccnet
|
||||
import seafile
|
||||
@@ -25,22 +25,25 @@ def _load_path_from_env(key, check=True):
|
||||
raise ImportError("Seaserv cannot be imported, because environment variable %s is undefined." % key)
|
||||
return None
|
||||
if _DEBUG:
|
||||
print "Loading %s from %s" % (key, v)
|
||||
print("Loading %s from %s" % (key, v))
|
||||
return os.path.normpath(os.path.expanduser(v))
|
||||
|
||||
CCNET_CONF_PATH = _load_path_from_env('CCNET_CONF_DIR')
|
||||
SEAFILE_CONF_DIR = _load_path_from_env('SEAFILE_CONF_DIR')
|
||||
SEAFILE_CENTRAL_CONF_DIR = _load_path_from_env('SEAFILE_CENTRAL_CONF_DIR', check=False)
|
||||
|
||||
pool = ccnet.ClientPool(CCNET_CONF_PATH, central_config_dir=SEAFILE_CENTRAL_CONF_DIR)
|
||||
ccnet_rpc = ccnet.CcnetRpcClient(pool, req_pool=True)
|
||||
ccnet_threaded_rpc = ccnet.CcnetThreadedRpcClient(pool, req_pool=True)
|
||||
seafserv_rpc = seafile.ServerRpcClient(pool, req_pool=True)
|
||||
seafserv_threaded_rpc = seafile.ServerThreadedRpcClient(pool, req_pool=True)
|
||||
ccnet_pipe_path = os.path.join (CCNET_CONF_PATH, 'ccnet-rpc.sock')
|
||||
ccnet_threaded_rpc = ccnet.CcnetThreadedRpcClient(ccnet_pipe_path)
|
||||
|
||||
if SEAFILE_CENTRAL_CONF_DIR:
|
||||
seafile_pipe_path = os.path.join(SEAFILE_CENTRAL_CONF_DIR, 'seafile.sock')
|
||||
else:
|
||||
seafile_pipe_path = os.path.join(SEAFILE_CONF_DIR, 'seafile.sock')
|
||||
seafserv_threaded_rpc = seafile.ServerThreadedRpcClient(seafile_pipe_path)
|
||||
|
||||
# load ccnet server addr and port from ccnet.conf.
|
||||
# 'addr:port' is used when downloading a repo
|
||||
config = ConfigParser.ConfigParser()
|
||||
config = configparser.ConfigParser()
|
||||
config.read(os.path.join(SEAFILE_CENTRAL_CONF_DIR if SEAFILE_CENTRAL_CONF_DIR else CCNET_CONF_PATH,
|
||||
'ccnet.conf'))
|
||||
|
||||
@@ -55,7 +58,7 @@ if config.has_option('General', 'SERVICE_URL'):
|
||||
else:
|
||||
CCNET_SERVER_PORT = 10001
|
||||
else:
|
||||
print "Warning: SERVICE_URL not set in ccnet.conf"
|
||||
print("Warning: SERVICE_URL not set in ccnet.conf")
|
||||
CCNET_SERVER_ADDR = None
|
||||
CCNET_SERVER_PORT = None
|
||||
SERVICE_URL = None
|
||||
@@ -131,9 +134,6 @@ def count_emailusers():
|
||||
def get_emailuser_with_import(email):
|
||||
return ccnet_threaded_rpc.get_emailuser_with_import(email)
|
||||
|
||||
def get_session_info():
|
||||
return ccnet_rpc.get_session_info()
|
||||
|
||||
# group
|
||||
def get_group(group_id):
|
||||
group_id_int = int(group_id)
|
||||
@@ -171,7 +171,7 @@ def check_group_staff(group_id, username):
|
||||
group_id = int(group_id)
|
||||
try:
|
||||
ret = ccnet_threaded_rpc.check_group_staff(group_id, username)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
ret = 0
|
||||
|
||||
@@ -344,7 +344,7 @@ def get_repo(repo_id):
|
||||
def edit_repo(repo_id, name, desc, user):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.edit_repo(repo_id, name, desc, user)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
ret = -1
|
||||
return True if ret == 0 else False
|
||||
|
||||
@@ -354,7 +354,7 @@ def create_repo(name, desc, user, passwd):
|
||||
"""
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.create_repo(name, desc, user, passwd)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
ret = None
|
||||
return ret
|
||||
@@ -365,7 +365,7 @@ def remove_repo(repo_id):
|
||||
"""
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.remove_repo(repo_id)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
ret = -1
|
||||
return True if ret == 0 else False
|
||||
@@ -784,7 +784,7 @@ def post_empty_file(repo_id, parent_dir, file_name, user):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.post_empty_file(repo_id, parent_dir,
|
||||
file_name, user)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
ret = -1
|
||||
return True if ret == 0 else False
|
||||
@@ -796,7 +796,7 @@ def del_file(repo_id, parent_dir, file_name, user):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.del_file(repo_id, parent_dir,
|
||||
file_name, user)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
ret = -1
|
||||
return True if ret == 0 else False
|
||||
@@ -816,14 +816,14 @@ def is_valid_filename(file_or_dir):
|
||||
def get_file_size(store_id, version, file_id):
|
||||
try:
|
||||
fs = seafserv_threaded_rpc.get_file_size(store_id, version, file_id)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
fs = 0
|
||||
return fs
|
||||
|
||||
def get_file_id_by_path(repo_id, path):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.get_file_id_by_path(repo_id, path)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
ret = ''
|
||||
return ret
|
||||
|
||||
@@ -889,7 +889,7 @@ def get_related_users_by_org_repo(org_id, repo_id):
|
||||
def check_quota(repo_id, delta=0):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.check_quota(repo_id, delta)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
ret = -1
|
||||
return ret
|
||||
@@ -897,7 +897,7 @@ def check_quota(repo_id, delta=0):
|
||||
def get_user_quota(user):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.get_user_quota(user)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
ret = 0
|
||||
return ret
|
||||
@@ -905,7 +905,7 @@ def get_user_quota(user):
|
||||
def get_user_quota_usage(user):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.get_user_quota_usage(user)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
ret = 0
|
||||
return ret
|
||||
@@ -913,7 +913,7 @@ def get_user_quota_usage(user):
|
||||
def get_user_share_usage(user):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.get_user_share_usage(user)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
ret = 0
|
||||
return ret
|
||||
@@ -922,7 +922,7 @@ def get_user_share_usage(user):
|
||||
def web_get_access_token(repo_id, obj_id, op, username, use_onetime=1):
|
||||
try:
|
||||
ret = seafserv_rpc.web_get_access_token(repo_id, obj_id, op, username, use_onetime)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
ret = ''
|
||||
return ret
|
||||
|
||||
@@ -936,14 +936,14 @@ def unset_repo_passwd(repo_id, user):
|
||||
"""
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.unset_passwd(repo_id, user)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
ret = -1
|
||||
return ret
|
||||
|
||||
def is_passwd_set(repo_id, user):
|
||||
try:
|
||||
ret = seafserv_rpc.is_passwd_set(repo_id, user)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
ret = -1
|
||||
return True if ret == 1 else False
|
||||
|
||||
@@ -951,13 +951,13 @@ def is_passwd_set(repo_id, user):
|
||||
def get_repo_history_limit(repo_id):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.get_repo_history_limit(repo_id)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
ret = -1
|
||||
return ret
|
||||
|
||||
def set_repo_history_limit(repo_id, days):
|
||||
try:
|
||||
ret = seafserv_threaded_rpc.set_repo_history_limit(repo_id, days)
|
||||
except SearpcError, e:
|
||||
except SearpcError as e:
|
||||
ret = -1
|
||||
return ret
|
||||
|
Reference in New Issue
Block a user