forked from loafle/openapi-generator-original
Revert "[Python] Fix issue in python client"
This commit is contained in:
parent
e8d40a146c
commit
c59e2b88b1
@ -25,7 +25,6 @@ from .rest import ApiException
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import urllib
|
import urllib
|
||||||
import json
|
import json
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
@ -31,7 +31,6 @@ except ImportError:
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from six import iteritems
|
|
||||||
|
|
||||||
def singleton(cls, *args, **kw):
|
def singleton(cls, *args, **kw):
|
||||||
instances = {}
|
instances = {}
|
||||||
@ -73,17 +72,12 @@ class Configuration(object):
|
|||||||
self.password = ""
|
self.password = ""
|
||||||
|
|
||||||
# Logging Settings
|
# Logging Settings
|
||||||
self.logger = {}
|
|
||||||
self.logger["package_logger"] = logging.getLogger("{{packageName}}")
|
|
||||||
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
|
|
||||||
# Log format
|
|
||||||
self.logging_format = '%(asctime)s %(levelname)s %(message)s'
|
self.logging_format = '%(asctime)s %(levelname)s %(message)s'
|
||||||
# Debug file location
|
# Debug file location
|
||||||
self.logging_stream_handler = None
|
self.__logging_file = None
|
||||||
self.logging_file_handler = None
|
|
||||||
self.logging_file = None
|
|
||||||
# Debug switch
|
# Debug switch
|
||||||
self.debug = False
|
self.__debug = False
|
||||||
|
self.init_logger()
|
||||||
|
|
||||||
# SSL/TLS verification
|
# SSL/TLS verification
|
||||||
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
||||||
@ -91,6 +85,24 @@ class Configuration(object):
|
|||||||
# Set this to customize the certificate file to verify the peer.
|
# Set this to customize the certificate file to verify the peer.
|
||||||
self.ssl_ca_cert = None
|
self.ssl_ca_cert = None
|
||||||
|
|
||||||
|
def init_logger(self):
|
||||||
|
"""
|
||||||
|
Initializes logger settings.
|
||||||
|
"""
|
||||||
|
self.logger = logging.getLogger()
|
||||||
|
formatter = logging.Formatter(self.logging_format)
|
||||||
|
stream_handler = logging.StreamHandler()
|
||||||
|
stream_handler.setFormatter(formatter)
|
||||||
|
self.logger.addHandler(stream_handler)
|
||||||
|
if self.__debug:
|
||||||
|
self.logger.setLevel(logging.DEBUG)
|
||||||
|
else:
|
||||||
|
self.logger.setLevel(logging.WARNING)
|
||||||
|
if self.__logging_file:
|
||||||
|
file_handler = logging.FileHandler(self.__logging_file)
|
||||||
|
file_handler.setFormatter(formatter)
|
||||||
|
self.logger.addFilter(file_handler)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def logging_file(self):
|
def logging_file(self):
|
||||||
return self.__logging_file
|
return self.__logging_file
|
||||||
@ -99,23 +111,10 @@ class Configuration(object):
|
|||||||
def logging_file(self, value):
|
def logging_file(self, value):
|
||||||
self.__logging_file = value
|
self.__logging_file = value
|
||||||
if self.__logging_file:
|
if self.__logging_file:
|
||||||
# If set logging file,
|
formater = logging.Formatter(self.logging_format)
|
||||||
# then add file handler and remove stream handler.
|
file_handler = logging.FileHandler(self.__logging_file)
|
||||||
self.logging_file_handler = logging.FileHandler(self.__logging_file)
|
file_handler.setFormatter(formater)
|
||||||
self.logging_file_handler.setFormatter(self.logging_formatter)
|
self.logger.addHandler(file_handler)
|
||||||
for _, logger in iteritems(self.logger):
|
|
||||||
logger.addHandler(self.logging_file_handler)
|
|
||||||
if self.logging_stream_handler:
|
|
||||||
logger.removeHandler(self.logging_stream_handler)
|
|
||||||
else:
|
|
||||||
# If not set logging file,
|
|
||||||
# then add stream handler and remove file handler.
|
|
||||||
self.logging_stream_handler = logging.StreamHandler()
|
|
||||||
self.logging_stream_handler.setFormatter(self.logging_formatter)
|
|
||||||
for _, logger in iteritems(self.logger):
|
|
||||||
logger.addHandler(self.logging_stream_handler)
|
|
||||||
if self.logging_file_handler:
|
|
||||||
logger.removeHandler(self.logging_file_handler)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def debug(self):
|
def debug(self):
|
||||||
@ -126,26 +125,13 @@ class Configuration(object):
|
|||||||
self.__debug = value
|
self.__debug = value
|
||||||
if self.__debug:
|
if self.__debug:
|
||||||
# if debug status is True, turn on debug logging
|
# if debug status is True, turn on debug logging
|
||||||
for _, logger in iteritems(self.logger):
|
self.logger.setLevel(logging.DEBUG)
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
# turn on httplib debug
|
# turn on httplib debug
|
||||||
httplib.HTTPConnection.debuglevel = 1
|
httplib.HTTPConnection.debuglevel = 1
|
||||||
else:
|
else:
|
||||||
# if debug status is False, turn off debug logging,
|
# if debug status is False, turn off debug logging,
|
||||||
# setting log level to default `logging.WARNING`
|
# setting log level to default `logging.WARNING`
|
||||||
for _, logger in iteritems(self.logger):
|
self.logger.setLevel(logging.WARNING)
|
||||||
logger.setLevel(logging.WARNING)
|
|
||||||
# turn off httplib debug
|
|
||||||
httplib.HTTPConnection.debuglevel = 0
|
|
||||||
|
|
||||||
@property
|
|
||||||
def logging_format(self):
|
|
||||||
return self.__logging_format
|
|
||||||
|
|
||||||
@logging_format.setter
|
|
||||||
def logging_format(self, value):
|
|
||||||
self.__logging_format = value
|
|
||||||
self.logging_formatter = logging.Formatter(self.__logging_format)
|
|
||||||
|
|
||||||
def get_api_key_with_prefix(self, identifier):
|
def get_api_key_with_prefix(self, identifier):
|
||||||
"""
|
"""
|
||||||
|
@ -25,7 +25,6 @@ from .rest import ApiException
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import urllib
|
import urllib
|
||||||
import json
|
import json
|
||||||
import mimetypes
|
import mimetypes
|
||||||
@ -181,19 +180,16 @@ class ApiClient(object):
|
|||||||
If obj is str, int, float, bool, return directly.
|
If obj is str, int, float, bool, return directly.
|
||||||
If obj is datetime.datetime, datetime.date
|
If obj is datetime.datetime, datetime.date
|
||||||
convert to string in iso8601 format.
|
convert to string in iso8601 format.
|
||||||
If obj is list, sanitize each element in the list.
|
If obj is list, santize each element in the list.
|
||||||
If obj is dict, return the dict.
|
If obj is dict, return the dict.
|
||||||
If obj is swagger model, return the properties dict.
|
If obj is swagger model, return the properties dict.
|
||||||
|
|
||||||
:param obj: The data to serialize.
|
:param obj: The data to serialize.
|
||||||
:return: The serialized form of data.
|
:return: The serialized form of data.
|
||||||
"""
|
"""
|
||||||
types = (str, int, float, bool, tuple)
|
|
||||||
if sys.version_info < (3,0):
|
|
||||||
types = types + (unicode,)
|
|
||||||
if isinstance(obj, type(None)):
|
if isinstance(obj, type(None)):
|
||||||
return None
|
return None
|
||||||
elif isinstance(obj, types):
|
elif isinstance(obj, (str, int, float, bool, tuple)):
|
||||||
return obj
|
return obj
|
||||||
elif isinstance(obj, list):
|
elif isinstance(obj, list):
|
||||||
return [self.sanitize_for_serialization(sub_obj)
|
return [self.sanitize_for_serialization(sub_obj)
|
||||||
|
@ -31,7 +31,6 @@ except ImportError:
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from six import iteritems
|
|
||||||
|
|
||||||
def singleton(cls, *args, **kw):
|
def singleton(cls, *args, **kw):
|
||||||
instances = {}
|
instances = {}
|
||||||
@ -73,17 +72,12 @@ class Configuration(object):
|
|||||||
self.password = ""
|
self.password = ""
|
||||||
|
|
||||||
# Logging Settings
|
# Logging Settings
|
||||||
self.logger = {}
|
|
||||||
self.logger["package_logger"] = logging.getLogger("swagger_client")
|
|
||||||
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
|
|
||||||
# Log format
|
|
||||||
self.logging_format = '%(asctime)s %(levelname)s %(message)s'
|
self.logging_format = '%(asctime)s %(levelname)s %(message)s'
|
||||||
# Debug file location
|
# Debug file location
|
||||||
self.logging_stream_handler = None
|
self.__logging_file = None
|
||||||
self.logging_file_handler = None
|
|
||||||
self.logging_file = None
|
|
||||||
# Debug switch
|
# Debug switch
|
||||||
self.debug = False
|
self.__debug = False
|
||||||
|
self.init_logger()
|
||||||
|
|
||||||
# SSL/TLS verification
|
# SSL/TLS verification
|
||||||
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
||||||
@ -91,6 +85,24 @@ class Configuration(object):
|
|||||||
# Set this to customize the certificate file to verify the peer.
|
# Set this to customize the certificate file to verify the peer.
|
||||||
self.ssl_ca_cert = None
|
self.ssl_ca_cert = None
|
||||||
|
|
||||||
|
def init_logger(self):
|
||||||
|
"""
|
||||||
|
Initializes logger settings.
|
||||||
|
"""
|
||||||
|
self.logger = logging.getLogger()
|
||||||
|
formatter = logging.Formatter(self.logging_format)
|
||||||
|
stream_handler = logging.StreamHandler()
|
||||||
|
stream_handler.setFormatter(formatter)
|
||||||
|
self.logger.addHandler(stream_handler)
|
||||||
|
if self.__debug:
|
||||||
|
self.logger.setLevel(logging.DEBUG)
|
||||||
|
else:
|
||||||
|
self.logger.setLevel(logging.WARNING)
|
||||||
|
if self.__logging_file:
|
||||||
|
file_handler = logging.FileHandler(self.__logging_file)
|
||||||
|
file_handler.setFormatter(formatter)
|
||||||
|
self.logger.addFilter(file_handler)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def logging_file(self):
|
def logging_file(self):
|
||||||
return self.__logging_file
|
return self.__logging_file
|
||||||
@ -99,23 +111,10 @@ class Configuration(object):
|
|||||||
def logging_file(self, value):
|
def logging_file(self, value):
|
||||||
self.__logging_file = value
|
self.__logging_file = value
|
||||||
if self.__logging_file:
|
if self.__logging_file:
|
||||||
# If set logging file,
|
formater = logging.Formatter(self.logging_format)
|
||||||
# then add file handler and remove stream handler.
|
file_handler = logging.FileHandler(self.__logging_file)
|
||||||
self.logging_file_handler = logging.FileHandler(self.__logging_file)
|
file_handler.setFormatter(formater)
|
||||||
self.logging_file_handler.setFormatter(self.logging_formatter)
|
self.logger.addHandler(file_handler)
|
||||||
for _, logger in iteritems(self.logger):
|
|
||||||
logger.addHandler(self.logging_file_handler)
|
|
||||||
if self.logging_stream_handler:
|
|
||||||
logger.removeHandler(self.logging_stream_handler)
|
|
||||||
else:
|
|
||||||
# If not set logging file,
|
|
||||||
# then add stream handler and remove file handler.
|
|
||||||
self.logging_stream_handler = logging.StreamHandler()
|
|
||||||
self.logging_stream_handler.setFormatter(self.logging_formatter)
|
|
||||||
for _, logger in iteritems(self.logger):
|
|
||||||
logger.addHandler(self.logging_stream_handler)
|
|
||||||
if self.logging_file_handler:
|
|
||||||
logger.removeHandler(self.logging_file_handler)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def debug(self):
|
def debug(self):
|
||||||
@ -126,26 +125,13 @@ class Configuration(object):
|
|||||||
self.__debug = value
|
self.__debug = value
|
||||||
if self.__debug:
|
if self.__debug:
|
||||||
# if debug status is True, turn on debug logging
|
# if debug status is True, turn on debug logging
|
||||||
for _, logger in iteritems(self.logger):
|
self.logger.setLevel(logging.DEBUG)
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
# turn on httplib debug
|
# turn on httplib debug
|
||||||
httplib.HTTPConnection.debuglevel = 1
|
httplib.HTTPConnection.debuglevel = 1
|
||||||
else:
|
else:
|
||||||
# if debug status is False, turn off debug logging,
|
# if debug status is False, turn off debug logging,
|
||||||
# setting log level to default `logging.WARNING`
|
# setting log level to default `logging.WARNING`
|
||||||
for _, logger in iteritems(self.logger):
|
self.logger.setLevel(logging.WARNING)
|
||||||
logger.setLevel(logging.WARNING)
|
|
||||||
# turn off httplib debug
|
|
||||||
httplib.HTTPConnection.debuglevel = 0
|
|
||||||
|
|
||||||
@property
|
|
||||||
def logging_format(self):
|
|
||||||
return self.__logging_format
|
|
||||||
|
|
||||||
@logging_format.setter
|
|
||||||
def logging_format(self, value):
|
|
||||||
self.__logging_format = value
|
|
||||||
self.logging_formatter = logging.Formatter(self.__logging_format)
|
|
||||||
|
|
||||||
def get_api_key_with_prefix(self, identifier):
|
def get_api_key_with_prefix(self, identifier):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user