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(
|
setup(
|
||||||
name="sbeam",
|
name="sbeam",
|
||||||
version="0.1",
|
description="",
|
||||||
|
version="0.3",
|
||||||
author="JayPiKay",
|
author="JayPiKay",
|
||||||
author_email="jpk+python@goatpr0n.de",
|
author_email="jpk+python@goatpr0n.de",
|
||||||
url='https://git.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:
|
headers={'User-Agent': 'sbeam'}) as response:
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
with click.progressbar(filelist, label='Receiving',
|
with click.progressbar(filelist, label='Receiving') as bar:
|
||||||
bar_template='%(label)s %(info)s:') as bar:
|
|
||||||
for rawinfo in bar:
|
for rawinfo in bar:
|
||||||
if not rawinfo:
|
if not rawinfo:
|
||||||
break
|
break
|
||||||
filename, filesize, filepath, timestamp = rawinfo.split('||')
|
filename, filesize, filepath, timestamp = rawinfo.split('||')
|
||||||
# TODO fix when filename to long
|
width, height = click.get_terminal_size()
|
||||||
bar.bar_template = f'%(label)s %(info)s: {filename}'
|
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:])
|
fullpath = os.path.join(destination, filepath[1:])
|
||||||
os.makedirs(fullpath, exist_ok=True)
|
os.makedirs(fullpath, exist_ok=True)
|
||||||
|
|
Loading…
Reference in New Issue