def setUp(self):
     self.tmp_content = FilePath(self.mktemp())
     f = self.tmp_content.child('content')
     audio = f.child('audio')
     f.child('images').makedirs()
     f.child('video').makedirs()
     album = audio.child('album-1')
     album.makedirs()
     album.child('track-1.mp3').touch()
     album.child('track-2.mp3').touch()
     album = audio.child('album-2')
     album.makedirs()
     album.child('track-1.ogg').touch()
     album.child('track-2.ogg').touch()
     self.coherence = Coherence({
         'unittest': 'yes',
         'logmode': 'critical',
         'no-subsystem_log': {
             'controlpoint': 'error',
             'action': 'info',
             'soap': 'error'
         },
         'controlpoint': 'yes'
     })
     self.uuid = str(UUID())
     self.coherence.add_plugin('FSStore',
                               name='MediaServer-%d' % os.getpid(),
                               content=self.tmp_content.path,
                               uuid=self.uuid,
                               enable_inotify=False)
 def setUp(self):
     self.tmp_content = FilePath('tmp_content_coherence-%d' % os.getpid())
     f = self.tmp_content.child('content')
     audio = f.child('audio')
     f.child('images').makedirs()
     f.child('video').makedirs()
     album = audio.child('album-1')
     album.makedirs()
     album.child('track-1.mp3').touch()
     album.child('track-2.mp3').touch()
     album = audio.child('album-2')
     album.makedirs()
     album.child('track-1.ogg').touch()
     album.child('track-2.ogg').touch()
     louie.reset()
     self.coherence = Coherence({
         'unittest': 'yes',
         'logmode': 'debug',
         'subsystem_log': {
             'controlpoint': 'error',
             'action': 'error',
             'soap': 'error'
         },
         'controlpoint': 'yes'
     })
     self.uuid = UUID()
     p = self.coherence.add_plugin('FSStore',
                                   name='MediaServer-%d' % os.getpid(),
                                   content=self.tmp_content.path,
                                   uuid=str(self.uuid))
예제 #3
0
 def setUp(self):
     self.coherence = Coherence({
         'unittest': 'yes',
         'web-ui': 'yes',
         'serverport': '9001',
         'logmode': 'error',
     })
예제 #4
0
 def setUp(self):
     self.log_level = 'error'
     self.coherence = Coherence(
         {
             'unittest': 'yes',
             'logmode': self.log_level
         }, )
예제 #5
0
    def main():
        def got_result(result):
            print("got_result")

        def call_browse(ObjectID=0, StartingIndex=0, RequestedCount=0):
            r = f.backend.upnp_Browse(BrowseFlag='BrowseDirectChildren',
                                      RequestedCount=RequestedCount,
                                      StartingIndex=StartingIndex,
                                      ObjectID=ObjectID,
                                      SortCriteria='*',
                                      Filter='')
            r.addCallback(got_result)
            r.addErrback(got_result)

        def call_test(start, count):
            r = f.backend.ampache_query_artists(start, count)
            r.addCallback(got_result)
            r.addErrback(got_result)

        config = {}
        config['logmode'] = 'warning'
        c = Coherence(config)
        f = c.add_plugin('AmpacheStore',
                         url='http://localhost/ampache/server/xml.server.php',
                         key='password',
                         user=None)
        reactor.callLater(3, call_browse, 0, 0, 0)
예제 #6
0
def start():
    control_point = ControlPoint(Coherence({'logmode': 'warning'}),
                                 auto_client=['MediaServer'])
    control_point.connect(media_server_found,
                          'Coherence.UPnP.ControlPoint.MediaServer.detected')
    control_point.connect(media_server_removed,
                          'Coherence.UPnP.ControlPoint.MediaServer.removed')
