Improve logging.
This commit is contained in:
parent
79fdfc5fb7
commit
7314d5a8c8
@ -34,32 +34,13 @@ except Exception, e:
|
|||||||
_data_store = None
|
_data_store = None
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
|
|
||||||
def get_contents(filename):
|
|
||||||
if not filename:
|
|
||||||
return ''
|
|
||||||
f = open(filename, "r")
|
|
||||||
try:
|
|
||||||
contents = f.read()
|
|
||||||
finally:
|
|
||||||
f.close()
|
|
||||||
return contents
|
|
||||||
|
|
||||||
def create(properties, filename):
|
def create(properties, filename):
|
||||||
logging.debug('dbus_helpers.create: %s, %s' % (properties, filename))
|
|
||||||
try:
|
|
||||||
logging.debug(get_contents(filename))
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
pass
|
|
||||||
object_id = _data_store.create(dbus.Dictionary(properties), filename)
|
object_id = _data_store.create(dbus.Dictionary(properties), filename)
|
||||||
logging.debug('dbus_helpers.create: ' + object_id)
|
logging.debug('dbus_helpers.create: ' + object_id)
|
||||||
return object_id
|
return object_id
|
||||||
|
|
||||||
def update(uid, properties, filename, reply_handler=None, error_handler=None):
|
def update(uid, properties, filename, reply_handler=None, error_handler=None):
|
||||||
logging.debug('dbus_helpers.update: %s, %s, %s' % (uid, properties, filename))
|
logging.debug('dbus_helpers.update')
|
||||||
try:
|
|
||||||
logging.debug(get_contents(filename))
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
pass
|
|
||||||
if reply_handler and error_handler:
|
if reply_handler and error_handler:
|
||||||
_data_store.update(uid, dbus.Dictionary(properties), filename,
|
_data_store.update(uid, dbus.Dictionary(properties), filename,
|
||||||
reply_handler=reply_handler,
|
reply_handler=reply_handler,
|
||||||
@ -68,20 +49,16 @@ def update(uid, properties, filename, reply_handler=None, error_handler=None):
|
|||||||
_data_store.update(uid, dbus.Dictionary(properties), filename)
|
_data_store.update(uid, dbus.Dictionary(properties), filename)
|
||||||
|
|
||||||
def get_properties(uid):
|
def get_properties(uid):
|
||||||
props = _data_store.get_properties(uid)
|
logging.debug('dbus_helpers.get_properties: %s' % uid)
|
||||||
logging.debug('dbus_helpers.get_properties: %s, %s' % (uid, props))
|
return _data_store.get_properties(uid)
|
||||||
return props
|
|
||||||
|
|
||||||
def get_filename(uid):
|
def get_filename(uid):
|
||||||
filename = _data_store.get_filename(uid)
|
filename = _data_store.get_filename(uid)
|
||||||
logging.debug('dbus_helpers.get_filename: %s, %s' % (uid, filename))
|
logging.debug('dbus_helpers.get_filename: %s, %s' % (uid, filename))
|
||||||
try:
|
|
||||||
logging.debug(get_contents(filename))
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
pass
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def find(query, reply_handler, error_handler):
|
def find(query, reply_handler, error_handler):
|
||||||
|
logging.debug('dbus_helpers.find')
|
||||||
if reply_handler and error_handler:
|
if reply_handler and error_handler:
|
||||||
return _data_store.find(query, reply_handler=reply_handler,
|
return _data_store.find(query, reply_handler=reply_handler,
|
||||||
error_handler=error_handler)
|
error_handler=error_handler)
|
||||||
|
Loading…
Reference in New Issue
Block a user