Exemplo n.º 1
0
 def _run_server(self, host, port):
     app.frame_data = self._frame_data
     httpd = make_server(host, port, app, ws_handler_class=WebConsoleSocket)
     logger.info('Web-PDB: starting web-server on {0}:{1}...'.format(
             httpd.server_name, port)
     )
     dialog = DialogProgressBG()
     started = False
     while not (self._stop_all.is_set() or kodi_monitor.abortRequested()):
         try:
             httpd.handle_request()
         except SystemExit:
             break
         if not started:
             logger.info('Web-PDB: web-server started.')
             dialog.create(
                 addon.getLocalizedString(32001),
                 addon.getLocalizedString(32002).format(
                     httpd.server_name, port
                 )
             )
             dialog.update(100)
             started = True
     httpd.handle_close()
     logger.info('Web-PDB: web-server stopped.')
     dialog.close()
Exemplo n.º 2
0
    def __run(self):
        """
        Do the work
        """
        log.debug('Show sync info thread started')
        # cache local variables because it's faster
        total = self.total
        dialog = DialogProgressBG('dialoglogProgressBG')
        thread_stopped = self.thread_stopped
        dialog.create("%s %s: %s %s" %
                      (lang(39714), self.item_type, str(total), lang(39715)))
        player = Player()

        total = 2 * total
        totalProgress = 0
        while thread_stopped() is False and not player.isPlaying():
            with LOCK:
                get_progress = GET_METADATA_COUNT
                process_progress = PROCESS_METADATA_COUNT
                viewName = PROCESSING_VIEW_NAME
            totalProgress = get_progress + process_progress
            try:
                percentage = int(float(totalProgress) / float(total) * 100.0)
            except ZeroDivisionError:
                percentage = 0
            dialog.update(percentage,
                          message="%s %s. %s %s: %s" %
                          (get_progress, lang(39712), process_progress,
                           lang(39713), viewName))
            # Sleep for x milliseconds
            sleep(200)
        dialog.close()
        log.debug('Show sync info thread terminated')
Exemplo n.º 3
0
    def run(self):
        """
        Do the work
        """
        LOG.debug('Show sync info thread started')
        # cache local variables because it's faster
        total = self.total
        dialog = DialogProgressBG('dialoglogProgressBG')
        dialog.create("%s %s: %s %s" % (utils.lang(39714), self.item_type,
                                        unicode(total), utils.lang(39715)))

        total = 2 * total
        total_progress = 0
        while not self.stopped():
            with LOCK:
                get_progress = GET_METADATA_COUNT
                process_progress = PROCESS_METADATA_COUNT
                view_name = PROCESSING_VIEW_NAME
            total_progress = get_progress + process_progress
            try:
                percentage = int(float(total_progress) / float(total) * 100.0)
            except ZeroDivisionError:
                percentage = 0
            dialog.update(percentage,
                          message="%s %s. %s %s: %s" %
                          (get_progress, utils.lang(39712), process_progress,
                           utils.lang(39713), view_name))
            # Sleep for x milliseconds
            sleep(200)
        dialog.close()
        LOG.debug('Show sync info thread terminated')
Exemplo n.º 4
0
def update_tvdb():
    progress_bar = DialogProgressBG()
    progress_bar.create(heading="Downloading database...")
    msg = "Базата данни НЕ бе обновена!"
    try:
        log('Force-updating tvdb')
        # recreated the db_file in case db_file is overwritten by use_local_db
        __db_file__ = os.path.join(get_resources_dir(), 'tv.db')
        asset = Assets(__db_file__, backup_db_file)
        progress_bar.update(1, "Downloading database...")

        errors = asset.update(settings.url_db)
        if errors:
            notify_error(msg + "\n" + errors)

        if settings.use_local_db:
            notify_success("Използвате локална база данни!")

    except Exception as ex:
        log(ex, 4)

    if progress_bar:
        progress_bar.close()
Exemplo n.º 5
0
class ProviderListenerDialog(ProviderListener):
    def __init__(self, providers, method, timeout=10):
        super(ProviderListenerDialog, self).__init__(providers,
                                                     method,
                                                     timeout=timeout)
        self._total = len(providers)
        self._count = 0
        self._dialog = DialogProgressBG()

    def on_receive(self, sender):
        self._count += 1
        self._dialog.update(int(100 * self._count / self._total))

    def __enter__(self):
        ret = super(ProviderListenerDialog, self).__enter__()
        self._dialog.create(ADDON_NAME, translate(30111))
        return ret

    def __exit__(self, exc_type, exc_val, exc_tb):
        try:
            return super(ProviderListenerDialog,
                         self).__exit__(exc_type, exc_val, exc_tb)
        finally:
            self._dialog.close()
