Always print progress bar at 100%
This commit is contained in:
parent
dc596cfac6
commit
063cc375df
@ -13,6 +13,6 @@ __author__ = "Davide Testa"
|
|||||||
__email__ = "davide@davte.it"
|
__email__ = "davide@davte.it"
|
||||||
__credits__ = []
|
__credits__ = []
|
||||||
__license__ = "GNU General Public License v3.0"
|
__license__ = "GNU General Public License v3.0"
|
||||||
__version__ = "0.0.8"
|
__version__ = "0.0.9"
|
||||||
__maintainer__ = "Davide Testa"
|
__maintainer__ = "Davide Testa"
|
||||||
__contact__ = "t.me/davte"
|
__contact__ = "t.me/davte"
|
||||||
|
@ -399,6 +399,7 @@ class Client:
|
|||||||
self.print_progress_bar(
|
self.print_progress_bar(
|
||||||
progress=new_progress,
|
progress=new_progress,
|
||||||
bytes_=bytes_sent,
|
bytes_=bytes_sent,
|
||||||
|
force=(new_progress == 100)
|
||||||
)
|
)
|
||||||
print() # New line after progress_bar
|
print() # New line after progress_bar
|
||||||
writer.close()
|
writer.close()
|
||||||
@ -431,7 +432,8 @@ class Client:
|
|||||||
)
|
)
|
||||||
self.print_progress_bar(
|
self.print_progress_bar(
|
||||||
progress=new_progress,
|
progress=new_progress,
|
||||||
bytes_=bytes_received
|
bytes_=bytes_received,
|
||||||
|
force=(new_progress == 100)
|
||||||
)
|
)
|
||||||
if not input_data:
|
if not input_data:
|
||||||
break
|
break
|
||||||
|
@ -73,7 +73,7 @@ class Server:
|
|||||||
def set_ssl_context(self, ssl_context: ssl.SSLContext):
|
def set_ssl_context(self, ssl_context: ssl.SSLContext):
|
||||||
self._ssl_context = ssl_context
|
self._ssl_context = ssl_context
|
||||||
|
|
||||||
async def run_reader(self, reader, connection_token):
|
async def run_reader(self, reader: asyncio.StreamReader, connection_token):
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
# Wait one second if buffer is full
|
# Wait one second if buffer is full
|
||||||
@ -90,7 +90,7 @@ class Server:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Unexpected exception:\n{e}", exc_info=True)
|
logging.error(f"Unexpected exception:\n{e}", exc_info=True)
|
||||||
|
|
||||||
async def run_writer(self, writer, connection_token):
|
async def run_writer(self, writer: asyncio.StreamWriter, connection_token):
|
||||||
consecutive_interruptions = 0
|
consecutive_interruptions = 0
|
||||||
errors = 0
|
errors = 0
|
||||||
while connection_token in self.buffers:
|
while connection_token in self.buffers:
|
||||||
@ -100,6 +100,7 @@ class Server:
|
|||||||
# Slow down if buffer is empty; after 1.5 s of silence, break
|
# Slow down if buffer is empty; after 1.5 s of silence, break
|
||||||
consecutive_interruptions += 1
|
consecutive_interruptions += 1
|
||||||
if consecutive_interruptions > 3:
|
if consecutive_interruptions > 3:
|
||||||
|
logging.error("Too many interruptions...")
|
||||||
break
|
break
|
||||||
await asyncio.sleep(.5)
|
await asyncio.sleep(.5)
|
||||||
continue
|
continue
|
||||||
@ -166,6 +167,7 @@ class Server:
|
|||||||
else:
|
else:
|
||||||
return 0 # On success, return 0
|
return 0 # On success, return 0
|
||||||
# On exception, disconnect and return 1
|
# On exception, disconnect and return 1
|
||||||
|
logging.error("Disconnecting...")
|
||||||
self.disconnect(connection_token=connection_token)
|
self.disconnect(connection_token=connection_token)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ def timed_action(interval: Union[int, float, datetime.timedelta] = None):
|
|||||||
timedelta = interval
|
timedelta = interval
|
||||||
|
|
||||||
def timer(function_to_time):
|
def timer(function_to_time):
|
||||||
def timed_function(*args, **kwargs):
|
def timed_function(*args, force: bool = False, **kwargs):
|
||||||
nonlocal last_call
|
nonlocal last_call
|
||||||
if now() > last_call + timedelta:
|
if force or now() > last_call + timedelta:
|
||||||
last_call = now()
|
last_call = now()
|
||||||
return function_to_time(*args, **kwargs)
|
return function_to_time(*args, **kwargs)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user