mirror of
https://opendev.org/x/pyghmi
synced 2026-01-10 02:02:30 +00:00
Fix webclient upload
The os import was missing. Further, the call to urandom creates a yield if monkey patched that may have _upbuffer not existing. Change-Id: Ie8a1f17600df3fa21139430d39efbea2e9169bd9
This commit is contained in:
@@ -24,6 +24,7 @@ import json
|
||||
import socket
|
||||
import ssl
|
||||
import threading
|
||||
import os
|
||||
|
||||
import six
|
||||
|
||||
@@ -142,6 +143,7 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
self.broken = False
|
||||
self.thehost = host
|
||||
self.theport = port
|
||||
self._upbuffer = None
|
||||
try:
|
||||
httplib.HTTPConnection.__init__(self, host, port, strict=strict,
|
||||
**kwargs)
|
||||
@@ -384,6 +386,8 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
return body
|
||||
|
||||
def get_upload_progress(self):
|
||||
if self._upbuffer is None:
|
||||
return 0.0
|
||||
return float(self._upbuffer.tell()) / float(self.ulsize)
|
||||
|
||||
def request(self, method, url, body=None, headers=None, referer=None):
|
||||
|
||||
Reference in New Issue
Block a user