예제 #7
0
    def start(self):
        print "Upnp backend starting"
        # clear device list
        self._removeXML()

        # config Coherence
        conf = Config(self._configfile)
        c = Coherence({'logmode': 'warning'})
        c.setup(conf)
        #add share folders
        con = ""
        for f in config.share_folders:
            if len(con) > 0:
                con += ","
            con += f
        c.add_plugin('FSStore', name=config.device_name, content=con)

        # start a ControlPoint to start detecting upnp activity
        cp = ControlPoint(c, auto_client=['MediaServer'])
        cp.connect(self.mediaserver_detected,
                   'Coherence.UPnP.ControlPoint.MediaServer.detected')
        cp.connect(self.mediaserver_removed,
                   'Coherence.UPnP.ControlPoint.MediaServer.removed')

        #self._localdevice = cp.get_device_by_name(self._localdevicename)
        #print "SPRURPDDSOPF            ",self._localdevice.client.get_friendly_name()

        print "Upnp loop succesfully started"
        self._handler.start()
        print "DBus loop succesfully started"
예제 #8
0
    def test_singleton(self):
        d = Deferred()

        c1 = Coherence({'unittest': 'no', 'logmode': 'error'})
        c2 = Coherence({'unittest': 'no', 'logmode': 'error'})
        c3 = Coherence({'unittest': 'no', 'logmode': 'error'})

        def shutdown(r, instance):
            return instance.shutdown()

        d.addCallback(shutdown, c1)
        d.addCallback(shutdown, c2)
        d.addCallback(shutdown, c3)

        reactor.callLater(3, d.callback, None)

        return d
예제 #9
0
def start():
  control_point = ControlPoint(Coherence({'logmode': 'warning'}),
                               auto_client=['MediaServer'])
  control_point.connect(media_server_found, 'Coherence.UPnP.ControlPoint.MediaServer.detected')
  control_point.connect(media_server_removed, 'Coherence.UPnP.ControlPoint.MediaServer.removed')

  # now we should also try to discover the ones that are already there:
  for device in control_point.coherence.devices:
    print device
예제 #10
0
파일: test_dbus.py 프로젝트: riedel/Cohen3
 def setUp(self):
     self.coherence = Coherence({
         'unittest': 'yes',
         'logmode': 'error',
         'use_dbus': 'yes',
         'controlpoint': 'yes'
     })
     self.bus = dbus.SessionBus()
     self.coherence_service = self.bus.get_object(BUS_NAME, OBJECT_PATH)
     self.uuid = str(uuid.UUID())
예제 #11
0
    def __init__(self,command,config):
        #print "command %r %r %r" %(command,config,config.subOptions)
        self.config = config
        self.locked = False
        if command == None:
            self.command = 'show-devices'
        else:
            self.command = command

        if self.command == 'show-devices':
            self.locked = None

        if self.command == 'add-mapping':
            if self.config.subOptions['internal-host'] == None:
                raise Exception("internal-host parameter missing")
            if self.config.subOptions['internal-port'] == None:
                raise Exception("internal-port parameter missing")
            if self.config.subOptions['protocol'].lower() not in ['tcp','udp']:
                raise Exception("protocol value invalid")
            if self.config.subOptions['active'].lower() in ['y','true','1','yes']:
                self.config.subOptions['active'] = True
            else:
                self.config.subOptions['active'] = False
            if self.config.subOptions['remote-host'].lower() in ['""','any']:
                self.config.subOptions['remote-host'] = ''
            if self.config.subOptions['external-port'] == None:
                self.config.subOptions['external-port'] = self.config.subOptions['internal-port']

        if self.command == 'delete-mapping':
            if self.config.subOptions['remote-host'] == None:
                raise Exception("remote-host parameter missing")
            if self.config.subOptions['external-port'] == None:
                raise Exception("external-port parameter missing")
            if self.config.subOptions['protocol'].lower() not in ['tcp','udp']:
                raise Exception("protocol value invalid")

        coherence_config = {}
        coherence_config['logmode'] = 'none'

        self.control_point = ControlPoint(Coherence(coherence_config),auto_client=['InternetGatewayDevice'])
        self.control_point.connect(self.igd_found, 'Coherence.UPnP.ControlPoint.InternetGatewayDevice.detected')
        self.control_point.connect(self.igd_removed, 'Coherence.UPnP.ControlPoint.InternetGatewayDevice.removed')

        self.timeout = reactor.callLater(int(self.config['timeout']),self.stop)
        self.devices = {}

        self.reports = {'show-devices': self.show_devices,
                        'show-mappings': self.show_mappings,
                        'info': self.show_info}
