本文整理汇总了Python中remuco.log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, sock, addr, clients, pinfo_msg, msg_handler_fn, c_type):
self.__sock = sock
self.__addr = addr
self.__clients = clients
self.__pinfo_msg = pinfo_msg
self.__msg_handler_fn = msg_handler_fn
self.__conn_type = c_type
# client info
self.info = ClientInfo()
self.__psave = False
# the following fields are used for iterative receiving on message data
# see io_recv() and io_recv_buff()
self.__rcv_buff_header = ReceiveBuffer()
self.__rcv_buff_data = ReceiveBuffer()
self.__rcv_msg_id = message.IGNORE
self.__rcv_msg_size = 0
self.__snd_buff = "" # buffer for outgoing data
# source IDs for various events
self.__sids = [
gobject.io_add_watch(self.__sock, gobject.IO_IN, self.__io_recv),
gobject.io_add_watch(self.__sock, gobject.IO_ERR, self.__io_error),
gobject.io_add_watch(self.__sock, gobject.IO_HUP, self.__io_hup)
]
self.__sid_out = 0
log.debug("send 'hello' to %s" % self)
self.send(ClientConnection.IO_HELLO)
示例2: __get_position
def __get_position(self):
sp = self.__shell.get_player()
db = self.__shell.props.db
position = 0
id_now = self.__item_id
if id_now is not None:
if sp.props.playing_from_queue:
qmodel = self.__queue_sc.props.query_model
elif self.__playlist_sc is not None:
qmodel = self.__playlist_sc.get_entry_view().props.model
else:
qmodel = None
if qmodel is not None:
for row in qmodel:
id = db.entry_get(row[0], rhythmdb.PROP_LOCATION)
if id_now == id:
break
position += 1
log.debug("position: %i" % position)
return position
示例3: __on_owner_change
def __on_owner_change(self, name, old, new):
log.debug("dbus name owner changed: '%s' -> '%s'" % (old, new))
_stop_pa(self.__pa)
if new:
_start_pa(self.__pa)
示例4: start
def start(self, shell):
if self.__shell is not None:
log.warning("already started")
return
remuco.PlayerAdapter.start(self)
self.__shell = shell
sp = self.__shell.get_player()
# gconf is used to adjust repeat and shuffle
self.__gconf = gconf.client_get_default()
# shortcuts to RB data
self.__item_id = None
self.__item_entry = None
self.__playlist_sc = sp.get_playing_source()
self.__queue_sc = self.__shell.props.queue_source
# connect to shell player signals
self.__signal_ids = (
sp.connect("playing_changed", self.__notify_playing_changed),
sp.connect("playing_uri_changed", self.__notify_playing_uri_changed),
sp.connect("playing-source-changed", self.__notify_source_changed)
)
# state sync will happen by timeout
# trigger item sync:
self.__notify_playing_uri_changed(sp, sp.get_playing_path()) # item sync
log.debug("start done")
示例5: __get_position
def __get_position(self):
sp = self.__shell.props.shell_player
db = self.__shell.props.db
position = 0
id_now = self.__item_id
if id_now is not None:
if sp.props.playing_from_queue:
qmodel = self.__queue_sc.props.query_model
elif self.__playlist_sc is not None:
qmodel = self.__playlist_sc.get_entry_view().props.model
else:
qmodel = None
if qmodel is not None:
for row in qmodel:
id = row[0].get_string(RB.RhythmDBPropType.LOCATION)
if id_now == id:
break
position += 1
log.debug("position: %i" % position)
return position
示例6: send
def send(self, msg):
"""Send a message to the client.
@param msg:
complete message (incl. ID and length) in binary format
(net.build_message() is your friend here)
@see: net.build_message()
"""
if msg is None:
log.error("** BUG ** msg is None")
return
if self.__sock is None:
log.debug("cannot send message to %s, already disconnected" % self)
return
if self.__psave:
log.debug("%s is in sleep mode, send nothing" % self)
return
self.__snd_buff = "%s%s" % (self.__snd_buff, msg)
# if not already trying to send data ..
if self.__sid_out == 0:
# .. do it when it is possible:
self.__sid_out = gobject.io_add_watch(self.__sock, gobject.IO_OUT,
self.__io_send)
示例7: get_art
def get_art(resource, prefer_thumbnail=False):
if resource is None:
return None
uri = __resource_to_file_uri(resource)
if uri is None:
log.debug("resource '%s' is not local, ignore" % resource)
return None
if prefer_thumbnail:
file = __get_art_from_thumbnails(uri)
if file is not None:
return file
file = __get_art_in_folder(uri)
if file is not None:
return file
if not prefer_thumbnail:
file = __get_art_from_thumbnails(uri)
if file is not None:
return file
return None
示例8: __get_art_in_folder
def __get_art_in_folder(uri):
"""Try to find art images in the given URI's folder.
@param uri:
a file URI ('file://...')
@return:
path to an image file or None if there is no matching image file in the
URI's folder
"""
elems = urlparse.urlparse(uri)
path = urllib.url2pathname(elems[2])
path = os.path.dirname(path)
log.debug("looking for art image in %s" % path)
files = glob.glob(os.path.join(path, "*"))
files = [os.path.basename(f) for f in files if os.path.isfile(f)]
for rx in RE_FILE:
for file in files:
if rx.match(file):
return os.path.join(path, file)
return None
示例9: __io_send
def __io_send(self, fd, cond):
""" GObject callback function (when data can be written). """
if not self.__snd_buff:
self.__sid_out = 0
return False
log.debug("try to send %d bytes to %s" % (len(self.__snd_buff), self))
try:
sent = self.__sock.send(self.__snd_buff)
except socket.error as e:
log.warning("failed to send data to %s (%s)" % (self, e))
self.disconnect()
return False
log.debug("sent %d bytes" % sent)
if sent == 0:
log.warning("failed to send data to %s" % self)
self.disconnect()
return False
self.__snd_buff = self.__snd_buff[sent:]
if not self.__snd_buff:
self.__sid_out = 0
return False
else:
return True
示例10: write_string
def write_string(self, s):
""" Write a string.
If the string is a unicode string, it will be encoded as a normal string
in Bin.NET_ENCODING. If it already is a normal string it will be
converted from Bin.HOST_ENCODING to Bin.NET_ENCODING.
"""
if s is None:
self.__write_string(s)
return
if Bin.HOST_ENCODING not in Bin.NET_ENCODING_ALT:
log.debug("convert '%s' from %s to %s" %
(s, Bin.HOST_ENCODING, Bin.NET_ENCODING))
try:
s = unicode(s, Bin.HOST_ENCODING).encode(Bin.NET_ENCODING)
except UnicodeDecodeError as e:
log.warning("could not decode '%s' with codec %s (%s)" %
(s, Bin.HOST_ENCODING, e))
except UnicodeEncodeError as e:
log.warning("could not encode '%s' with codec %s (%s)" %
(s, Bin.NET_ENCODING, e))
self.__write_string(s)
示例11: _notify_tracklist_change
def _notify_tracklist_change(self, new_len):
log.debug("tracklist change")
try:
self._mp_t.GetCurrentTrack(reply_handler=self._notify_position, error_handler=self._dbus_error)
except DBusException as e:
log.warning("dbus error: %s" % e)
示例12: __recv_buff
def __recv_buff(self, rcv_buff):
""" Receive some data and put it into the given ReceiveBuffer.
@param rcv_buff: the receive buffer to put received data into
@return: true if some data has been received, false if an error occurred
"""
try:
log.debug("try to receive %d bytes" % rcv_buff.rest)
data = self.__sock.recv(rcv_buff.rest)
except socket.timeout as e: # TODO: needed?
log.warning("connection to %s broken (%s)" % (self, e))
self.disconnect()
return False
except socket.error as e:
log.warning("connection to %s broken (%s)" % (self, e))
self.disconnect()
return False
received = len(data)
log.debug("received %d bytes" % received)
if received == 0:
log.warning("connection to %s broken (no data)" % self)
self.disconnect()
return False
rcv_buff.data = rcv_buff.data + data
rcv_buff.rest -= received
return True
示例13: __notify_playing_uri_changed
def __notify_playing_uri_changed(self, sp, uri):
"""Shell player signal callback to handle an item change."""
log.debug("playing uri changed: %s" % uri)
db = self.__shell.props.db
entry = sp.get_playing_entry()
if entry is None:
id = None
else:
id = db.entry_get(entry, rhythmdb.PROP_LOCATION)
self.__item_id = id
self.__item_entry = entry
if entry is not None and id is not None:
info = self.__get_item_from_entry(entry)
img_data = db.entry_request_extra_metadata(entry, "rb:coverArt")
if img_data is None:
img_file = self.find_image(id)
else:
try:
img_file = "%s/art.png" % self.config.cache_dir
img_data.save(img_file, "png")
except IOError, e:
log.warning("failed to save cover art (%s)" % e)
img_file = None
示例14: __notify_file_opened
def __notify_file_opened(self, totem, file):
# XXX: does not get called for podcasts from BBC plugin
log.debug("file opened: %s" % file)
self.__update_item = True
示例15: update_item
def update_item(self, id, info, img):
"""Set currently played item.
@param id:
item ID (str)
@param info:
meta information (dict)
@param img:
image / cover art (either a file name or URI or an instance of
Image.Image)
@note: Call to synchronize player state with remote clients.
@see: find_image() for finding image files for an item.
@see: remuco.INFO_... for keys to use for 'info'
"""
log.debug("new item: (%s, %s %s)" % (id, info, img))
change = self.__item_id != id
change |= self.__item_info != info
change |= self.__item_img != img
if change:
self.__item_id = id
self.__item_info = info
self.__item_img = img
self.__sync_trigger(self.__sync_item)