Пример #1
0
def send_im(conversation, message):
     # First we have to get a "ConvIm" id from the conversation id we got in receive_msg.
     try: 
         conv_im = int(mydbus.send_dbus("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject", "im.pidgin.purple.PurpleInterface.PurpleConvIm", [conversation]).rstrip())
         # Then we use the ConvIm to identify the conversation and send it a message.
         return mydbus.send_dbus("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject", "im.pidgin.purple.PurpleInterface.PurpleConvImSend", [conv_im, message]).rstrip()
     except mydbus.WrappedCalledProcessError:
         logger.exception("Looks like pidgin isn't running")
Пример #2
0
 def cmd_play(self, args):
     logger.info("cmd_play %s", args)
     try:
         return mydbus.send_dbus('org.mpris.clementine', '/Player',
                                 'org.freedesktop.MediaPlayer.Play')
     except mydbus.WrappedCalledProcessError as e:
         logger.exception("Looks like clementine isn't running...")
Пример #3
0
def track_info(track_number):
    """
    e.g.
    qdbus org.mpris.clementine /TrackList org.freedesktop.MediaPlayer.GetMetadata 122 
    """
    info_string = mydbus.send_dbus('org.mpris.clementine', '/TrackList',
                                   'org.freedesktop.MediaPlayer.GetMetadata',
                                   [track_number])
    info_string.rstrip()
    field_delim = ': '
    d = {}
    for line in info_string.splitlines():
        fields = line.split(field_delim)
        field_name = fields[0]
        value = None
        if len(fields) == 2:
            value = fields[1]
        else:
            value = fields[0] + ''.join(field_delim + e
                                        for e in fields[1:len(fields)])
        d[field_name] = value
        d['track_number'] = str(track_number)
    if d == {}:
        return None
    return d
Пример #4
0
 def cmd_track(self, args):
     """
     e.g.
     qdbus org.mpris.clementine /TrackList org.freedesktop.MediaPlayer.PlayTrack 0 
     """
     cmd, track = args
     self._init_tracklist()
     if len(self.track_infos) == 0:
         logger.exception("Looks like clementine isn't running...")
         return
     track_number = None
     try:
         track_number = self.track_index[track[1]]
     except KeyError:
         logger.exception("No such track \"%s\"...", track[1])
         self.notify_server("No such track", track[1])
         return
     try:
         result = mydbus.send_dbus('org.mpris.clementine', '/TrackList',
                                   'org.freedesktop.MediaPlayer.PlayTrack',
                                   [track_number])
         if self.is_recording():
             self.put_cmd(args, **{})
         return result
     except mydbus.WrappedCalledProcessError as e:
         logger.exception("Looks like clementine isn't running...")
Пример #5
0
def pidgin_dbus(post_process, service, path, method, args=[], qdbus_args=[]):
     try: 
         result = mydbus.send_dbus(service, path, method, args, qdbus_args).rstrip()
         return post_process(result)
     except mydbus.WrappedCalledProcessError:
         logger.exception("Looks like pidgin isn't running")
         return None
Пример #6
0
 def cmd_volume(self, args):
     cmd, level = args
     try:
         result = mydbus.send_dbus('org.mpris.clementine', '/Player', 'org.freedesktop.MediaPlayer.VolumeSet', [level[1]])
         if self.is_recording():
             self.put_cmd(args, **{})
         return result
     except mydbus.WrappedCalledProcessError as e:
         logger.exception("Looks like clementine isn't running...")
Пример #7
0
 def cmd_volume(self, args):
     cmd, level = args
     try:
         result = mydbus.send_dbus('org.mpris.clementine', '/Player',
                                   'org.freedesktop.MediaPlayer.VolumeSet',
                                   [level[1]])
         if self.is_recording():
             self.put_cmd(args, **{})
         return result
     except mydbus.WrappedCalledProcessError as e:
         logger.exception("Looks like clementine isn't running...")
Пример #8
0
def track_info(track_number):
    """
    e.g.
    qdbus org.mpris.clementine /TrackList org.freedesktop.MediaPlayer.GetMetadata 122 
    """
    info_string = mydbus.send_dbus('org.mpris.clementine', '/TrackList', 'org.freedesktop.MediaPlayer.GetMetadata', [track_number])
    info_string.rstrip()
    field_delim = ': '
    d = {}
    for line in info_string.splitlines():
        fields = line.split(field_delim)
        field_name = fields[0]
        value = None
        if len(fields) == 2:
            value = fields[1]
        else:
            value = fields[0] + ''.join(field_delim + e for e in fields[1:len(fields)])
        d[field_name] = value
        d['track_number'] = str(track_number)
    if d == {}:
        return None
    return d
Пример #9
0
 def cmd_track(self, args):
     """
     e.g.
     qdbus org.mpris.clementine /TrackList org.freedesktop.MediaPlayer.PlayTrack 0 
     """
     cmd, track = args
     self._init_tracklist()
     if len(self.track_infos) == 0:
         logger.exception("Looks like clementine isn't running...")
         return
     track_number = None
     try:
         track_number = self.track_index[track[1]]
     except KeyError:
         logger.exception("No such track \"%s\"...", track[1])
         self.notify_server("No such track", track[1])
         return
     try:
         result = mydbus.send_dbus('org.mpris.clementine', '/TrackList', 'org.freedesktop.MediaPlayer.PlayTrack', [track_number])
         if self.is_recording():
             self.put_cmd(args, **{})
         return result
     except mydbus.WrappedCalledProcessError as e:
         logger.exception("Looks like clementine isn't running...")
Пример #10
0
 def cmd_next(self, args):
     try:
         return mydbus.send_dbus('org.mpris.clementine', '/Player', 'org.freedesktop.MediaPlayer.Next')
     except mydbus.WrappedCalledProcessError as e:
         logger.exception("Looks like clementine isn't running...")