mirror of
https://github.com/frozenpandaman/s3s.git
synced 2026-10-01 13:47:43 -05:00
use shutil instead of os for get_terminal_size()
- os.get_terminal_size() does not work in many situations (i.e. when python gets called from a java program) - in these situations, it will simply throw an exception, breaking the whole script - in these cases, shutil is a high level alternative providing a fallback, allowing to still use the script
This commit is contained in:
4
s3s.py
4
s3s.py
@@ -4,7 +4,7 @@
|
||||
# https://github.com/frozenpandaman/s3s
|
||||
# License: GPLv3
|
||||
|
||||
import argparse, datetime, json, os, re, requests, sys, time, uuid
|
||||
import argparse, datetime, json, os, shutil, re, requests, sys, time, uuid
|
||||
import msgpack
|
||||
from packaging import version
|
||||
from PIL import Image
|
||||
@@ -1008,7 +1008,7 @@ class SquidProgress:
|
||||
self.count = 0
|
||||
|
||||
def __call__(self):
|
||||
lineend = os.get_terminal_size()[0] - 4
|
||||
lineend = shutil.get_terminal_size()[0] - 4
|
||||
ika = '>=> ' if self.count % 2 == 0 else '===>'
|
||||
sys.stdout.write(f"\r{' '*self.count}{ika}{' '*(lineend - self.count)}")
|
||||
sys.stdout.flush()
|
||||
|
||||
Reference in New Issue
Block a user