Fixed overlong filename w/ terminal width
This commit is contained in:
parent
6831c64cc4
commit
5c8a529fb7
3
setup.py
3
setup.py
|
@ -3,7 +3,8 @@ from setuptools import setup, find_namespace_packages
|
|||
|
||||
setup(
|
||||
name="sbeam",
|
||||
version="0.1",
|
||||
description="",
|
||||
version="0.3",
|
||||
author="JayPiKay",
|
||||
author_email="jpk+python@goatpr0n.de",
|
||||
url='https://git.goatpr0n.de/',
|
||||
|
|
11
src/sbeam.py
11
src/sbeam.py
|
@ -83,14 +83,17 @@ def receive(host, destination):
|
|||
headers={'User-Agent': 'sbeam'}) as response:
|
||||
assert response.status_code == 200
|
||||
|
||||
with click.progressbar(filelist, label='Receiving',
|
||||
bar_template='%(label)s %(info)s:') as bar:
|
||||
with click.progressbar(filelist, label='Receiving') as bar:
|
||||
for rawinfo in bar:
|
||||
if not rawinfo:
|
||||
break
|
||||
filename, filesize, filepath, timestamp = rawinfo.split('||')
|
||||
# TODO fix when filename to long
|
||||
bar.bar_template = f'%(label)s %(info)s: {filename}'
|
||||
width, height = click.get_terminal_size()
|
||||
term_space = 70 + len(filename)
|
||||
printname = filename
|
||||
if term_space > width:
|
||||
printname = filename[:-1*(term_space-width-4)]
|
||||
bar.bar_template = f'%(label)s [%(bar)s] %(info)s: {printname}'
|
||||
|
||||
fullpath = os.path.join(destination, filepath[1:])
|
||||
os.makedirs(fullpath, exist_ok=True)
|
||||
|
|
Loading…
Reference in New Issue