client in api, slightl more robust client
This commit is contained in:
@@ -3,9 +3,19 @@ import argparse, sys, os, subprocess, time, re, json
|
||||
from subprocess import call, Popen, PIPE, STDOUT
|
||||
import threading
|
||||
import readline
|
||||
from tabulate import tabulate
|
||||
import glob
|
||||
from io import StringIO
|
||||
try:
|
||||
from tabulate import tabulate
|
||||
except ImportError:
|
||||
print("Install tabulate with: pip install --user tabulate")
|
||||
def tabulate(table, headers):
|
||||
value = []
|
||||
value.append("\t".join(headers))
|
||||
for row in table:
|
||||
value.append("\t".join([str(c) for c in row]))
|
||||
value.append("\n\nGet nicer tables by installing 'tabulate' package!\n")
|
||||
return "\n".join(value)
|
||||
|
||||
ROOTURL="{{ rooturl }}"
|
||||
SHARE="{{ name }}"
|
||||
@@ -138,6 +148,19 @@ def menu_download(opts):
|
||||
def menu_upload(opts):
|
||||
while True:
|
||||
print_title("Upload")
|
||||
files = sorted(os.listdir("."))
|
||||
file_table = []
|
||||
for f in files:
|
||||
if f.startswith("."):
|
||||
continue
|
||||
if os.path.isfile(f):
|
||||
file_size = round(os.path.getsize(f) / 1024 / 1024, 2)
|
||||
else:
|
||||
file_size = "[DIR]"
|
||||
f += "/"
|
||||
file_table.append((f, file_size))
|
||||
print(tabulate(file_table, headers = ("Name", "Size [Mb]")))
|
||||
|
||||
comp = Completer(choices = [])
|
||||
# we want to treat '/' as part of a word, so override the delimiters
|
||||
|
||||
@@ -207,8 +230,12 @@ def run_command(command, opts):
|
||||
|
||||
|
||||
def run_loop(opts):
|
||||
while True:
|
||||
menu(opts)
|
||||
try:
|
||||
while True:
|
||||
menu(opts)
|
||||
except KeyboardInterrupt:
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
def upload_file(file, opts):
|
||||
|
||||
Reference in New Issue
Block a user