Exemplo n.º 6
0
                    old_file = os.path.join(old_folder, file)
                    new_file = os.path.join(new_folder, file)
                    if self.MIGRATETYPE == 'move':
                        xbmcvfs.copy( old_file, new_file  )
                        xbmcvfs.delete( old_file )
                    elif self.MIGRATETYPE == 'copy':                
                        xbmcvfs.copy( old_file, new_file )
                    else:
                        test_str = test_str + old_file + ' to ' + new_file + '\n'
                if self.MIGRATETYPE == 'move':
                    xbmcvfs.rmdir ( old_folder )
                count += 1
        if self.MIGRATETYPE == 'test':
            success, loglines = writeFile( test_str, os.path.join( self.MIGRATEFOLDER, '_migrationtest.txt' ) )
            lw.log( loglines )
        pDialog.close()


    def _remove_trailing_dot( self, thename ):
        if thename[-1] == '.' and len( thename ) > 1 and self.ENDREPLACE <> '.':
            return self._remove_trailing_dot( thename[:-1] + self.ENDREPLACE )
        else:
            return thename


if ( __name__ == "__main__" ):
    lw.log( ['script version %s started' % addonversion], xbmc.LOGNOTICE )
    lw.log( ['debug logging set to %s' % logdebug], xbmc.LOGNOTICE )
    Main()
    command = 'XBMC.Notification(%s, %s, %s, %s)' % (smartUTF8(language(30330)), smartUTF8(language(30331)), 3000, smartUTF8(addonicon))
    xbmc.executebuiltin( command )
Exemplo n.º 7
0
class RemotePdb(Pdb):
    """
    This will run pdb as a ephemeral telnet service. Once you connect no one
    else can connect. On construction this object will block execution till a
    client has connected.

    Based on https://github.com/tamentis/rpdb I think ...

    To use this::

        RemotePdb(host='0.0.0.0', port=4444).set_trace()

    Then run: telnet 127.0.0.1 4444
    """
    active_instance = None
    has_quit = False

    def __init__(self, host, port, patch_stdstreams=False):
        cry('listen socket')
        self._listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self._listen_socket.settimeout(None)
        cry('setsokcport')
        self._listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
        cry('bind')
        self._listen_socket.bind((host, port))
        self._stop_monitor = threading.Event()
        self._monitor_thread = threading.Thread(target=self._monitor_abort)
        self._monitor_thread.daemon = True
        self._monitor_thread.start()
        if not host:
            host = socket.gethostname()
        port = self._listen_socket.getsockname()[1]
        cry("RemotePdb session open at %s:%s, waiting for connection ..." % (host, port))
        self._dialog = DialogProgressBG()
        self._dialog.create('remote-pdb',
                            'Waiting for connection at [COLOR=yellow]%s:%s[/COLOR]' % (host, port)
                            )
        self._listen_socket.listen(1)
        self._connection, address = self._listen_socket.accept()
        self._connection.settimeout(None)
        self._dialog.update(100, heading='remote-pdb', message='Connection from %s active' % address[0])
        cry("RemotePdb accepted connection from %s." % repr(address))
        if PY3:
            self.handle = LF2CRLF_FileWrapper(self._connection.makefile('rw'))
        else:
            self.handle = LF2CRLF_FileWrapper(self._connection.makefile())
        Pdb.__init__(self, completekey='tab', stdin=self.handle, stdout=self.handle)
        self.backup = []
        if patch_stdstreams:
            for name in (
                    'stderr',
                    'stdout',
                    '__stderr__',
                    '__stdout__',
                    'stdin',
                    '__stdin__',
            ):
                self.backup.append((name, getattr(sys, name)))
                setattr(sys, name, self.handle)
        RemotePdb.active_instance = self

    def _monitor_abort(self):
        while not (xbmc.abortRequested or self._stop_monitor.is_set()):
            time.sleep(0.1)
        if not self._stop_monitor.is_set():
            self.do_quit(None)

    def __restore(self):
        if self.backup:
            cry('Restoring streams: %s ...' % self.backup)
        for name, fh in self.backup:
            setattr(sys, name, fh)
        self.handle.close()
        RemotePdb.active_instance = None

    def do_quit(self, arg):
        self._dialog.close()
        self._stop_monitor.set()
        try:
            self._connection.shutdown(socket.SHUT_WR)
            self._connection.close()
        except AttributeError:
            pass
        self._listen_socket.close()
        try:
            self.__restore()
        except AttributeError:
            pass
        self.set_quit()
        RemotePdb.has_quit = True
        return 1

    do_q = do_exit = do_quit

    def set_trace(self, frame=None):
        if frame is None:
            frame = sys._getframe().f_back
        try:
            Pdb.set_trace(self, frame)
        except IOError as exc:
            if exc.errno != errno.ECONNRESET:
                raise

    def set_quit(self):
        sys.settrace(None)