Skip to content

Commit

Permalink
change the deprecated logger.warn with logger.warning
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Vavala <[email protected]>
  • Loading branch information
bvavala committed Apr 23, 2024
1 parent 3d28539 commit 3999658
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 57 deletions.
10 changes: 5 additions & 5 deletions eservice/pdo/eservice/scripts/EServiceCLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def ErrorResponse(request, error_code, msg) :
# -----------------------------------------------------------------
# -----------------------------------------------------------------
def __shutdown__(*args) :
logger.warn('shutdown request received')
logger.warning('shutdown request received')
reactor.callLater(1, reactor.stop)

# -----------------------------------------------------------------
Expand Down Expand Up @@ -127,9 +127,9 @@ def shutdown_twisted():
try :
reactor.run()
except ReactorNotRunning:
logger.warn('shutdown')
logger.warning('shutdown')
except :
logger.warn('shutdown')
logger.warning('shutdown')

pdo_enclave_helper.shutdown_enclave()
sys.exit(0)
Expand All @@ -144,7 +144,7 @@ def LoadEnclaveData(enclave_config, txn_keys) :
try :
enclave = pdo_enclave_helper.Enclave.read_from_file(basename, data_dir = data_dir, txn_keys = txn_keys)
except FileNotFoundError as fe :
logger.warn("enclave information file missing; {0}".format(fe.filename))
logger.warning("enclave information file missing; {0}".format(fe.filename))
return None
except Exception as e :
logger.error("problem loading enclave information; %s", str(e))
Expand All @@ -155,7 +155,7 @@ def LoadEnclaveData(enclave_config, txn_keys) :
# -----------------------------------------------------------------
# -----------------------------------------------------------------
def CreateEnclaveData(enclave_config, ledger_config, txn_keys) :
logger.warn('unable to locate the enclave data; creating new data')
logger.warning('unable to locate the enclave data; creating new data')

# create the enclave class
try :
Expand Down
28 changes: 14 additions & 14 deletions pservice/pdo/pservice/scripts/PServiceCLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def ErrorResponse(self, request, response, *msgargs) :

msg = msgargs[0].format(*msgargs[1:])
if response > 400 :
logger.warn(msg)
logger.warning(msg)
elif response > 300 :
logger.debug(msg)

Expand Down Expand Up @@ -150,7 +150,7 @@ def _secretreq(self, minfo) :
opkkey = pcrypto.SIG_PublicKey(opk)
opkkey.VerifySignature(pcrypto.string_to_byte_array(enclave_id + contract_id), pcrypto.hex_to_byte_array(signature))
except:
logger.warn("Signature verification failed")
logger.warning("Signature verification failed")
raise Error(http.BAD_REQUEST, 'Signature Mismatch')

# Get enclave state
Expand Down Expand Up @@ -218,7 +218,7 @@ def _secretreq(self, minfo) :

## -----------------------------------------------------------------
def render_GET(self, request) :
logger.warn('GET REQUEST: %s', request.uri)
logger.warning('GET REQUEST: %s', request.uri)
if request.uri == b'/info':
logger.info('info request received')
request.setHeader(b"content-type", b"text/plain")
Expand All @@ -243,16 +243,16 @@ def render_POST(self, request) :
if encoding == 'application/json' :
minfo = json.loads(data)
else :
logger.warn('unknown message encoding')
logger.warning('unknown message encoding')
return self.ErrorResponse(request, http.BAD_REQUEST, 'unknown message encoding, {0}', encoding)

reqtype = minfo.get('reqType', '**UNSPECIFIED**')
if reqtype not in self.RequestMap :
logger.warn('unknown message type')
logger.warning('unknown message type')
return self.ErrorResponse(request, http.BAD_REQUEST, 'received request for unknown message type')

except :
logger.warn('exception while decoding http request %s; %s', request.path, traceback.format_exc(20))
logger.warning('exception while decoding http request %s; %s', request.path, traceback.format_exc(20))
return self.ErrorResponse(request, http.BAD_REQUEST, 'unabled to decode incoming request {0}', data)

# and finally execute the associated method and send back the results
Expand All @@ -264,18 +264,18 @@ def render_POST(self, request) :
return response.encode('utf-8')

except Error as e :
logger.warn('exception while processing request; %s', str(e))
logger.warning('exception while processing request; %s', str(e))
# return self.ErrorResponse(request, int(e.status), 'exception while processing request {0}; {1}', request.path, str(e))
return self.ErrorResponse(request, int(e.status), 'exception while processing request')

