本文整理汇总了Python中utils.logger.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_add
def do_add(self, tqname=None, namespace='mobile', account=1, version=1, payload=None, tags=None, priority='low', delay=0):
'''
Insert one task into the specific task queue.
Params:
tqname: Name of task queue.
namespace: Namespace of the task queue.
account: Account ID.
version: Version of the resource, default value 1.
payload: Base64 encode string.
tags: Tags in the task.
priority: Priority of the task.
delay: If delay is set, the lease request will not see the added task in [delay] seconds.
Return:
Instance object of class RestResult;
Exception message
'''
assert(tqname)
resource = TQRES_TEMPLATE_STR % (version, account, namespace, tqname)
resource = '/'.join([resource, 'addtask'])
if delay > 0:
resource += '?delay=%s' % delay
data = json.dumps({'payload_base64' : payload, 'tags' : tags, 'priority' : priority}, encoding="utf-8")
logger.debug('Add task - resource:%s, data:%s' % (resource, data))
return self.m_wrest.do_access(resource, 'POST', data=data, headers=None)
示例2: do_bulk_add
def do_bulk_add(self, tqname=None, namespace='mobile', account=1, version=1, taskslist=[]):
'''
Insert tasks into the specific task queue.
Params:
tqname: Name of task queue.
namespace: Namespace of the task queue.
account: Account ID.
version: Version of the resource, default value 1.
taskslist: task structures in list.
For example: [
{
"payload_base64": "TXkgbGl0dGxlIHRhc2sK",
"tags": ["state=red", "watchthis", "code=41"],
"priority" : "high"
},
...
]
Return:
Instance object of class RestResult;
Exception message
'''
#check data is available
assert(tqname)
assert(isinstance(taskslist, list))
for task in taskslist:
assert(isinstance(task, dict))
resource = TQRES_TEMPLATE_STR % (version, account, namespace, tqname)
resource = '/'.join([resource, 'addtasks'])
data = json.dumps(taskslist, encoding="utf-8")
logger.debug('Add %d tasks - resource:%s, data:%s' % (len(taskslist), resource, data))
return self.m_wrest.do_access(resource, 'POST', data=data, headers=None)
示例3: do_update
def do_update(self, udid=None, attributes=None):
'''
Update one device information to RS
Params:
attributes: Attributes of the devicd information.
Return:
Instance object of class RestResult;
Exception message
'''
if udid:
udid_str = str(udid)
else:
udid_str = self.m_udid
if not udid_str:
raise Exception('Require device UDID!')
resource = DEVRES_TEMPLATE_STR % (self.m_ver, udid_str)
if isinstance(attributes, list):
attr = json.dumps(attributes)
elif isinstance(attributes, basestring):
attr = attributes
else:
raise Exception('Invalid input!')
content = {
'method':'modify',
'params':attributes,
}
data = json.dumps(content)
wrest = HostedAccess()
logger.debug('Update device info - resource:%s, data:%s' % (resource, data))
retval = wrest.do_access(resource, 'POST', data=data, headers=None)
del wrest
return retval
示例4: do_get_many
def do_get_many(self, tqname=None, namespace='mobile', account=1, version=1, tasknum=0, tags=None):
'''
Get a bulk of tasks' information from the specific task queue.
Params:
tqname: Name of task queue.
namespace: Namespace of the task queue.
account: Account ID.
version: Version of the resource, default value 1.
tasknum: Number of the tasks that expected.
tags: Search conditions.
Return:
Instance object of class RestResult;
Exception message
'''
assert(tqname)
resource = TQRES_TEMPLATE_STR % (version, account, namespace, tqname)
resource = '/'.join([resource, 'search?numTasks=%s'])
resource = resource % tasknum
resource = '&'.join([resource, 'orderby=priority'])
if tags:
data = json.dumps({'tags' : tags}, encoding="utf-8")
else:
data = tags
logger.debug('Get tasks - resource:%s, data:%s' % (resource, data))
return self.m_wrest.do_access(resource, 'POST', data=data, headers=None)
示例5: move_task_to_errorqueue
def move_task_to_errorqueue(self, error_msg):
hostedTQ = HostedTaskQueue()
if type(self.m_tags)!=list:
logger.error('task tags is not a list:[%s]' % self.m_tags)
raise Exception('tags type error in move_task_to_errorqueue')
if TASK_STATUS_DICT['normal'] in self.m_tags:
self.m_tags.remove(TASK_STATUS_DICT['normal'])
if TASK_STATUS_DICT['retry'] in self.m_tags:
self.m_tags.remove(TASK_STATUS_DICT['retry'])
self.m_tags.append(TASK_STATUS_DICT['error'])
tag_error = 'error_msg_base64=%s' % base64.encodestring(error_msg).replace('\n', '')
self.m_tags.append(tag_error)
try:
hostedTQ.do_add(tqname=self.m_error_qname, namespace='mobile', account=int(self.m_account), version=1, payload=self.m_payload_base64, tags=self.m_tags, priority = self.m_priority)
except MDMiHttpError, e:
logger.debug('add error task failed:%s, will try to create error queue' % repr(e))
error_qname_list = [
{'name' : 'enrollmentError', 'settings' : {"description" : "Enrollment Decision Error task queue", "max_leases" : "30", "max_age" : "0"}}
]
tqo = TaskQueueUtils(error_qname_list)
tqo.init_task_queue()
del tqo
hostedTQ.do_add(tqname=self.m_error_qname, namespace='mobile', account=int(self.m_account), version=1, payload=self.m_payload_base64, tags=self.m_tags, priority = self.m_priority)
示例6: put_data
def put_data(self, data, block=True, timeout=0):
task_data = {}
data = json.loads(data)
if data['sync_type'] == 'metanate':
key = ':'.join(['metanate', str(data['account']), data['trans_type'], data['sync_source']])
task_data['key'] = key
task_data['value'] = data
elif data['sync_type'] == 'hybrid':
key = ':'.join([data['sync_type'], str(data['account'])])
task_data['key'] = key
task_data['value'] = data
while not self.__stop_event.is_set():
try:
self.__queue.put(task_data, block, timeout)
logger.debug('put task data (%s, %s) successfully' % (key, data))
break
except Full:
logger.debug('task cache size reachs max size')
self.full_event.clear()
self.full_event.wait()
except Exception, e:
logger.error('put task data into cache error %s' % repr(e))
break
示例7: setup_table
def setup_table(self, num):
table = 'test_%s' % num
self.cursor.execute('SHOW TABLES LIKE %s', [table])
if self.cursor.fetchone():
# Table already exists.
return table
logger.debug('Creating table "%s"' % table)
_dir = dirname(__file__) or '.'
with open(_dir + '/mysql_mid_table.sql', 'rb') as f:
sql = f.read() % num
self.cursor.execute(sql.strip(' ;\r\n'))
delta = timedelta(seconds=self.CREATED_INTERVAL)
start_dt = datetime.now() - delta * num
for chunk in xrange(int(ceil(float(num) / self.CHUNK_SIZE))):
values = list(chain(*[[
MID_RECORD['name'] % (i + chunk * self.CHUNK_SIZE),
MID_RECORD['data'],
start_dt + delta * i,
] for i in xrange(self.CHUNK_SIZE)]))
sql = (
'INSERT INTO `%s` (`name`, `data`, `created`) VALUES ' % table
) + ('(%s, %s, %s), ' * self.CHUNK_SIZE)[:-2]
self.cursor.execute('BEGIN')
self.cursor.execute(sql, values)
self.cursor.execute('COMMIT')
# logger.debug(
# 'Inserted chunk #%s with %s middle sized records',
# chunk + 1, self.CHUNK_SIZE
# )
logger.debug('Created with %s records' % num)
return table
示例8: _get
def _get(self, method, args):
"""
private helper to perform an api call
"""
url = self.API_BASE % (self.api_key, method, "/".join(args))
logger.debug("fetching url '%s'" % url)
return self._get_url(url)
示例9: run
def run(self):
# read keys from files at first
if self.m_enable_init:
logger.info('Creator %d running, doing init!' % os.getpid())
keys_list = self._init_keys_list()
for item in keys_list:
if not self.m_keylist_queue.full():
self._put(item)
else:
# waiting for init finished
logger.debug('Creator %d running, waiting init done!' % os.getpid())
while not self.m_ready_evt.is_set():
if self._idle(1):
return
logger.info('Creator %d init done!' % os.getpid())
self._generate_keys_handle()
# clean multiprocess queue
self.m_keylist_queue.close()
while not self.m_keylist_queue.empty():
self.m_keylist_queue.get(1)
logger.info('key pool creator(%d) exits' % os.getpid())
return
pass
示例10: do_bulk_op
def do_bulk_op(self, content):
'''
Bulk add or/and update device information into RS
Params:
content: data in a specific format, generated by format_bulk_data
Return:
instance object of class RestResult;
exception message
'''
if isinstance(content, list):
data = json.dumps(content)
elif isinstance(attributes, basestring):
data = content
else:
raise Exception('Invalid content!')
resource = BULK_OP_URL % self.m_ver
wrest = HostedAccess()
logger.debug('bulk operation info - resource:%s, data:%s' % (resource, data))
retval = wrest.do_access(resource, 'POST', data=data, headers=None)
del wrest
return retval
示例11: list_sdk_versions
def list_sdk_versions(args):
logger.debug(' * Retreiving list of App Engine SDK versions')
versions = sdk.get_versions()
for version in sdk.get_versions():
print '{0}.{1}.{2}'.format(*version)
sys.exit(0)
示例12: do_insert
def do_insert(self, devinfo=None):
'''
Insert one new device information to RS
Params:
devinfo: Detail information of the device.
Return:
Instance object of class RestResult;
Exception message
'''
if not self.m_udid:
raise Exception('Require device UDID!')
resource = DEVRES_TEMPLATE_STR % (self.m_ver, self.m_udid)
if isinstance(devinfo, dict):
temp = devinfo
elif isinstance(devinfo, basestring):
temp = json.loads(devinfo)
else:
raise Exception('Invalid input!')
temp = {'attributes':temp}
data = json.dumps(temp)
wrest = HostedAccess()
logger.debug('Insert new device info - resource:%s, data:%s' % (resource, data))
retval = wrest.do_access(resource, 'PUT', data=data, headers=None)
del wrest
return retval
示例13: signal_handler
def signal_handler(signum, frame):
logger.debug('Catched interrupt signal: %d in main process', signum)
if signum == signal.SIGHUP:
reload_config()
g_service_status.reload_status()
else:
stop_children()
示例14: do_update
def do_update(self, tqname=None, namespace='mobile', account=1, version=1, taskname=0, payload=None, tags=None, priority='low', enqueuetime=''):
'''
Modify seciton value of one task.
Params:
tqname: Name of task queue.
namespace: Namespace of the task queue.
account: Account ID.
version: Version of the resource, default value 1.
taskname: Name of the specific task.
payload: Base64 encode string.
tags: Tags in the task.
priority: Priority of the task.
enqueuetime: Last modify time.
Return:
Instance object of class RestResult;
Exception message
'''
assert(tqname)
assert(payload and tags)
resource = TQRES_TEMPLATE_STR % (version, account, namespace, tqname)
temp = 'task-%s' % taskname
resource = '/'.join([resource, temp])
data = json.dumps({'payload_base64' : payload, 'tags' : tags, 'priority' : priority}, encoding="utf-8")
header = self.m_wrest.generate_default_header()
header.update({'If-Unmodified-Since' : enqueuetime})
logger.debug('Update task - resource:%s, header:%s, data:%s' % (resource, header, data))
return self.m_wrest.do_access(resource, 'PUT', data=data, headers=header)
示例15: resolve
def resolve(address, uuid, adapter=None, bus=dbus.SystemBus()):
try:
adapter.CreateDevice(address)
logger.debug("Device created: %s" % address)
except:
logger.debug("Device all ready known: %s" % address)
path = adapter.FindDevice(address)
device = dbus.Interface(bus.get_object("org.bluez", path),
"org.bluez.Device")
properties = device.GetProperties()
if uuid in properties['UUIDs']:
services = device.DiscoverServices(uuid);
for key in services.keys():
root=etree.XML(str(services[key]))
res=CHANNEL_XPATH(root)
if len(res)>0:
return int(res[0], 16)
# lets check if the service is there now
#adapter.RemoveDevice(path)
raise Exception("UUID not found")