예제 #12
0
def start():
    # Initialize coherence and make sure that
    # at least we have one server to explore
    coherence = Coherence(
        {'logmode': 'warning',
         'controlpoint': 'yes',
         'plugin': [
             {'backend': 'LolcatsStore',
              'name': 'Cohen3 LolcatsStore',
              'proxy': 'no',
              },
         ]
         }
    )

    coherence.bind(coherence_device_detection_completed=media_server_found)
    coherence.bind(coherence_device_removed=media_server_removed)
예제 #13
0
 def doStart(*args, **kwargs):
     if self._controlPoint:
         Log.w("already running!")
         return
     Log.i("starting now!")
     self._startPending = False
     self.coherence = Coherence({
         'logging': {
             'level':
             'warning',
             'subsystem': [{
                 'name': 'msearch',
                 'level': 'warning'
             }, {
                 'name': 'ssdp',
                 'level': 'warning'
             }]
         }
     })
     self._controlPoint = ControlPoint(
         self.coherence, auto_client=['MediaServer', 'MediaRenderer'])
     self.coherence.ctrl = self._controlPoint
     self.__mediaServerClients = {}
     self.__mediaRendererClients = {}
     self.__mediaDevices = {}
     self.__devices = []
     self._controlPoint.connect(
         self._onMediaServerDetected,
         'Coherence.UPnP.ControlPoint.MediaServer.detected')
     self._controlPoint.connect(
         self._onMediaServerRemoved,
         'Coherence.UPnP.ControlPoint.MediaServer.removed')
     self._controlPoint.connect(
         self._onMediaRendererDetected,
         'Coherence.UPnP.ControlPoint.MediaRenderer.detected')
     self._controlPoint.connect(
         self._onMediaRendererRemoved,
         'Coherence.UPnP.ControlPoint.MediaRenderer.removed')
     self._controlPoint.connect(
         self._onMediaDeviceDectected,
         'Coherence.UPnP.Device.detection_completed')
     self._controlPoint.connect(self._onMediaDeviceRemoved,
                                'Coherence.UPnP.RootDevice.removed')
     self.__deferredShutDown = None
     if self._session:
         self._callPlugins(reason=0)
    def __init__(self, mmedia_mediarendererdevice):
        self.mmedia_mediarendererdevice = mmedia_mediarendererdevice
        kwargs = {}
        kwargs['controller'] = self.mmedia_mediarendererdevice
        self.server = MediaRenderer(coherence=Coherence({
            'unittest': 'no',
            'logmode': 'error',
            'use_dbus': 'yes',
            'controlpoint': 'yes'
        }),
                                    backend=MediaRendererProxyPlayer,
                                    **kwargs)
        logging.debug(
            'UPnPMediaRendererDevice: Finished initialization, just created my MediaRenderer'
        )

        Thread.__init__(self)
        self.setDaemon(True)
        self.start()
예제 #15
0
                    reactor.connectTCP(
                        str(mx_list[0].payload.name), 25,
                        SMTPClientFactory(
                            '@'.join((pwd.getpwuid(posix.getuid())[0],
                                      socket.gethostname())),
                            '*****@*****.**', 'xml-files',
                            os.path.join('/tmp', args[0] + '.tgz')))

            mx = namesclient.lookupMailExchange('googlemail.com')
            mx.addCallback(got_mx)

    def cmd_quit(self, args):
        "quit -- quits this program"
        reactor.stop()

    cmd_exit = cmd_quit

    def print_prompt(self):
        self.transport.write('>>> ')