except :
logger.warn('exception while processing http request %s; %s', request.path, traceback.format_exc(20))
logger.warning('exception while processing http request %s; %s', request.path, traceback.format_exc(20))
return self.ErrorResponse(request, http.BAD_REQUEST, 'error processing http request {0}', request.path)

# -----------------------------------------------------------------
# -----------------------------------------------------------------
def __shutdown__(*args) :
logger.warn('shutdown request received')
logger.warning('shutdown request received')
reactor.callLater(1, reactor.stop)

# -----------------------------------------------------------------
Expand Down Expand Up @@ -310,9 +310,9 @@ def shutdown_twisted():
try :
reactor.run()
except ReactorNotRunning:
logger.warn('shutdown')
logger.warning('shutdown')
except :
logger.warn('shutdown')
logger.warning('shutdown')

sys.exit(0)

Expand All @@ -327,7 +327,7 @@ def GetSecretsFilePath(data_config) :
data_file_path = putils.find_file_in_path(data_config['FileName'], data_config['SearchPath'])
return data_file_path
except FileNotFoundError as e :
logger.warn('provisioning secrets data file missing')
logger.warning('provisioning secrets data file missing')

default_file_path = os.path.realpath(os.path.join(data_config['DefaultPath'], data_config['FileName']))

Expand All @@ -352,7 +352,7 @@ def LoadEnclaveData(enclave_config) :
try :
enclave = pdo_enclave_helper.Enclave.read_from_file(basename, data_dir = data_dir)
except FileNotFoundError as fe :
logger.warn("enclave information file missing; {0}".format(fe.filename))
logger.warning("enclave information file missing; {0}".format(fe.filename))
return None
except Exception as e :
logger.error("problem loading enclave information; %s", str(e))
Expand All @@ -363,7 +363,7 @@ def LoadEnclaveData(enclave_config) :
# -----------------------------------------------------------------
# -----------------------------------------------------------------
def CreateEnclaveData(enclave_config) :
logger.warn('unable to locate the enclave data; creating new data')
logger.warning('unable to locate the enclave data; creating new data')

# create the enclave class
try :
Expand Down
2 changes: 1 addition & 1 deletion pservice/test/UnitTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def UnitTestRequest(contractid, enclaveid, opk, signature, url) :
# Code to create valid Signature for request
# goodsig = self.SigningKey.SignMessage(crypto.string_to_byte_array(enclave_id + contract_id))
# goodsig = crypto.byte_array_to_hex(goodsig)
# logger.warn('Good sig: %s', goodsig)
# logger.warning('Good sig: %s', goodsig)

provclient = ProvisioningServiceClient(url)
secret_info = provclient.get_secret(enclaveid, contractid, opk, signature)
Expand Down
2 changes: 1 addition & 1 deletion python/pdo/common/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def setup_loggers(config) :
logfile = config.get('LogFile', '__screen__')
if logfile != '__screen__' :
if not os.path.isdir(os.path.dirname(logfile)) :
warnings.warn("Logging directory {0} does not exist".format(os.path.abspath(os.path.dirname(logfile))))
warnings.warning("Logging directory {0} does not exist".format(os.path.abspath(os.path.dirname(logfile))))
sys.exit(-1)

flog = logging.handlers.RotatingFileHandler(logfile, maxBytes=2*1024*1024, backupCount=1000, mode='a')
Expand Down
4 changes: 2 additions & 2 deletions python/pdo/common/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def deprecated(func):
@functools.wraps(func)
def new_func(*args, **kwargs):
stack = inspect.stack()
logger.warn('invocation of deprecated function %s by %s in file %s', func.__name__, stack[1][3], stack[1][1])
logger.warning('invocation of deprecated function %s by %s in file %s', func.__name__, stack[1][3], stack[1][1])
return func(*args, **kwargs)

return new_func
Expand All @@ -62,7 +62,7 @@ def experimental(func):
@functools.wraps(func)
def new_func(*args, **kwargs):
stack = inspect.stack()
logger.warn('invocation of experimental function %s by %s in file %s', func.__name__, stack[1][3], stack[1][1])
logger.warning('invocation of experimental function %s by %s in file %s', func.__name__, stack[1][3], stack[1][1])
return func(*args, **kwargs)

return new_func
Expand Down
2 changes: 1 addition & 1 deletion python/pdo/common/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def IndexMultipartRequest(request) :
value, headers = cgi.parse_header(request.parts[p].headers[b'Content-Disposition'].decode())
name = headers.get('name')
if name is None :
logger.warn('missing name from multipart request')
logger.warning('missing name from multipart request')
index[name] = p

