예제 #1
0
    def start(self, loop):
        from calibre.utils.mdns import publish, unpublish, get_external_ip, verify_ipV4_address
        ip_address, port = loop.bound_address[:2]
        self.zeroconf_ip_address = zipa = verify_ipV4_address(
            ip_address) or get_external_ip()
        prefix = loop.opts.url_prefix or ''
        mdns_services = ((self.service_name, self.service_type, port, {
            'path': prefix + self.path
        }), )
        if self.shutdown.is_set():
            return
        self.services = []

        for s in mdns_services:
            self.services.append(
                publish(*s,
                        use_ip_address=zipa,
                        add_hostname=self.add_hostname))
        loop.log('OPDS feeds advertised via BonJour at: %s port: %s' %
                 (zipa, port))
        self.advertised_port = port
        self.started.set()

        self.shutdown.wait()
        for s in mdns_services:
            unpublish(*s,
                      add_hostname=self.add_hostname,
                      wait_for_stop=self.wait_for_stop)
        self.stopped.set()
예제 #2
0
    def start(self, loop):
        from calibre.utils.mdns import publish, unpublish, get_external_ip, verify_ipV4_address
        ip_address, port = loop.bound_address[:2]
        self.zeroconf_ip_address = zipa = verify_ipV4_address(ip_address) or get_external_ip()
        prefix = loop.opts.url_prefix or ''
        # The Zeroconf module requires everything to be bytestrings

        def enc(x):
            if not isinstance(x, bytes):
                x = x.encode('ascii')
            return x
        mdns_services = (
            (enc(self.service_name), enc(self.service_type), port, {b'path':enc(prefix + self.path)}),
        )
        if self.shutdown.is_set():
            return
        self.services = []

        for s in mdns_services:
            self.services.append(publish(*s, use_ip_address=zipa, add_hostname=self.add_hostname))
        loop.log('OPDS feeds advertised via BonJour at: %s port: %s' % (zipa, port))
        self.advertised_port = port
        self.started.set()

        self.shutdown.wait()
        for s in mdns_services:
            unpublish(*s, add_hostname=self.add_hostname)
        self.stopped.set()
예제 #3
0
파일: base.py 프로젝트: Pipeliner/calibre
 def start(self):
     zeroconf_ip_address = verify_ipV4_address(self.ip_address)
     try:
         for s in self.mdns_services:
             publish_zeroconf(*s, use_ip_address=zeroconf_ip_address)
     except:
         import traceback
         cherrypy.log.error('Failed to start BonJour:')
         cherrypy.log.error(traceback.format_exc())
예제 #4
0
파일: base.py 프로젝트: tokot/calibre
 def start(self):
     zeroconf_ip_address = verify_ipV4_address(self.ip_address)
     try:
         for s in self.mdns_services:
             publish_zeroconf(*s, use_ip_address=zeroconf_ip_address)
     except:
         import traceback
         cherrypy.log.error('Failed to start BonJour:')
         cherrypy.log.error(traceback.format_exc())
예제 #5
0
파일: device.py 프로젝트: mirror/calibre
    def server_state_changed(self, running):
        from calibre.utils.mdns import get_external_ip, verify_ipV4_address

        text = _("Start Content Server")
        if running:
            listen_on = verify_ipV4_address(tweaks["server_listen_on"]) or get_external_ip()
            try:
                cs_port = content_server_config().parse().port
                ip_text = _(" [%(ip)s, port %(port)d]") % dict(ip=listen_on, port=cs_port)
            except:
                ip_text = " [%s]" % listen_on
            text = _("Stop Content Server") + ip_text
        self.toggle_server_action.setText(text)
예제 #6
0
파일: device.py 프로젝트: yeyanchao/calibre
 def server_state_changed(self, running):
     from calibre.utils.mdns import get_external_ip, verify_ipV4_address
     text = _('Start Content Server')
     if running:
         listen_on = (verify_ipV4_address(tweaks['server_listen_on']) or
                 get_external_ip())
         try :
             cs_port = content_server_config().parse().port
             ip_text = _(' [%s, port %d]')%(listen_on, cs_port)
         except:
             ip_text = ' [%s]'%listen_on
         text = _('Stop Content Server') + ip_text
     self.toggle_server_action.setText(text)
예제 #7
0
파일: device.py 프로젝트: wynick27/calibre
 def server_state_changed(self, running):
     from calibre.utils.mdns import get_external_ip, verify_ipV4_address
     text = _('Start Content Server')
     if running:
         listen_on = (verify_ipV4_address(tweaks['server_listen_on'])
                      or get_external_ip())
         try:
             cs_port = content_server_config().parse().port
             ip_text = _(' [%(ip)s, port %(port)d]') % dict(ip=listen_on,
                                                            port=cs_port)
         except:
             ip_text = ' [%s]' % listen_on
         text = _('Stop Content Server') + ip_text
     self.toggle_server_action.setText(text)
예제 #8
0
 def server_state_changed(self, running):
     from calibre.utils.mdns import get_external_ip, verify_ipV4_address
     text = _('Start Content server')
     if running:
         from calibre.srv.opts import server_config
         opts = server_config()
         listen_on = verify_ipV4_address(opts.listen_on) or get_external_ip()
         try:
             ip_text = _(' [%(ip)s, port %(port)d]')%dict(
                 ip=listen_on, port=opts.port)
         except Exception:
             ip_text = ' [%s]'%listen_on
         text = _('Stop Content server') + ip_text
     self.toggle_server_action.setText(text)
예제 #9
0
파일: device.py 프로젝트: exedre/calibre
 def server_state_changed(self, running):
     from calibre.utils.mdns import get_external_ip, verify_ipV4_address
     text = _('Start Content server')
     if running:
         from calibre.srv.opts import server_config
         opts = server_config()
         listen_on = verify_ipV4_address(opts.listen_on) or get_external_ip()
         protocol = 'HTTPS' if opts.ssl_certfile and opts.ssl_keyfile else 'HTTP'
         try:
             ip_text = ' ' + _('[{ip}, port {port}, {protocol}]').format(
                     ip=listen_on, port=opts.port, protocol=protocol)
         except Exception:
             ip_text = ' [{} {}]'.format(listen_on, protocol)
         self.ip_text = ip_text
         self.server_state_changed_signal.emit(running, ip_text)
         text = _('Stop Content server') + ip_text
     else:
         self.ip_text = ''
     self.toggle_server_action.setText(text)
예제 #10
0
파일: bonjour.py 프로젝트: JimmXinu/calibre
    def start(self, loop):
        from calibre.utils.mdns import publish, unpublish, get_external_ip, verify_ipV4_address
        ip_address, port = loop.bound_address[:2]
        self.zeroconf_ip_address = zipa = verify_ipV4_address(ip_address) or get_external_ip()
        prefix = loop.opts.url_prefix or ''
        mdns_services = (
            (self.service_name, self.service_type, port, {'path':prefix + self.path}),
        )
        if self.shutdown.is_set():
            return
        self.services = []

        for s in mdns_services:
            self.services.append(publish(*s, use_ip_address=zipa, add_hostname=self.add_hostname))
        loop.log('OPDS feeds advertised via BonJour at: %s port: %s' % (zipa, port))
        self.advertised_port = port
        self.started.set()

        self.shutdown.wait()
        for s in mdns_services:
            unpublish(*s, add_hostname=self.add_hostname, wait_for_stop=self.wait_for_stop)
        self.stopped.set()