[Linux] Support token as cmdline arguments. (#2489)

sso-login-use-system-browser
sun20121818 2021-09-07 15:58:14 +08:00 committed by GitHub
parent 207bd49dcc
commit 0f20ebd1d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 50 additions and 31 deletions

View File

@ -424,13 +424,16 @@ def seaf_list_remote(args):
username = user_from_config
if not username:
username = input("Enter username: ")
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s : " % username)
tfa = args.tfa
# curl -d 'username=<USERNAME>&password=<PASSWORD>' http://127.0.0.1:8000/api2/auth-token
token = get_token(url, username, password, tfa, conf_dir)
token = args.token
password = None
tfa = args.tfa
if not token:
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s : " % username)
# curl -d 'username=<USERNAME>&password=<PASSWORD>' http://127.0.0.1:8000/api2/auth-token
token = get_token(url, username, password, tfa, conf_dir)
repos = get_repo_download_info("%s/api2/repos/" % (url), token)
@ -503,13 +506,15 @@ def seaf_download(args):
username = user_from_config
if not username:
username = input("Enter username: ")
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s : " % username)
token = args.token
password = None
tfa = args.tfa
# curl -d 'username=<USERNAME>&password=<PASSWORD>' http://127.0.0.1:8000/api2/auth-token
token = get_token(url, username, password, tfa, conf_dir)
if not token:
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s : " % username)
# curl -d 'username=<USERNAME>&password=<PASSWORD>' http://127.0.0.1:8000/api2/auth-token
token = get_token(url, username, password, tfa, conf_dir)
tmp = get_repo_download_info("%s/api2/repos/%s/download-info/" % (url, repo), token)
@ -590,14 +595,17 @@ def seaf_download_by_name(args):
if not username:
username = input("Enter username: ")
args.username = username
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s : " % username)
args.password = password
tfa = args.tfa
# curl -d 'username=<USERNAME>&password=<PASSWORD>' http://127.0.0.1:8000/api2/auth-token
token = get_token(url, username, password, tfa, conf_dir)
token = args.token
password = None
tfa = args.tfa
if not token:
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s : " % username)
args.password = password
# curl -d 'username=<USERNAME>&password=<PASSWORD>' http://127.0.0.1:8000/api2/auth-token
token = get_token(url, username, password, tfa, conf_dir)
tmp = get_repo_download_info("%s/api2/repos/" % (url), token)
@ -656,12 +664,16 @@ def seaf_sync(args):
username = user_from_config;
if not username:
username = input("Enter username: ")
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s : " % username)
tfa = args.tfa
token = get_token(url, username, password, tfa, conf_dir)
password = None
token = args.token
tfa = args.tfa
if not token:
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s : " % username)
token = get_token(url, username, password, tfa, conf_dir)
tmp = get_repo_download_info("%s/api2/repos/%s/download-info/" % (url, repo), token)
encrypted = tmp['encrypted']
@ -850,12 +862,7 @@ def seaf_create(args):
username = user_from_config;
if not username:
username = input("Enter username: ")
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s " % username)
tfa = args.tfa
# check url
url = args.server
if not url and server_from_config:
url = server_from_config
@ -863,8 +870,15 @@ def seaf_create(args):
print("Seafile server url need to be presented")
sys.exit(1)
# curl -d 'username=<USERNAME>&password=<PASSWORD>' http://127.0.0.1:8000/api2/auth-token
token = get_token(url, username, password, tfa, conf_dir)
token = args.token
password = None
tfa = args.tfa
if not token:
password = args.password
if not password:
password = getpass.getpass("Enter password for user %s " % username)
# curl -d 'username=<USERNAME>&password=<PASSWORD>' http://127.0.0.1:8000/api2/auth-token
token = get_token(url, username, password, tfa, conf_dir)
repo_id = create_repo("%s/api2/repos/" % (url), token, args)
print(repo_id)
@ -912,6 +926,7 @@ def main():
parser_download.add_argument('-s', '--server', help='URL for seafile server', type=str)
parser_download.add_argument('-u', '--username', help='username', type=str)
parser_download.add_argument('-p', '--password', help='password', type=str)
parser_download.add_argument('-T', '--token', help='token', type=str)
parser_download.add_argument('-a', '--tfa', help='two-factor authentication', type=str)
parser_download.add_argument('--json', help='output json format result', action='store_true')
@ -931,6 +946,7 @@ def main():
parser_download.add_argument('-d', '--dir', help='the directory to put the library', type=str)
parser_download.add_argument('-u', '--username', help='username', type=str)
parser_download.add_argument('-p', '--password', help='password', type=str)
parser_download.add_argument('-T', '--token', help='token', type=str)
parser_download.add_argument('-a', '--tfa', help='two-factor authentication', type=str)
parser_download.add_argument('-e', '--libpasswd', help='library password', type=str)
@ -945,6 +961,7 @@ def main():
parser_download.add_argument('-d', '--dir', help='the directory to put the library', type=str)
parser_download.add_argument('-u', '--username', help='username', type=str)
parser_download.add_argument('-p', '--password', help='password', type=str)
parser_download.add_argument('-T', '--token', help='token', type=str)
parser_download.add_argument('-a', '--tfa', help='two-factor authentication', type=str)
parser_download.add_argument('-e', '--libpasswd', help='library password', type=str)
@ -959,6 +976,7 @@ def main():
parser_sync.add_argument('-s', '--server', help='URL for seafile server', type=str)
parser_sync.add_argument('-u', '--username', help='username', type=str)
parser_sync.add_argument('-p', '--password', help='password', type=str)
parser_sync.add_argument('-T', '--token', help='token', type=str)
parser_sync.add_argument('-a', '--tfa', help='two-factor authentication', type=str)
parser_sync.add_argument('-d', '--folder', help='the existing local folder', type=str)
parser_sync.add_argument('-e', '--libpasswd', help='library password', type=str)
@ -980,6 +998,7 @@ def main():
parser_create.add_argument('-s', '--server', help='URL for seafile server', type=str)
parser_create.add_argument('-u', '--username', help='username', type=str)
parser_create.add_argument('-p', '--password', help='password', type=str)
parser_create.add_argument('-T', '--token', help='token', type=str)
parser_create.add_argument('-a', '--tfa', help='two-factor authentication', type=str)
parser_create.add_argument('-c', '--confdir', help='the config directory', type=str, required=confdir_required)
parser_create.add_argument('-C', help='the user config directory', type=str)