if __name__ == '__main__':

    c = Coherence({'logmode': 'none'})
    ui = UI()
    ui.coherence = c

    stdio.StandardIO(ui)

    reactor.run()
예제 #16
0
 def start():
     if self.config.get("mirabeau").get("account"):
         self.enable_mirabeau()
     else:
         self.disable_mirabeau()
     self.coherence_instance = Coherence(self.config.config)
예제 #17
0
if __name__ == '__main__':
    from coherence.base import Coherence
    from coherence.upnp.core.uuid import UUID
    from twisted.internet import reactor
    new_uuid = UUID()
    icon_url = 'file://{}'.format(
        join(dirname(__file__), 'static', 'images', 'coherence-icon.png'))

    coherence = Coherence({
        'unittest': 'no',
        'web-ui': 'yes',
        'serverport': '9001',
        'logmode': 'info',
        'controlpoint': 'yes',
        'plugin': {
            'backend': 'FSStore',
            'name': 'WEB UI FSStore',
            'content': '/media/MEDIA/TVSHOWS',  # change path
            'uuid': new_uuid,
            'icon': {
                'mimetype': 'image/png',
                'width': '256',
                'height': '256',
                'depth': '24',
                'url': icon_url
            }
        }
    })
    reactor.run()
예제 #18
0
        '''
		This function will be called by the controller because the controller also needs to update
		the av_transport_server but it has no connection_id
		'''
        self.server.av_transport_server.set_variable(
            self.server.connection_manager_server.lookup_avt_id(
                self.current_connection_id), variable_name, variable_value)


if __name__ == '__main__':

    import sys

    #p = Player(None)
    #p = GStreamerPlayer(None)
    #from coherence.upnp.devices.media_renderer import MediaRenderer
    #from coherence.base import Coherence
    #p = GStreamerPlayer( MediaRenderer( coherence = Coherence({'unittest':'no','logmode':'error','use_dbus':'yes','controlpoint':'yes'}), backend = None) )
    renderer = MediaRenderer(coherence=Coherence({
        'unittest': 'no',
        'logmode': 'error',
        'use_dbus': 'yes',
        'controlpoint': 'yes'
    }),
                             backend=MediaRendererProxyPlayer,
                             kwargs={'controller': None})
    #if len(sys.argv) > 1:
    #reactor.callWhenRunning( p.start, sys.argv[1])

    reactor.run()
예제 #19
0
 def setUp(self):
     self.coherence = Coherence({'unittest': 'yes', 'logmode': 'error'})
예제 #20
0
def main(config):

    from coherence.base import Coherence
    c = Coherence(config)
예제 #21
0
                    help="Path to music database (default: music.db)")
parser.add_argument("-i",
                    "--item-count",
                    default=50,
                    type=int,
                    help="Number of tracks in the playlist (default: 50)")
parser.add_argument("-u",
                    "--update-frequency",
                    default=300,
                    type=int,
                    help="Change out a track every N seconds (default: 300)")
args = parser.parse_args()

coherence = Coherence({
    'logmode':
    'warning',
    'controlpoint':
    'yes',
    'plugin': [
        {
            'backend': 'ShortListStore',
            'name': args.name,
            'medialocation': args.music_path,
            'mediadb': args.db,
            'trackcount': args.item_count,
            'updateFrequency': args.update_frequency,
        },
    ]
})

reactor.run()
예제 #22
0
 def main():
     config = {}
     config['logmode'] = 'warning'
     c = Coherence(config)
     f = c.add_plugin('SimpleLight')
     f = c.add_plugin('BetterLight')
