Support library names in configuration
This commit is contained in:
26
start.py
26
start.py
@@ -1,15 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
from seafile_client import SeafileClient, start_seaf_daemon
|
||||
from seafile_client.misc import setup_uid, create_dir
|
||||
from dsc import SeafileClient, start_seaf_daemon
|
||||
from dsc.misc import setup_uid, create_dir
|
||||
|
||||
_lg = logging.getLogger('dsc')
|
||||
|
||||
|
||||
def main():
|
||||
logging.basicConfig(format="%(asctime)s %(message)s", level=logging.INFO)
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--uid", default=os.getenv("SEAFILE_UID", default=1000), type=int)
|
||||
parser.add_argument("--gid", default=os.getenv("SEAFILE_GID", default=100), type=int)
|
||||
@@ -21,10 +26,23 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
setup_uid(args.uid, args.gid)
|
||||
start_seaf_daemon()
|
||||
create_dir(args.data_dir)
|
||||
start_seaf_daemon()
|
||||
|
||||
libs_to_sync = set()
|
||||
|
||||
client = SeafileClient(args.host, args.username, args.password)
|
||||
for lib_id in args.libs.split(sep=":"):
|
||||
for arg_lib in args.libs.split(sep=":"):
|
||||
lib_id = client.get_library_id(arg_lib)
|
||||
if lib_id:
|
||||
libs_to_sync.add(lib_id)
|
||||
else:
|
||||
_lg.warning("Library %s is not found on server %s", arg_lib, args.host)
|
||||
|
||||
# don't start to sync libraries already in sync
|
||||
libs_to_sync -= client.get_local_libraries()
|
||||
|
||||
for lib_id in libs_to_sync:
|
||||
client.sync_lib(lib_id, args.data_dir)
|
||||
client.watch_status()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user