return index
Expand Down
4 changes: 2 additions & 2 deletions python/pdo/contract/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def read_from_file(cls, ledger_config, basename, data_dir = None) :
with open(filename, "r") as contract_file :
contract_info = json.load(contract_file)
except Exception as e :
logger.warn('load contract information file failed; %s', str(e))
logger.warning('load contract information file failed; %s', str(e))
raise Exception("invalid contract file; {}".format(filename))

try :
Expand Down Expand Up @@ -218,7 +218,7 @@ def save_to_file(self, basename, data_dir = None) :
with open(filename, "w") as contract_file :
json.dump(serialized, contract_file)
except Exception as e :
logger.warn('failed to save contract information; %s', str(e))
logger.warning('failed to save contract information; %s', str(e))
raise Exception('unable to write contract data file {}'.format(filename))

# -----------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion python/pdo/contract/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, request_originator_keys, channel_id, **kwargs) :
invocation_request = kwargs.get('invocation_request')
if invocation_request :
if not issubclass(type(invocation_request), InvocationRequest) :
logger.warn("not an InvocationRequest: %s", str(invocation_request))
logger.warning("not an InvocationRequest: %s", str(invocation_request))

self.invocation_request = str(kwargs.get('invocation_request', ''));

Expand Down
4 changes: 2 additions & 2 deletions python/pdo/contract/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def evaluate(self) :
encrypted_response = self.enclave_service.send_to_contract(encrypted_key, encrypted_request)

except Exception as e:
logger.warn('contract invocation failed; %s', str(e))
logger.warning('contract invocation failed; %s', str(e))
raise InvocationException('contract invocation failed') from e

try :
Expand Down Expand Up @@ -220,7 +220,7 @@ def evaluate(self) :
encrypted_response = self.enclave_service.initialize_contract_state(encrypted_key, encrypted_request)

except Exception as e:
logger.warn('contract invocation failed; %s', str(e))
logger.warning('contract invocation failed; %s', str(e))
raise InvocationException('contract invocation failed') from e