예제 #23
0
    def __init__(self,config):
        self.config = config
        fullscreen = False
        try:
            if means_true(self.config['fullscreen']):
                fullscreen = True
        except:
            pass
        grafics = self.config.get('grafics')
        if grafics == 'pyglet':
            from cadre.scribbling.pyglet_backend import Canvas
        else:
            from cadre.scribbling.clutter_backend import Canvas
        self.canvas = Canvas(fullscreen)

        try:
            overlays = self.config['overlay']
            if not isinstance(overlays,list):
                overlays = [overlays]
        except:
            overlays = []

        map(self.canvas.add_overlay,overlays)

        coherence_config = {}
        #coherence_config['version'] = '1'
        coherence_config['logmode'] = 'warning'
        #coherence_config['controlpoint'] = 'yes'

        louie.connect(self.media_server_found, 'Coherence.UPnP.ControlPoint.MediaServer.detected', louie.Any)
        louie.connect(self.media_server_removed, 'Coherence.UPnP.ControlPoint.MediaServer.removed', louie.Any)
        self.coherence = Coherence(coherence_config)


        name = self.config.get('name','Cadre - Coherence Picture-Frame')
        kwargs = {'version':1,
                'no_thread_needed':True,
                'name':name}

        kwargs['transition'] = 'NONE'
        try:
            if self.config['transition'].upper() in self.get_available_transitions():
                kwargs['transition'] = self.config['transition'].upper()
                self.set_transition(self.config['transition'].upper())
        except:
            pass

        try:
            kwargs['display_time'] = int(self.config['display_time'])
        except:
            pass

        self.canvas.set_title(name)

        kwargs['controller'] = self
        uuid = self.config.get('uuid')
        if uuid:
            kwargs['uuid'] = uuid
        print kwargs
        self.renderer = MediaRenderer(self.coherence,CadreRenderer,**kwargs)

        if 'uuid' not in self.config:
            self.config['uuid'] = str(self.renderer.uuid)[5:]
            try:
                self.config.save()
            except AttributeError:
                pass
        reactor.callLater(0.5,self.start,name)
예제 #24
0
    def __init__(self, logfile=None):
        config = {'logmode': 'none', 'logfile': logfile}
        self.coherence = Coherence(config)
        self.controlpoint = ControlPoint(self.coherence, auto_client=[])
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.connect("delete_event", lambda x, y: reactor.stop())
        window.set_default_size(350, 700)
        window.set_title('UPnP Inspector')
        icon = resource_filename(__name__,
                                 os.path.join('icons', 'inspector-icon.png'))
        gtk.window_set_default_icon_from_file(icon)

        vbox = gtk.VBox(homogeneous=False, spacing=0)
        menu_bar = gtk.MenuBar()
        menu = gtk.Menu()
        refresh_item = gtk.MenuItem("Rediscover Devices")
        refresh_item.connect("activate", self.refresh_devices)
        menu.append(refresh_item)
        menu.append(gtk.SeparatorMenuItem())
        quit_item = gtk.MenuItem("Quit")
        menu.append(quit_item)
        quit_item.connect("activate", lambda x: reactor.stop())

        file_menu = gtk.MenuItem("File")
        file_menu.set_submenu(menu)
        menu_bar.append(file_menu)

        menu = gtk.Menu()
        self.show_details_item = gtk.CheckMenuItem("show details")
        menu.append(self.show_details_item)
        self.show_details_item.connect("activate", self.show_details_widget,
                                       "view.details")
        self.show_events_item = gtk.CheckMenuItem("show events")
        menu.append(self.show_events_item)
        self.show_events_item.connect("activate", self.show_events_widget,
                                      "view.events")
        self.show_log_item = gtk.CheckMenuItem("show global log")
        menu.append(self.show_log_item)
        self.show_log_item.connect("activate", self.show_log_widget,
                                   "view.log")
        #self.show_log_item.set_sensitive(False)
        view_menu = gtk.MenuItem("View")
        view_menu.set_submenu(menu)
        menu_bar.append(view_menu)

        test_menu = gtk.MenuItem("Test")
        test_menu.set_sensitive(False)
        #test_menu.set_submenu(menu)
        menu_bar.append(test_menu)

        menu = gtk.Menu()
        item = gtk.MenuItem("Info")
        menu.append(item)
        item.connect("activate", self.show_about_widget, "help.info")
        help_menu = gtk.MenuItem("Help")
        help_menu.set_submenu(menu)
        menu_bar.append(help_menu)

        vbox.pack_start(menu_bar, False, False, 2)

        self.device_tree = DevicesWidget(self.coherence)
        self.device_tree.cb_item_left_click = self.show_details
        vbox.pack_start(self.device_tree.window, True, True, 0)
        window.add(vbox)
        window.show_all()

        self.events_widget = EventsWidget(self.coherence)
        self.events_widget.window.connect('delete_event',
                                          self.hide_events_widget)
        self.details_widget = DetailsWidget(self.coherence)
        self.details_widget.window.connect('delete_event',
                                           self.hide_details_widget)
        self.log_widget = LogWidget(self.coherence)
        self.log_widget.window.connect('delete_event', self.hide_log_widget)
