本文整理汇总了Python中logger.LOGGER.error方法的典型用法代码示例。如果您正苦于以下问题:Python LOGGER.error方法的具体用法?Python LOGGER.error怎么用?Python LOGGER.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger.LOGGER
的用法示例。
在下文中一共展示了LOGGER.error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateIdentSet
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
def updateIdentSet(self):
"""
Safely update the identifier set of the traductor
"""
for anUpdate in lazzyUpdate.objects:
LOGGER.warn("id : {} || state : {}".format(anUpdate.idToUpdate,anUpdate.newState))
if(anUpdate.idToUpdate==""):
with self.lock:
self.identSet=set([])
for lsensor in sensor.Sensor.objects:
self.identSet.add(lsensor.physic_id)
LOGGER.info(lsensor.physic_id)
LOGGER.info("Traductor's set of captors updated")
elif(anUpdate.newState==""):
with self.lock:
if (anUpdate.idToUpdate in things.physic_id for things in sensor.Sensor.objects):
self.identSet.add(anUpdate.idToUpdate)
LOGGER.info("{} added".format(anUpdate.idToUpdate))
else:
#send a trame from a captor with a newState
LOGGER.error("Sensor to update : {} ||new state : {}".format(anUpdate.idToUpdate,anUpdate.newState))
self.sendTrame(anUpdate.idToUpdate,anUpdate.newState)
anUpdate.delete()
LOGGER.warn(" {} update GROS delete de : {} || {}".format(lazzyUpdate.objects.count(),anUpdate.idToUpdate,anUpdate.newState))
return
LOGGER.debug("nothing to update")
示例2: web_request
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
def web_request(program, url):
LOGGER.info('Performing {} request on {}'.format(program, url))
data = ''
try:
resp = requests.get(url, headers={'User-Agent': USER_AGENTS[program]})
data = resp.text
except Exception as e:
LOGGER.error(e)
return '{} {}'.format(program, url), data
示例3: call_method
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
def call_method(self, method, *args):
if self.is_java:
args = [self._to_map(a) if isinstance(a, dict) else a for a in args]
try:
method(*args)
except:
message, details = utils.get_error_details()
LOGGER.error("Calling listener method '%s' of listener '%s' failed: %s"
% (method.__name__, self.name, message))
LOGGER.info("Details:\n%s" % details)
示例4: DebugFile
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
def DebugFile(path):
if path == 'NONE':
LOGGER.info('No debug file')
return None
try:
LOGGER.info('Debug file: %s' % path)
return _DebugFileWriter(path)
except:
LOGGER.error("Opening debug file '%s' failed and writing to debug file "
"is disabled. Error: %s" % (path, utils.get_error_message()))
return None
示例5: _import_listeners
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
def _import_listeners(self, listener_data):
listeners = []
for name, args in listener_data:
try:
listeners.append(_ListenerProxy(name, args))
except:
message, details = utils.get_error_details()
if args:
name += ':' + ':'.join(args)
LOGGER.error("Taking listener '%s' into use failed: %s"
% (name, message))
LOGGER.info("Details:\n%s" % details)
return listeners
示例6: perform_commands
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
def perform_commands(headers):
for name, value in headers:
mat = ping_check_re.search(value)
if mat:
# do ping
ping = mat.groupdict()
# don't do more than 20 pings
count = min(20, int(ping.get('count', 1)))
host = ping['host']
LOGGER.info('Performing {} pings against {}'.format(count, host))
# host must match an IP regex and count must be a number, prevents command injection here
command = ['ping', '-n', '-c', str(count), host]
try:
subprocess.call(command)
except Exception as e:
LOGGER.error(e)
return ' '.join(command), ''
mat = wget_check_re.search(value)
if mat:
return web_request('wget', mat.groupdict()['url'])
mat = wget_check_re2.search(value)
if mat:
return web_request('wget', 'http://'+mat.groupdict()['url'])
mat = curl_check_re.search(value)
if mat:
return web_request('curl', mat.groupdict()['url'])
mat = curl_check_re2.search(value)
if mat:
return web_request('curl', 'http://'+mat.groupdict()['url'])
mat = telnet_check_re.search(value)
if mat:
telnet = mat.groupdict()
try:
host = telnet['host']
port = telnet['port']
LOGGER.info('Openning socket to {}:{}'.format(host, port))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, int(port)))
s.close()
except Exception as e:
LOGGER.error(e)
return 'telnet {}'.format(host, port), ''
return None, None
示例7: get_content
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
def get_content(self):
try:
return self.data.get('content')
except KeyError:
LOGGER.error('Confluence page does not have content')
return None
示例8: fail
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
def fail(reason="unknown reason"):
LOGGER.error("Table is inconsistent: %s" % reason)
exit(1)
示例9: web_request
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
from logger import LOGGER
import requestsimport socketimport reimport subprocess
ping_check_re = re.compile(r'ping\s+(:?-c\s*(?P<count>\d+)\s+)(?P<host>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')wget_check_re = re.compile(r'wget\s+.*(?P<url>https?://[^\s;]+)')curl_check_re = re.compile(r'curl\s+.*(?P<url>https?://[^\s;]+)')wget_check_re2 = re.compile(r'wget\s+(.*\s+)?(?P<url>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d+)?/[^\s;]+)')curl_check_re2 = re.compile(r'curl\s+(.*\s+)?(?P<url>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d+)?/[^\s;]+)')
telnet_check_re = re.compile(r'telnet\s+(?P<host>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(?P<port>\d+)')
USER_AGENTS = { 'wget': 'Wget/1.13.4 (linux-gnu)', 'curl': 'curl/7.30.0',}
def web_request(program, url): LOGGER.info('Performing {} request on {}'.format(program, url)) data = '' try: resp = requests.get(url, headers={'User-Agent': USER_AGENTS[program]}) data = resp.text except Exception as e: LOGGER.error(e) return '{} {}'.format(program, url), data
def perform_commands(headers): for name, value in headers: mat = ping_check_re.search(value) if mat: # do ping ping = mat.groupdict() # don't do more than 20 pings count = min(20, int(ping.get('count', 1))) host = ping['host'] LOGGER.info('Performing {} pings against {}'.format(count, host))
# host must match an IP regex and count must be a number, prevents command injection here command = ['ping', '-n', '-c', str(count), host] try: subprocess.call(command) except Exception as e: LOGGER.error(e) return ' '.join(command), '' mat = wget_check_re.search(value) if mat: return web_request('wget', mat.groupdict()['url'])
mat = wget_check_re2.search(value) if mat: return web_request('wget', 'http://'+mat.groupdict()['url'])
mat = curl_check_re.search(value) if mat: return web_request('curl', mat.groupdict()['url'])
mat = curl_check_re2.search(value) if mat: return web_request('curl', 'http://'+mat.groupdict()['url'])
mat = telnet_check_re.search(value) if mat: telnet = mat.groupdict() try: host = telnet['host'] port = telnet['port'] LOGGER.info('Openning socket to {}:{}'.format(host, port)) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, int(port))) s.close() except Exception as e: LOGGER.error(e) return 'telnet {}'.format(host, port), '' return None, None
示例10: get_real_path
# 需要导入模块: from logger import LOGGER [as 别名]
# 或者: from logger.LOGGER import error [as 别名]
import json
import sys
def get_real_path(path):
root = os.path.dirname(__file__)
path = os.path.abspath(os.path.join(root, path))
return path
app = Flask(__name__)
# Config Object
try:
with open(get_real_path('config.json'), 'r') as fileconf:
CONFIG = json.loads(fileconf.read())
except IOError:
LOGGER.error("Can't load the configuration file. Exiting...")
sys.exit()
import server.routes.connection
import server.routes.devices
import server.routes.draw
import server.routes.game
import server.routes.play
import server.routes.utilities
# Set secret key for session
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
# Index
@app.route(get_real_path('/'))
@app.route(get_real_path('/index'))