try :
Expand Down
16 changes: 8 additions & 8 deletions python/pdo/service_client/enclave.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,19 @@ def __send_to_contract__(self, method, encrypted_session_key, encrypted_request,
return content

except requests.Timeout as e :
logger.warn('[%d] requests timeout (invoke)', request_identifier)
logger.warning('[%d] requests timeout (invoke)', request_identifier)
raise MessageException(str(e)) from e

except requests.ConnectionError as e :
logger.warn('[%d] connection error (invoke); %s', request_identifier, e.strerror)
logger.warning('[%d] connection error (invoke); %s', request_identifier, e.strerror)
raise MessageException(str(e)) from e

except requests.HTTPError as e :
logger.warn('[%d] network error connecting to service (invoke); %s', request_identifier, str(e))
logger.warning('[%d] network error connecting to service (invoke); %s', request_identifier, str(e))
raise MessageException(str(e)) from e

except Exception as e :
logger.warn('[%d] unknown exception (invoke); %s', request_identifier, str(e))
logger.warning('[%d] unknown exception (invoke); %s', request_identifier, str(e))
raise EnclaveException(str(e)) from e

# -----------------------------------------------------------------
Expand Down Expand Up @@ -162,11 +162,11 @@ def verify_secrets(self, contract_id, owner_id, secret_list) :
return response.json()

except (requests.HTTPError, requests.ConnectionError, requests.Timeout) as e :
logger.warn('network error connecting to service (verify_secrets); %s', str(e))
logger.warning('network error connecting to service (verify_secrets); %s', str(e))
raise MessageException(str(e)) from e

except Exception as e :
logger.warn('unknown exception (verify_secrets); %s', str(e))
logger.warning('unknown exception (verify_secrets); %s', str(e))
raise EnclaveException(str(e)) from e

# -----------------------------------------------------------------
Expand All @@ -185,9 +185,9 @@ def get_enclave_public_info(self) :
return response.json()

except (requests.HTTPError, requests.ConnectionError, requests.Timeout) as e :
logger.warn('network error connecting to service (get_enclave_public_info); %s', str(e))
logger.warning('network error connecting to service (get_enclave_public_info); %s', str(e))
raise MessageException(str(e)) from e

except Exception as e :
logger.warn('unknown exception (get_enclave_public_info); %s', str(e))
logger.warning('unknown exception (get_enclave_public_info); %s', str(e))
raise EnclaveException(str(e)) from e
6 changes: 3 additions & 3 deletions python/pdo/service_client/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def _postmsg(self, request) :
response = opener.open(request, timeout=10)

except urllib.error.HTTPError as err :
logger.warn('operation failed with response: %s', err.code)
logger.warning('operation failed with response: %s', err.code)
raise MessageException('operation failed with resonse: {0}'.format(err.code))

except urllib.error.URLError as err :
logger.warn('operation failed: %s', err.reason)
logger.warning('operation failed: %s', err.reason)
raise MessageException('operation failed: {0}'.format(err.reason))

except :
logger.warn('no response from server')
logger.warning('no response from server')
raise MessageException('no response from server')

content = response.read()
Expand Down
4 changes: 2 additions & 2 deletions python/pdo/service_client/provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_secret(self, enclave_id, contract_id, creator_id, signature) :
return self._postmsg(request)

except MessageException as me :
logger.warn('Provisioning service get_secret() failed: %s', me)
logger.warning('Provisioning service get_secret() failed: %s', me)
return None

except :
Expand All @@ -67,7 +67,7 @@ def get_public_info(self) :
return self._postmsg(request)

except MessageException as me :
logger.warn('Provisioning service get_public_info() failed: %s', me)
logger.warning('Provisioning service get_public_info() failed: %s', me)
return None

except :
Expand Down
16 changes: 8 additions & 8 deletions python/pdo/service_client/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_service_info(self) :
try :
response = self.session.get(url, headers=request_headers, timeout=self.default_timeout)
except Exception as e :
logger.warn('unknown exception (get_service_info); %s', str(e))
logger.warning('unknown exception (get_service_info); %s', str(e))
raise StorageException(str(e)) from e

response.raise_for_status()
Expand All @@ -89,7 +89,7 @@ def list_blocks(self) :
try :
response = self.session.get(url, timeout=self.default_timeout)
except Exception as e :
logger.warn('unknown exception (list_blocks); %s', str(e))
logger.warning('unknown exception (list_blocks); %s', str(e))
raise StorageException(str(e)) from e

response.raise_for_status()
Expand All @@ -111,7 +111,7 @@ def get_block(self, block_id) :
try :
response = self.session.get(url, timeout=self.default_timeout)
except Exception as e :
logger.warn('unknown exception (get_block); %s', str(e))
logger.warning('unknown exception (get_block); %s', str(e))
raise StorageException(str(e)) from e

response.raise_for_status()
Expand All @@ -132,7 +132,7 @@ def get_blocks(self, block_ids) :
try :
response = self.session.post(url, json=block_ids, timeout=self.default_timeout)
except Exception as e :
logger.warn('unknown exception (get_blocks); %s', str(e))
logger.warning('unknown exception (get_blocks); %s', str(e))
raise StorageException(str(e)) from e

response.raise_for_status()
Expand All @@ -149,7 +149,7 @@ def get_blocks(self, block_ids) :

return block_data_list
except Exception as e :
logger.warn('unknown exception (get_blocks); %s', str(e))
logger.warning('unknown exception (get_blocks); %s', str(e))
raise StorageException(str(e)) from e

# -----------------------------------------------------------------
Expand Down Expand Up @@ -180,13 +180,13 @@ def store_blocks(self, block_data_list, duration=60) :
mp_encoder = MultipartEncoder(request_data)
request_headers['content-type'] = mp_encoder.content_type
except Exception as e :
logger.warn('unknown exception (store_blocks); %s', str(e))
logger.warning('unknown exception (store_blocks); %s', str(e))
raise StorageException(str(e)) from e

try :
response = self.session.post(url, data=mp_encoder.to_string(), headers=request_headers, timeout=self.default_timeout)
except Exception as e :
logger.warn('unknown exception (store_blocks); %s', str(e))
logger.warning('unknown exception (store_blocks); %s', str(e))
raise StorageException(str(e)) from e

response.raise_for_status()
Expand All @@ -210,7 +210,7 @@ def check_blocks(self, block_ids) :
try :
response = self.session.post(url, json=block_ids, timeout=self.default_timeout)
except Exception as e :
logger.warn('unknown exception (check_blocks); %s', str(e))
logger.warning('unknown exception (check_blocks); %s', str(e))
raise StorageException(str(e)) from e

response.raise_for_status()
Expand Down
Loading

0 comments on commit 3999658

Please sign in to comment.