本文整理汇总了Python中Logging.Logging.get_logger方法的典型用法代码示例。如果您正苦于以下问题:Python Logging.get_logger方法的具体用法?Python Logging.get_logger怎么用?Python Logging.get_logger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logging.Logging
的用法示例。
在下文中一共展示了Logging.get_logger方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import get_logger [as 别名]
def post(url, endpoint, payload):
"""
Make a POST request to the desired URL with the supplied Payload
:param url: URL to make the POST Request to
:type url: str
:param endpoint: Path of the URL to make the request to
:type endpoint: str
:param payload: POST Payload
:type payload: dict
:return: Result JSON, If the request was made successfully
:rtype: str, bool
"""
url_endpoint = url + endpoint
Logging.get_logger(__name__).info('Making POST Request to ' + url_endpoint)
desk_config = Config.load_params()['Desk.com']
if desk_config['auth_method'] == 'oauth':
oauth_session = OAuth1Session(desk_config['client_key'],
client_secret=desk_config['client_secret'],
resource_owner_key=desk_config['resource_owner_key'],
resource_owner_secret=desk_config['resource_owner_secret'])
request = oauth_session.post(url_endpoint, payload)
else:
request = requests.post(url_endpoint, json=payload, auth=(desk_config['username'], desk_config['password']))
try:
return request.json(), request.status_code == 200
except Exception, e:
Logging.get_logger(__name__).error('Problem Getting JSON from POST Request - %s' % e.message)
return []
示例2: get
# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import get_logger [as 别名]
def get(url, endpoint):
"""
Make a GET request to the desk.com API using the pre-configured authentication method
:param url: URL to make the GET Request to
:type url: str
:param endpoint: Path of the URL to make the request to
:type endpoint: str
:return: Returned JSON
:rtype: str
"""
url_endpoint = url + endpoint
Logging.get_logger(__name__).info('Making GET Request to ' + url_endpoint)
desk_config = Config.load_params()['Desk.com']
if desk_config['auth_method'] == 'oauth':
oauth_session = OAuth1Session(desk_config['client_key'],
client_secret=desk_config['client_secret'],
resource_owner_key=desk_config['resource_owner_key'],
resource_owner_secret=desk_config['resource_owner_secret'])
request = oauth_session.get(url_endpoint)
else:
request = requests.get(url_endpoint, auth=(desk_config['username'], desk_config['password']))
try:
return request.json(), request.status_code == 200
except Exception, e:
Logging.get_logger(__name__).error('Problem Getting JSON from GET Request - %s' % e.message)
return []
示例3: get_filters
# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import get_logger [as 别名]
def get_filters(self):
"""
Get all the filters in Desk.com
:return: All Filters in Desk, If the request was completed successfully.
:rtype: str, bool
"""
results, ok = self.get(self.url, 'filters')
Logging.get_logger(__name__).debug('Get Filters returned %s' % str(results))
return results, ok
示例4: get_groups
# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import get_logger [as 别名]
def get_groups(self):
"""
Get all the Groups in Desk.com
:return: All Groups in Desk.com, If the request was successful
:rtype: str, bool
"""
results, ok = self.get(self.url, 'groups')
if ok:
results = results['_embedded']['entries']
Logging.get_logger(__name__).debug('Get Groups returned %s' % str(results))
return results, ok
示例5: resolve_case
# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import get_logger [as 别名]
def resolve_case(self, case_id):
"""
Mark a Case as Resolved
:param case_id: Case to Resolve
:type case_id: int
:return: The Updated Case, If the request was made successfully.
:rtype: str, bool
"""
Logging.get_logger(__name__).info("Resolving Case with ID: %d" % case_id)
result, ok = self.patch(self.url, 'cases/' + str(case_id), {"status": "resolved"})
return result, ok
示例6: add_note_to_case
# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import get_logger [as 别名]
def add_note_to_case(self, case_id, note):
"""
Add a note to the Supplied Case
:param case_id: Case to add note to
:type case_id: int
:param note: Note to be added to Case
:type note: str
:return: The Updated Case, If the request was made successfully.
:rtype: str, bool
"""
Logging.get_logger(__name__).info("Adding Note to Case with ID: %d" % case_id)
result, ok = self.post(self.url, 'cases/' + str(case_id) + '/notes',
{"body": note})
return result, ok
示例7: get_cases
# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import get_logger [as 别名]
def get_cases(self, case_filter=''):
"""
Get all cases that match the supplied filter. If no filter is supplied, all cases will be fetched.
:param case_filter: Either Customer ID, Company ID, or Filter ID
:type case_filter: str
:return: All Cases that match the filter, If the request was completed successfully.
:rtype: str, bool
"""
results, ok = self.get(self.url, 'cases' + case_filter)
all_cases = results['_embedded']['entries']
Logging.get_logger(__name__).debug('Get Cases returned %s' % str(results))
while results['_links']['next'] is not None:
results, ok = self.get(self.url, results['_links']['next']['href'].split('/')[-1])
Logging.get_logger(__name__).debug('Get Cases returned %s' % str(results))
all_cases.append(results['_embedded']['entries'])
Logging.get_logger(__name__).info('Fetched a total of %d cases.' % len(all_cases))
marshaled_results = Marshal.desk_case(all_cases)
for case in marshaled_results:
case.customer = self.get_customer(case.customer_id)[0]
return marshaled_results, ok
示例8: load_params
# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import get_logger [as 别名]
def load_params():
params = json.loads(os.environ["Params"])
Logging.get_logger(__name__).debug("Config File Loaded")
return params
示例9: Desk
# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import get_logger [as 别名]
:type url: str
:param email: Email of the Faculty who requested the Ticket
:type email: str
:return: If the email was sent successfully
:rtype: bool
"""
file_name = url.split('/')[-1]
file_path = '/nas/streaming/faculty/ondemand/user' + url[url.find('nas/user/') + 8:]
r = requests.get(Config.load_params()['Rohan_Search']['url'] + 'rest/email',
{'email': email, 'path': file_path, 'name': file_name})
return r.status_code == 200
if __name__ == "__main__":
desk = Desk(Config.load_params()['Desk.com']['site_name'])
cases = desk.get_cases_by_group('Digitizing')[0]
for case in cases:
if case.status != 'resolved' and case.status != 'closed':
if case.custom_fields['streaming_url'] is not None and case.custom_fields['streaming_url'] != "":
Logging.get_logger(__name__).info("Found Case that is Ready for Processing")
Logging.get_logger(__name__).debug("Case %d is ready for Processing" % case.id)
client_email = case.customer.emails[0]['value']
send_ticket(case.custom_fields['streaming_url'], client_email)
desk.add_note_to_case(case.id, 'Streaming Ticket sent to Faculty on %s by Automation System' %
datetime.datetime.now().strftime('%c'))
desk.resolve_case(case.id)