本文整理汇总了Python中remuco.log.warning函数的典型用法代码示例。如果您正苦于以下问题:Python warning函数的具体用法?Python warning怎么用?Python warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warning函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __thumbnail_img
def __thumbnail_img(self, img, img_size, img_type):
if img_size == 0:
return []
if isinstance(img, basestring) and img.startswith("file://"):
img = urlparse.urlparse(img)[2]
img = urllib.url2pathname(img)
if not img:
return []
try:
if not isinstance(img, Image.Image):
img = Image.open(img)
img.thumbnail((img_size, img_size))
file_tmp = tempfile.TemporaryFile()
img.save(file_tmp, img_type)
file_tmp.seek(0)
thumb = file_tmp.read()
file_tmp.close()
return thumb
except IOError, e:
log.warning("failed to thumbnail %s (%s)" % (img, e))
return []
开发者ID:cpatulea,项目名称:remuco,代码行数:25,代码来源:data.py
示例2: __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
开发者ID:cpatulea,项目名称:remuco,代码行数:30,代码来源:remythm.py
示例3: write_dicts_to_file
def write_dicts_to_file(filename, dicts, keys=None, comment=None):
"""Write a list of dictionaries into a file.
@param filename: Name of the file to write into.
@param dicts: Either a list of dictionaries or a list of strings, i.e.
already flattened dictionaries.
@keyword keys: See dict_to_string(). Only used if dictionaries are not yet
flattened.
@keyword comment: A comment text to put at the beginning of the file.
"""
lines = []
if comment:
lines.append("%s\n" % comment)
for dic in dicts:
if not isinstance(dic, basestring):
dic = dict_to_string(dic, keys=keys)
lines.append("%s\n" % dic)
try:
with open(filename, "w") as fp:
fp.writelines(lines)
except IOError, e:
log.warning("failed to write to %s (%s)" % (filename, e))
开发者ID:Sixthhokage2,项目名称:remuco,代码行数:26,代码来源:dictool.py
示例4: __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
开发者ID:gkfabs,项目名称:remuco,代码行数:30,代码来源:net.py
示例5: _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)
开发者ID:gkfabs,项目名称:remuco,代码行数:7,代码来源:mpris.py
示例6: 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")
开发者ID:cpatulea,项目名称:remuco,代码行数:35,代码来源:remythm.py
示例7: 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)
开发者ID:gkfabs,项目名称:remuco,代码行数:25,代码来源:serial.py
示例8: disconnect
def disconnect(self, remove_from_list=True, send_bye_msg=False):
""" Disconnect the client.
@keyword remove_from_list: whether to remove the client from the client
list or not (default is true)
@keyword send_bye_msg: whether to send a bye message before
disconnecting
"""
# send bye message
if send_bye_msg and self.__sock is not None:
log.info("send 'bye' to %s" % self)
msg = build_message(message.CONN_BYE, None)
sent = 0
retry = 0
while sent < len(msg) and retry < 10:
try:
sent += self.__sock.send(msg)
except socket.error, e:
log.warning("failed to send 'bye' to %s (%s)" % (self, e))
break
time.sleep(0.02)
retry += 1
if sent < len(msg):
log.warning("failed to send 'bye' to %s" % self)
else:
# give client some time to close connection:
time.sleep(0.1)
开发者ID:igoralmeida,项目名称:remuco,代码行数:29,代码来源:net.py
示例9: _poll_progress
def _poll_progress(self):
try:
self._mp_p.PositionGet(reply_handler=self._notify_progress,
error_handler=self._dbus_error)
except DBusException, e:
log.warning("dbus error: %s" % e)
开发者ID:Sixthhokage2,项目名称:remuco,代码行数:7,代码来源:mpris.py
示例10: notify
def notify(title, text):
"""Notify the user that a new device has been loggend."""
try:
bus = dbus.SessionBus()
except DBusException as e:
log.error("no dbus session bus (%s)" % e)
return
try:
proxy = bus.get_object("org.freedesktop.Notifications",
"/org/freedesktop/Notifications")
notid = dbus.Interface(proxy, "org.freedesktop.Notifications")
except DBusException as e:
log.error("failed to connect to notification daemon (%s)" % e)
return
try:
caps = notid.GetCapabilities()
except DBusException as e:
return
if not caps or "body-markup" not in caps:
text = text.replace("<b>", "")
text = text.replace("</b>", "")
try:
notid.Notify("Remuco", 0, "phone", title, text, [], {}, 15)
except DBusException as e:
log.warning("user notification failed (%s)" % e)
return
开发者ID:gkfabs,项目名称:remuco,代码行数:31,代码来源:remos.py
示例11: _dbus_error
def _dbus_error(self, error):
""" DBus error handler."""
if self._mp_p is None:
return # do not log errors when not stopped already
log.warning("DBus error: %s" % error)
开发者ID:Sixthhokage2,项目名称:remuco,代码行数:7,代码来源:mpris.py
示例12: __trim_root_dirs
def __trim_root_dirs(self, dirs):
"""Trim a directory list.
Expands variables and '~' and removes duplicate, relative, non
existent and optionally hidden directories.
@return: a trimmed directory list
"""
trimmed = []
for dir in dirs:
dir = os.path.expandvars(dir)
dir = os.path.expanduser(dir)
if not self.__show_hidden and dir.startswith("."):
continue
if not os.path.isabs(dir):
log.warning("path %s not absolute, ignore" % dir)
continue
if not os.path.isdir(dir):
log.warning("path %s not a directory, ignore" % dir)
continue
if dir not in trimmed:
trimmed.append(dir)
return trimmed
开发者ID:gkfabs,项目名称:remuco,代码行数:26,代码来源:files.py
示例13: start
def start(self):
PlayerAdapter.start(self)
try:
bus = dbus.SessionBus()
proxy = bus.get_object("org.mpris.%s" % self.__name, "/Player")
self._mp_p = dbus.Interface(proxy, "org.freedesktop.MediaPlayer")
proxy = bus.get_object("org.mpris.%s" % self.__name, "/TrackList")
self._mp_t = dbus.Interface(proxy, "org.freedesktop.MediaPlayer")
except DBusException as e:
raise StandardError("dbus error: %s" % e)
try:
self.__dbus_signal_handler = (
self._mp_p.connect_to_signal("TrackChange", self._notify_track),
self._mp_p.connect_to_signal("StatusChange", self._notify_status),
self._mp_p.connect_to_signal("CapsChange", self._notify_caps),
self._mp_t.connect_to_signal("TrackListChange", self._notify_tracklist_change),
)
except DBusException as e:
raise StandardError("dbus error: %s" % e)
try:
self._mp_p.GetStatus(reply_handler=self._notify_status, error_handler=self._dbus_error)
self._mp_p.GetMetadata(reply_handler=self._notify_track, error_handler=self._dbus_error)
self._mp_p.GetCaps(reply_handler=self._notify_caps, error_handler=self._dbus_error)
except DBusException as e:
# this is not necessarily a fatal error
log.warning("dbus error: %s" % e)
开发者ID:gkfabs,项目名称:remuco,代码行数:32,代码来源:mpris.py
示例14: down
def down(self):
if self._sock is not None:
try:
bluetooth.stop_advertising(self._sock)
except bluetooth.BluetoothError, e:
log.warning("failed to unregister bluetooth service (%s)" % e)
开发者ID:igoralmeida,项目名称:remuco,代码行数:7,代码来源:net.py
示例15: build_message
def build_message(id, serializable):
"""Create a message ready to send on a socket.
@param id:
message id
@param serializable:
message content (object of type Serializable)
@return:
the message as a binary string or None if serialization failed
"""
# This is not included in ClientConnection.send() because if there are
# multiple clients, each client would serialize the data to send again.
# Using this method, a message can be serialized once and send to many
# clients.
if serializable is not None:
ba = serial.pack(serializable)
if ba is None:
log.warning("failed to serialize (msg-id %d)" % id)
return None
else:
ba = ""
header = struct.pack("!hi", id, len(ba))
return "%s%s" % (header, ba)
开发者ID:igoralmeida,项目名称:remuco,代码行数:29,代码来源:net.py
示例16: _poll_volume
def _poll_volume(self):
try:
self._mp_p.VolumeGet(reply_handler=self._notify_volume,
error_handler=self._dbus_error)
except DBusException, e:
log.warning("dbus error: %s" % e)
开发者ID:Sixthhokage2,项目名称:remuco,代码行数:7,代码来源:mpris.py
示例17: __save
def __save(self):
try:
self.__cp.write(open(self.__file_config, 'w'))
except IOError, e:
log.warning("failed to save config to %s (%s)" %
(self.__file_config, e))
开发者ID:cpatulea,项目名称:remuco,代码行数:7,代码来源:config.py
示例18: ctrl_toggle_shuffle
def ctrl_toggle_shuffle(self):
try:
self._mp_t.SetRandom(not self._shuffle,
reply_handler=self._dbus_ignore,
error_handler=self._dbus_error)
except DBusException, e:
log.warning("dbus error: %s" % e)
开发者ID:Sixthhokage2,项目名称:remuco,代码行数:8,代码来源:mpris.py
示例19: ctrl_toggle_repeat
def ctrl_toggle_repeat(self):
try:
self._mp_t.SetLoop(not self._repeat,
reply_handler=self._dbus_ignore,
error_handler=self._dbus_error)
except DBusException, e:
log.warning("dbus error: %s" % e)
开发者ID:Sixthhokage2,项目名称:remuco,代码行数:8,代码来源:mpris.py
示例20: __get_tracklist
def __get_tracklist(self):
"""Get a list of track dicts of all tracks in the tracklist."""
try:
length = self._mp_t.GetLength()
except DBusException, e:
log.warning("dbus error: %s" % e)
length = 0
开发者ID:Sixthhokage2,项目名称:remuco,代码行数:8,代码来源:mpris.py
注:本文中的remuco.log.warning函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论