本文整理汇总了Python中kivy.Logger.error方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.error方法的具体用法?Python Logger.error怎么用?Python Logger.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.Logger
的用法示例。
在下文中一共展示了Logger.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def refresh(self, place):
last_updated = now = datetime.now()
tomorrow = now + timedelta(days=1)
place_cache = self.weather_data.get(place, {})
if place in self.update_stamps:
last_updated = self.update_stamps[place]
if not place_cache or (now - last_updated).total_seconds() >= self.update_interval:
try:
self.weather_data[place] = self.api_object.weather_at_place(place).get_weather()
self.forecast_today_data[place] = self.api_object.daily_forecast(place).get_weather_at(
now.replace(hour=12))
try:
self.forecast_tomorrow_data[place] = self.api_object.daily_forecast(place).get_weather_at(
tomorrow.replace(hour=12))
except Exception:
self.forecast_tomorrow_data[place] = {}
self.update_stamps[place] = datetime.now()
except Exception as e:
self.update_stamps[place] = datetime.now()
Logger.error('WEATHER: Failed to get data: {}'.format(e))
return False
except APICallError as e:
self.update_stamps[place] = datetime.now()
Logger.error('WEATHER: Failed to get data: {}'.format(e))
return False
return True
示例2: update
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def update(self):
self.news = feedparser.parse(self.feed_url)
article_list = []
xlocale = locale.getlocale(locale.LC_TIME)
locale.setlocale(locale.LC_TIME, 'en_US.utf-8')
if not self.news['items']:
Logger.error('NEWS: Seems there\'s no news')
return # Return here so we keep old news (if any)
for x in self.news['items']:
description = unicode(x['description']).strip()
description = description.split('<', 1)[0].strip()
title = unicode(x['title']).strip()
if description == '.':
title = u'[color=#FFDD63]{}[/color]'.format(title)
description = ''
article_date = (datetime.strptime(x['published'], "%a, %d %b %Y %H:%M:%S %Z") + timedelta(hours=2))
article_relative_date = format_timedelta(article_date - datetime.now(),
granularity='minute',
locale='ro_RO.utf-8',
add_direction=True)
article_list.append(u'{}\n[color=#777777]{}[/color]\n\n{}'.format(title,
article_relative_date,
description))
locale.setlocale(locale.LC_TIME, xlocale)
self.articles = deque(article_list)
示例3: on_connection_established
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def on_connection_established(self, characteristic, error):
if error:
Logger.error("BLE: connection failed: {}".format(error))
self.on_device_disconnect(None)
return
Logger.info("BLE: connection established {}".format(repr(characteristic.value)))
self.start_data()
示例4: on_device_disconnect
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def on_device_disconnect(self, device, error=None):
if error:
Logger.error("BLE: device disconnected: {}".format(error))
else:
Logger.info("BLE: device disconnected")
self.connected = None
self.ble_should_scan = True
示例5: play
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def play(self, *args):
if not self._loaded_stream:
self.select_stream(self.current_stream)
try:
self._loaded_stream.play()
Logger.info("Radio: playing %s" % self.stream_list[0])
self.is_playing = True
self.play_status = 'Radio: Pornit'
except Exception as e:
self.play_status = 'Radio: Eroare'
Logger.error('Radio: Failed to play stream: {}'.format(e.message))
示例6: on_discover_services
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def on_discover_services(self, services, error):
if error:
Logger.error("BLE: error discovering services: {}".format(error))
return
Logger.info("BLE: discovered services: {}".format(services.keys()))
service = services[self.connect_uuid]
if not service:
Logger.error("BLE: service not found!")
return
service.discover_characteristics(on_discover=self.on_discover_characteristics)
示例7: on_discover_characteristics
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def on_discover_characteristics(self, characteristics, error):
if error:
Logger.error("BLE: error discovering characteristics: {}".format(error))
return
# Logger.info('BLE: discovered characteristics: {}'.format(characteristics.keys()))
for uuid, char in characteristics.items():
Logger.info("BLE: discovered characteristic: {} {:02x}".format(uuid, char.properties))
if uuid == self.connection_uuid:
Logger.info("BLE: found connection characteristic")
char.read(on_read=self.on_connection_established)
elif uuid == self.module_message_uuid:
Logger.info("BLE: found module message characteristic")
self.module_message_characteristic = char
示例8: on_device_connect
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def on_device_connect(self, device, error=None):
self.connecting = None
if error:
Logger.error("BLE: failed to connect to device: {}".format(error))
self.ble_should_scan = True
return
Logger.info("BLE: connected to device {}".format(device))
self.connected = device
# device.discover_services(uuids=(self.connect_uuid,), on_discover=self.on_discover_services)
service = device.services[self.connect_uuid]
if service:
Logger.info("BLE: found service {}".format(service))
self.on_discover_services(device.services, None)
else:
device.discover_services(on_discover=self.on_discover_services)
示例9: criptiklogo
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def criptiklogo():
"""
Read the logo and return it as string.
"""
logofile = "{}/../data/logo.txt".format(dirname(realpath(__file__)))
try:
# Open and read logo file
with open(logofile, "r") as f:
logo = "".join(f.readlines())
except IOError:
# No logo present
Logger.error("UTILITIES: Failed to read cryptikchaos logo.")
return None
else:
# Return logo if success
return logo.format(md5hash(str(getnode()))[0:8], __version__)
示例10: update
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def update(self, readings):
for reading in readings:
meaning = reading['meaning']
if meaning not in settings.MEANING_COLORS:
continue
if meaning not in self.sensors:
sensor = SensorWidget(device=self)
sensor.meaning = meaning
self.sensors[meaning] = sensor
self.sensor_container.add_widget(sensor)
if not self.history.meaning:
self.history.meaning = meaning
self.sensors[meaning].timestamp = reading['recorded']
try:
self.sensors[meaning].value = reading['value']
except ValueError:
Logger.error("Sensor: %s:%s got bad value %s" % (self.device_id, meaning, reading['value']))
self.sensors[meaning].value = 0
if meaning == self.history.meaning:
self.history.add_value(reading['value'], reading['recorded'])
示例11: pack_stream
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
#.........这里部分代码省略.........
elif stream_flag == STREAM_TYPES.AUTH:
# Generate token at source side
stream_token = generate_token(stream_uid, shared_key)
# AES Encryption
if constants.AES_AVAILABLE:
Logger.info("STREAM: Encrypting content...")
# Generate iv from stream token
iv = md5hash(stream_token, hexdigest=False)
# Create AES object
AES_obj = AES.new(shared_key, AES.MODE_CBC, iv)
# Pad string
stream_content = self.pad(stream_content)
# Encrypt string
stream_content = AES_obj.encrypt(stream_content)
# Create stream object
stream_obj = Stream(
stream_uid,
stream_flag,
stream_type,
stream_content,
stream_token,
)
# Add stream to store
self.add_store(
stream_uid, stream_obj.dict
)
if stream_flag == STREAM_TYPES.UNAUTH:
Logger.info("STREAM: Packing Authentication Stream...")
# Pack store into authentication stream
stream = struct.pack(
"!?{}s{}s{}s{}s".format(
constants.STREAM_TYPE_LEN,
constants.STREAM_CONTENT_LEN,
constants.STREAM_PEER_KEY_LEN,
constants.STREAM_CHKSUM_LEN
),
self.get_store_item(stream_uid, 'STREAM_FLAG'),
self.get_store_item(stream_uid, 'STREAM_TYPE'),
self.get_store_item(stream_uid, 'STREAM_CONTENT'),
self.get_store_item(stream_uid, 'STREAM_PKEY'),
self.get_store_hmac(stream_uid)
)
elif stream_flag == STREAM_TYPES.AUTH:
Logger.info("STREAM: Packing Message Stream...")
# Pack store into message block stream
stream = struct.pack(
"!?{}s{}s{}s{}s".format(
constants.STREAM_TYPE_LEN,
constants.STREAM_CONTENT_LEN,
constants.STREAM_TOKEN_LEN,
constants.STREAM_CHKSUM_LEN
),
self.get_store_item(stream_uid, 'STREAM_FLAG'),
self.get_store_item(stream_uid, 'STREAM_TYPE'),
self.get_store_item(stream_uid, 'STREAM_CONTENT'),
self.get_store_item(stream_uid, 'STREAM_PKEY'),
self.get_store_hmac(stream_uid)
)
else:
Logger.error("STREAM: Invalid Stream Flag received.")
return None
def pkey_action(val):
val = md5hash(val)
return val
if stream_flag == STREAM_TYPES.UNAUTH:
Logger.debug("""STREAM: Packing: \n{}""".format(
self.storage_table(shorten_len=64, action_dict={"STREAM_PKEY":pkey_action}) ))
Logger.debug("""DEBUG STREAM:
FLAG: {}
TYPE: {}
CONTENT: {}
KEY: {}
CHECKSUM: {}
""".format(
self.get_store_item(stream_uid, 'STREAM_FLAG'),
self.get_store_item(stream_uid, 'STREAM_TYPE'),
_debug_stream_content,
b64encode(self.get_store_item(stream_uid, 'STREAM_PKEY')),
self.get_store_hmac(stream_uid)))
# Compress stream
if constants.ENABLE_COMPRESSION:
Logger.info("STREAM: Compressing Stream...")
stream = compress(stream)
Logger.info("STREAM: Succesfully packed stream.")
return stream
示例12: unpack_stream
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def unpack_stream(self, stream, shared_key=None):
"Unpack serial data into stream."
# Decompress data stream
if constants.ENABLE_COMPRESSION:
Logger.info("STREAM: Decompressing Stream...")
stream = decompress(stream)
# Check if data is of expected chunk size
if len(stream) != constants.STREAM_SIZE_AUTH_BLOCK and \
len(stream) != constants.STREAM_SIZE_MSG_BLOCK:
raise StreamOverflowError()
if len(stream) == constants.STREAM_SIZE_AUTH_BLOCK:
Logger.info("STREAM: Unpacking Authentication Stream...")
# Unpack auth stream to variables
(
stream_flag,
stream_type,
stream_content,
stream_token,
stream_hmac
) = struct.unpack(
"!?{}s{}s{}s{}s".format(
constants.STREAM_TYPE_LEN,
constants.STREAM_CONTENT_LEN,
constants.STREAM_PEER_KEY_LEN,
constants.STREAM_CHKSUM_LEN
), stream
)
elif len(stream) == constants.STREAM_SIZE_MSG_BLOCK:
Logger.info("STREAM: Unpacking Message Stream...")
# Unpack msg block stream to variables
(
stream_flag,
stream_type,
stream_content,
stream_token,
stream_hmac
) = struct.unpack(
"!?{}s{}s{}s{}s".format(
constants.STREAM_TYPE_LEN,
constants.STREAM_CONTENT_LEN,
constants.STREAM_TOKEN_LEN,
constants.STREAM_CHKSUM_LEN
), stream
)
else:
Logger.error("STREAM: Invalid Stream Length received.")
return [None] * 3
# Remove all null characters if present
stream_content = stream_content.rstrip('\0')
stream_token = stream_token.rstrip('\0')
# Get uid
stream_uid = generate_uuid(self.peer_host)
# Get stream object
stream_obj = Stream(
stream_uid,
stream_flag,
stream_type,
stream_content,
stream_token,
)
# Add stream to store
self.add_store(stream_uid, stream_obj.dict)
# Verify stream integrity
if not self.check_hmac(stream_uid, stream_hmac):
Logger.error("STREAM: Stream Checksum mismatch.")
return [None] * 3
# Check stream signing mode
if stream_flag == STREAM_TYPES.UNAUTH:
# Stream key is peer public key
pass
elif stream_flag == STREAM_TYPES.AUTH:
# Generate token at destination side
# Perform key challenge
if generate_token(stream_uid, shared_key) != stream_token:
Logger.error("STREAM: Token challenge Fail!")
Logger.error("STREAM: RCVD: {}".format(b64encode(stream_token)))
Logger.error("STREAM: EXPD: {}".format(b64encode(generate_token(stream_uid, shared_key))))
return [None] * 3
else:
Logger.info("STREAM: Token challenge Pass!")
# AES Decryption
if constants.AES_AVAILABLE:
Logger.info("STREAM: Decrypting content...")
# Generate iv from stream token
iv = md5hash(stream_token, hexdigest=False)
#.........这里部分代码省略.........
示例13: getContext
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def getContext(self):
"Get SSL context."
# Now the options you can set Standard OpenSSL Library options
# Selecting Transport Layer Security v1
# The SSL protocol to use, one of SSLv23_METHOD, SSLv2_METHOD,
# SSLv3_METHOD, TLSv1_METHOD. Defaults to TLSv1_METHOD.
self.method = SSL.TLSv1_METHOD
# If True, verify certificates received from the peer and fail
# the handshake if verification fails. Otherwise, allow anonymous
# sessions and sessions with certificates which fail validation.
self.verify = True
# Depth in certificate chain down to which to verify.
self.verifyDepth = 1
# If True, do not allow anonymous sessions.
self.requireCertification = True
# If True, do not re-verify the certificate on session resumption.
self.verifyOnce = True
# If True, generate a new key whenever ephemeral DH parameters are used
# to prevent small subgroup attacks.
self.enableSingleUseKeys = True
# If True, set a session ID on each context. This allows a shortened
# handshake to be used when a known client reconnects.
self.enableSessions = True
# If True, enable various non-spec protocol fixes for broken
# SSL implementations.
self.fixBrokenPeers = False
# Get the client context factory
ctx = ssl.ClientContextFactory.getContext(self)
# Load certificate
try:
ctx.use_certificate_file(self.crt)
except SSL.Error as exception:
Logger.error("SSLCONTEXT: "+exception.message[0][2])
raise SSLCertReadError(self.crt)
else:
Logger.info("SSLCONTEXT: Loaded Peer SSL Certificate.")
# Load private key
try:
ctx.use_privatekey_file(self.key)
except SSL.Error as exception:
Logger.error("SSLCONTEXT"+exception.message[0][2])
raise SSLKeyReadError(self.key)
else:
Logger.info("SSLCONTEXT: Loaded Peer SSL key.")
# Set verify mode and verify callback chain.
ctx.set_verify(
SSL.VERIFY_PEER | SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
self.verifyCallback
)
# Since we have self-signed certs we have to explicitly
# tell the server to trust them.
ctx.load_verify_locations(self.ca)
return ctx
示例14: on_char_write
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def on_char_write(self, char, error):
if error:
Logger.error("BLE: error writing data: {}: {}".format(char, error))
else:
Logger.debug("BLE: write successful: {}".format(char))
示例15: peripheral_advertising_error
# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import error [as 别名]
def peripheral_advertising_error(self, error):
Logger.error("BLE: connect: advertisement error: {}".format(error))