some beautification for client
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
import argparse, sys, os, subprocess, time, re, json
|
||||
from subprocess import call, Popen, PIPE, STDOUT
|
||||
import threading
|
||||
import readline
|
||||
import glob
|
||||
from io import StringIO
|
||||
@@ -102,11 +101,12 @@ def menu(opts):
|
||||
'Download',
|
||||
'Upload'
|
||||
]
|
||||
print_title("Main")
|
||||
print_title("Main menu")
|
||||
for i,command in enumerate(commands):
|
||||
print(" %d. %s"%( i+1, command, ))
|
||||
comp = Completer(choices = ["1","2"])
|
||||
readline.set_completer(comp.complete)
|
||||
print("\n[Empty to exit]")
|
||||
choice = user_input("Number of action: ").strip()
|
||||
if choice == "1":
|
||||
menu_download(opts)
|
||||
@@ -122,7 +122,11 @@ def menu_download(opts):
|
||||
files = json.loads(run_command("file/details", opts))
|
||||
file_table = []
|
||||
for f in files:
|
||||
file_table.append((f['name'], float(f['size'].replace(",","")), f['mtime']))
|
||||
file_table.append((
|
||||
f['name'],
|
||||
float(f['size'].replace(",","")),
|
||||
f['mtime']
|
||||
))
|
||||
print(tabulate(file_table, headers = ("Name", "Size [Mb]", "Modified")))
|
||||
name_list = [x['name'] for x in files]
|
||||
comp = Completer(choices = name_list)
|
||||
@@ -201,10 +205,18 @@ def parse_options():
|
||||
|
||||
|
||||
def print_title(title):
|
||||
print("%s\n%s\n"%(
|
||||
title,
|
||||
"="*len(title)
|
||||
))
|
||||
status = "Share: %s, Server: %s"%(
|
||||
opts.share,
|
||||
opts.rooturl
|
||||
)
|
||||
pad = " "*((len(status) - len(title))/2)
|
||||
print("\n".join((
|
||||
"",
|
||||
"="*len(status),
|
||||
status,
|
||||
pad + title + pad,
|
||||
"="*len(status)
|
||||
)))
|
||||
|
||||
|
||||
def read_output(stream):
|
||||
@@ -291,20 +303,6 @@ def upload_file(file, opts):
|
||||
sys.stderr.write(char)
|
||||
sys.stderr.flush()
|
||||
|
||||
#~ read_output(p2.stdout)
|
||||
#~ tin = threading.Thread(
|
||||
#~ target=write_input, args=(p2.stdin, script)
|
||||
#~ )
|
||||
#~ tout = threading.Thread(
|
||||
#~ target=read_output, args=(p2.stdout,)
|
||||
#~ )
|
||||
#~ terr = threading.Thread(
|
||||
#~ target=read_output, args=(p2.stderr,)
|
||||
#~ )
|
||||
#~ for t in (tin, tout, terr):
|
||||
#~ t.daemon = True
|
||||
#~ t.start()
|
||||
#~ p2.wait()
|
||||
return
|
||||
|
||||
|
||||
@@ -325,4 +323,3 @@ if __name__ == "__main__":
|
||||
readline.parse_and_bind("tab: complete")
|
||||
opts = parse_options()
|
||||
run_loop(opts)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user