Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jhollowe committed Apr 4, 2024
1 parent d7419ab commit 2b64c12
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
}
},
"cSpell.words": [
Expand All @@ -31,7 +31,9 @@
"rtype",
"sess",
"toolbelt",
"UPID",
"vmid",
"vzdump",
"vztmpl"
],
"autoDocstring.docstringFormat": "sphinx",
Expand Down
17 changes: 17 additions & 0 deletions proxmoxer/backends/https.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

logger = logging.getLogger(__name__)
logger.setLevel(level=logging.WARNING)
progress_logger = logging.getLogger(__name__ + "_progress")
logger.setLevel(level=logging.WARNING)

STREAMING_SIZE_THRESHOLD = 10 * 1024 * 1024 # 10 MiB
SSL_OVERFLOW_THRESHOLD = 2147483135 # 2^31 - 1 - 512
Expand Down Expand Up @@ -228,6 +230,11 @@ def request(
logger.info(
"Installing 'requests_toolbelt' will decrease memory used during upload"
)
progress_logger.info(
"Multipart upload not possible. No progress will be reported."
)
else:
progress_logger.info("Multipart upload not used. No progress will be reported.")

return super().request(
method,
Expand All @@ -247,6 +254,16 @@ def request(
cert,
)

def get_progress_cb(encoder):
full_size = encoder.len

def progress_callback(monitor):
sent_size = monitor.bytes_read
pct_done = 100 * sent_size / (1.0 * full_size)
progress_logger.debug(f"Upload progress: {sent_size}/{full_size} ({pct_done}%)")

return progress_callback


class Backend:
def __init__(
Expand Down
2 changes: 1 addition & 1 deletion proxmoxer/tools/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class SupportedChecksums(Enum):
# ordered by preference for longer/stronger checksums first
SHA512 = ChecksumInfo("sha512", 128)
SHA256 = ChecksumInfo("sha256", 64)
SHA224 = ChecksumInfo("sha224", 56)
SHA384 = ChecksumInfo("sha384", 96)
SHA224 = ChecksumInfo("sha224", 56)
MD5 = ChecksumInfo("md5", 32)
SHA1 = ChecksumInfo("sha1", 40)

Expand Down

0 comments on commit 2b64c12

Please sign in to comment.