本文整理汇总了Python中kivy.logger.Logger.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.debug方法的具体用法?Python Logger.debug怎么用?Python Logger.debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.logger.Logger
的用法示例。
在下文中一共展示了Logger.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enter_wpos
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def enter_wpos(self, axis, v):
i = ord(axis) - ord('x')
v = v.strip()
if v.startswith('/'):
# we divide current value by this
try:
d = float(v[1:])
v = str(self.app.wpos[i] / d)
except Exception:
Logger.warning("DROWidget: cannot divide by: {}".format(v))
self.app.wpos[i] = self.app.wpos[i]
return
try:
# needed because the filter does not allow -ive numbers WTF!!!
f = float(v.strip())
except Exception:
Logger.warning("DROWidget: invalid float input: {}".format(v))
# set the display back to what it was, this looks odd but it forces the display to update
self.app.wpos[i] = self.app.wpos[i]
return
Logger.debug("DROWidget: Set axis {} wpos to {}".format(axis, f))
self.app.comms.write('G10 L20 P0 {}{}\n'.format(axis.upper(), f))
self.app.wpos[i] = f
示例2: do_action
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def do_action(self, key):
if key == 'Send':
# Logger.debug("KbdWidget: Sending {}".format(self.display.text))
if self.display.text.strip():
self._add_line_to_log('<< {}'.format(self.display.text))
self.app.comms.write('{}\n'.format(self.display.text))
self.last_command = self.display.text
self.display.text = ''
elif key == 'Repeat':
self.display.text = self.last_command
elif key == 'BS':
self.display.text = self.display.text[:-1]
elif key == '?':
self.handle_input('?')
else:
self.display.text += key
示例3: _upload_gcode
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def _upload_gcode(self, file_path, dir_path):
if not file_path:
return
try:
self.nlines = Comms.file_len(file_path, self.app.fast_stream) # get number of lines so we can do progress and ETA
Logger.debug('MainWindow: number of lines: {}'.format(self.nlines))
except Exception:
Logger.warning('MainWindow: exception in file_len: {}'.format(traceback.format_exc()))
self.nlines = None
self.start_print_time = datetime.datetime.now()
self.display('>>> Uploading file: {}, {} lines'.format(file_path, self.nlines))
if not self.app.comms.upload_gcode(file_path, progress=lambda x: self.display_progress(x), done=self._upload_gcode_done):
self.display('WARNING Unable to upload file')
return
else:
self.is_printing = True
示例4: reinit
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def reinit(self, **kwargs):
"""
Re-initializes Datamodel on change in model configuration from settings
:param kwargs:
:return:
"""
self.minval = kwargs.get("minval", self.minval)
self.maxval = kwargs.get("maxval", self.maxval)
time_interval = kwargs.get("time_interval", None)
try:
if time_interval and int(time_interval) != self.time_interval:
self.time_interval = time_interval
if self.is_simulating:
self.simulate_timer.cancel()
self.simulate_timer = BackgroundJob("simulation", self.time_interval,
self._simulate_block_values)
self.dirty_thread = False
self.start_stop_simulation(self.simulate)
except ValueError:
Logger.debug("Error while reinitializing DataModel %s" % kwargs)
示例5: activate_module
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def activate_module(self, name, win):
'''Activate a module on a window'''
if name not in self.mods:
Logger.warning('Modules: Module <%s> not found' % name)
return
mod = self.mods[name]
# ensure the module has been configured
if 'module' not in mod:
self._configure_module(name)
pymod = mod['module']
if not mod['activated']:
context = mod['context']
msg = 'Modules: Start <{0}> with config {1}'.format(
name, context)
Logger.debug(msg)
pymod.start(win, context)
mod['activated'] = True
示例6: register
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def register(category, limit=None, timeout=None):
'''Register a new category in the cache with the specified limit.
:Parameters:
`category` : str
Identifier of the category.
`limit` : int (optional)
Maximum number of objects allowed in the cache.
If None, no limit is applied.
`timeout` : double (optional)
Time after which to delete the object if it has not been used.
If None, no timeout is applied.
'''
Cache._categories[category] = {
'limit': limit,
'timeout': timeout}
Cache._objects[category] = {}
Logger.debug(
'Cache: register <%s> with limit=%s, timeout=%s' %
(category, str(limit), str(timeout)))
示例7: screenshot
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def screenshot(self, *largs, **kwargs):
global glReadPixels, GL_RGBA, GL_UNSIGNED_BYTE
filename = super(WindowPygame, self).screenshot(*largs, **kwargs)
if filename is None:
return None
if glReadPixels is None:
from kivy.graphics.opengl import (glReadPixels, GL_RGBA,
GL_UNSIGNED_BYTE)
width, height = self.system_size
data = glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE)
if PY2:
data = str(buffer(data))
else:
data = bytes(bytearray(data))
surface = pygame.image.fromstring(data, (width, height), 'RGBA', True)
pygame.image.save(surface, filename)
Logger.debug('Window: Screenshot saved at <%s>' % filename)
return filename
示例8: add_to_tree
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def add_to_tree(self,*args):
if self.path=='':
return
file_list={}
file_list['image']=get_file_list(self.path,formats=['jpg','jpeg','bmp','png'])
file_list['video']=get_file_list(self.path,formats=['avi','mp4','tiff','tif'])
tree={'node_id':'resources','children':[],'type':'root','display':'text_viewer'}
for data_format in file_list:
for file_path in file_list[data_format]:
tree['children'].append({
'node_id':file_path.split(os.sep)[-1],
'type':'file_path',
'content':file_path,
'display':data_format+'_viewer',
'children':[]})
self.data.tree=tree
if len(self.data.tree['children'])>0:
self.data.select_idx=[0,0]
else:
self.data.select_idx=[0]
self.property('data').dispatch(self)
Logger.debug('Files: Opened {}'.format(self.path))
示例9: start
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def start(self):
Logger.info("TelemetryManager: start() telemetry_enabled: " + str(self.telemetry_enabled) + " cell_enabled: " + str(self.cell_enabled))
self._auth_failed = False
if self._should_connect:
if self._connection_process and not self._connection_process.is_alive():
Logger.info("TelemetryManager: connection process is dead")
self._connect()
elif not self._connection_process:
if self.device_id and self.channels:
Logger.debug("TelemetryManager: starting telemetry thread")
self._connect()
else:
Logger.warning('TelemetryManager: Device id, channels missing or RCP cell enabled '
'when attempting to start. Aborting.')
else:
Logger.warning('TelemetryManager: self._should_connect is false, not connecting')
# Creates new TelemetryConnection in separate thread
示例10: _results_has_distance
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def _results_has_distance(self, results):
distance_values = results.get('Distance')
interval_values = results.get('Interval')
# Some sanity checking
if not (distance_values and interval_values):
return False
distance_values = distance_values.values
interval_values = interval_values.values
if not (len(distance_values) > 0 and len(interval_values) > 0):
return False
# calculate the ratio of total distance / time
total_time_ms = interval_values[-1] - interval_values[0]
total_distance = distance_values[-1]
distance_ratio = total_distance / total_time_ms if total_time_ms > 0 else 0
Logger.debug('Checking distance threshold. Time: {} Distance: {} Ratio: {}'.format(total_time_ms, total_distance, distance_ratio))
return distance_ratio > LineChart.MEANINGFUL_DISTANCE_RATIO_THRESHOLD
示例11: open
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def open(self, vid, pid):
retval = False
# Stores an enumeration of all the connected USB HID devices
# en = Enumeration(vid=vid, pid=pid)
en = Enumeration()
# for d in en.find():
# print(d.description())
# return a list of devices based on the search parameters
devices = en.find(vid=vid, pid=pid, interface=0)
if not devices:
Logger.debug("RawHID: No matching device found")
return None
if len(devices) > 1:
Logger.debug("RawHID: more than one device found: {}".format(devices))
return None
# open the device
self.hid = devices[0]
self.hid.open()
Logger.debug("RawHID: Opened: {}".format(self.hid.description()))
return True
# Close HID connection and clean up.
#
# Returns True on success.
# Returns False on failure.
示例12: open
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def open(self, vid, pid):
self.opened = False
# Stores an enumeration of all the connected USB HID devices
# en = Enumeration(vid=vid, pid=pid)
en = Enumeration()
# for d in en.find():
# print(d.description())
# return a list of devices based on the search parameters
devices = en.find(vid=vid, pid=pid, interface=0)
if not devices:
Logger.debug("HB04HID: No matching device found")
return None
if len(devices) > 1:
Logger.debug("HB04HID: more than one device found: {}".format(devices))
return None
# open the device
self.hid = devices[0]
self.hid.open()
Logger.debug("HB04HID: Opened: {}".format(self.hid.description()))
self.opened = True
return True
# Close HID connection and clean up.
#
# Returns True on success.
# Returns False on failure.
示例13: connected
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def connected(self):
Logger.debug("MainWindow: Connected...")
self.add_line_to_log("...Connected")
self.app.is_connected = True
self.ids.connect_button.state = 'down'
self.ids.connect_button.text = "Disconnect"
self.ids.print_but.text = 'Run'
self.paused = False
self.is_printing = False
示例14: _start_print
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def _start_print(self, file_path=None, directory=None):
# start comms thread to stream the file
# set comms.ping_pong to False for fast stream mode
if file_path is None:
file_path = self.app.gcode_file
if directory is None:
directory = self.last_path
Logger.info('MainWindow: printing file: {}'.format(file_path))
try:
self.nlines = Comms.file_len(file_path, self.app.fast_stream) # get number of lines so we can do progress and ETA
Logger.debug('MainWindow: number of lines: {}'.format(self.nlines))
except Exception:
Logger.warning('MainWindow: exception in file_len: {}'.format(traceback.format_exc()))
self.nlines = None
self.start_print_time = datetime.datetime.now()
self.display('>>> Running file: {}, {} lines'.format(file_path, self.nlines))
if self.app.fast_stream:
self.display('>>> Using fast stream')
if self.app.comms.stream_gcode(file_path, progress=lambda x: self.display_progress(x)):
self.display('>>> Run started at: {}'.format(self.start_print_time.strftime('%x %X')))
else:
self.display('WARNING Unable to start print')
return
self.set_last_file(directory, file_path)
self.ids.print_but.text = 'Pause'
self.is_printing = True
self.paused = False
示例15: extrude
# 需要导入模块: from kivy.logger import Logger [as 别名]
# 或者: from kivy.logger.Logger import debug [as 别名]
def extrude(self):
''' called when the extrude button is pressed '''
Logger.debug('Extruder: extrude {0} mm @ {1} mm/min'.format(self.ids.extrude_length.text, self.ids.extrude_speed.text))
self.app.comms.write('M120 G91 G0 E{0} F{1} M121\n'.format(self.ids.extrude_length.text, self.ids.extrude_speed.text))