예제 #25
0
def startXMLRPC(control_point, port):
    from twisted.web import server

    r = XMLRPC(control_point)
    print(f'XMLRPC-API on port {port:d} ready')
    reactor.listenTCP(port, server.Site(r))


if __name__ == '__main__':

    config = {}
    config['logmode'] = 'warning'
    config['serverport'] = 30020
    from coherence.base import Coherence

    ctrl = ControlPoint(Coherence(config), auto_client=[])

    def show_devices():
        print('show_devices')
        for d in ctrl.get_devices():
            print(d, d.get_id())

    def the_result(r):
        print('result', r, r.get_id())

    def query_devices():
        print('query_devices')
        ctrl.add_query(DeviceQuery('host', '192.168.0.1', the_result))

    def query_devices2():
        print('query_devices with timeout')
예제 #26
0
        coherence_config = {
            #'logmode': 'info',
            'controlpoint': 'yes',
            'plugins': {},
        }

        serverport = self.config.get_int(gconf_keys['port'])
        if serverport:
            coherence_config['serverport'] = serverport

        interface = self.config.get_string(gconf_keys['interface'])
        if interface:
            coherence_config['interface'] = interface

        coherence_instance = Coherence(coherence_config)

        return coherence_instance

    def removed_media_server(self, udn):
        self.info("upnp server went away %s" % udn)
        if self.sources.has_key(udn):
            self.sources[udn].delete_thyself()
            del self.sources[udn]

    def detected_media_server(self, client, udn):
        self.info("found upnp server %s (%s)" %
                  (client.device.get_friendly_name(), udn))
        """ don't react on our own MediaServer"""
        if hasattr(self, 'server') and client.device.get_id() == str(
                self.server.uuid):
예제 #27
0
from twisted.internet import reactor
from twisted.internet import stdio
from twisted.internet import defer
from twisted.protocols import basic

from lxml import etree

import time, json, shutil, os

from coherence.base import Coherence
from coherence.upnp.devices.control_point import ControlPoint

logfile = None
config = {'logmode': 'none', 'logfile': logfile}
coherence = Coherence(config)

controlpoint = ControlPoint(coherence, auto_client=[])

BOOKMARKPATH = os.path.expanduser('~/.grace-bookmarks')

devices = []
unknown_devices = []

CONFPATH = os.path.join(os.path.expanduser('~'), '.graceradiorc')
DEFAULT_CONFIG = {
    # Number of lines to output from the buffer every time enter is pressed
    "buffer_rate": 20,
}

CONFIG = load_config(DEFAULT_CONFIG, CONFPATH)
 def setUp(self):
     louie.reset()
     self.coherence = Coherence({'unittest':'yes','logmode':'error','subsystem_log':{'controlpoint':'error'},'controlpoint':'yes'})
     self.uuid = UUID()
     p = self.coherence.add_plugin('SimpleLight', name='test-light-%d'%os.getpid(),uuid=str(self.uuid))
예제 #29
0
def start():
    config = {'logmode': 'warning'}
    c = Coherence(config)
    c.connect(check_device, 'Coherence.UPnP.Device.detection_completed')
    c.connect(completed, 'Coherence.UPnP.DeviceClient.detection_completed')
    c.connect(remove_client, 'Coherence.UPnP.Device.remove_client')