Ejemplo n.º 1
0
    def __init__(self):

        self.feeds = []
        self.services = []
        self.webui = None
        self.client = None
        self.init_db()
        self._updater = gevent.Greenlet(self.update_providers)
        self._updater.start_later(1)
        self.watch = None
        self.init_providers()
        app.torrent_client = client.init_client()
        if config.getboolean("webui", "enabled"):
            self.init_webui()
Ejemplo n.º 2
0
    def __init__(self):
        self.feeds = []
        self.services = []
        self.webui = None
        self.client = None
        self.init_db()
        self._updater = gevent.Greenlet(self.update_providers)
        self._updater.start_later(1)
        self.watch = None
        self.init_providers()
        self.client = client.init_client()
        app.torrent_client = self.client

        self.wsgi_app = None
        self.wsgi_socketio = None
        self.wsgi_server = None
        if config.getboolean("webui", "enabled"):
            self.init_webui()
            self.wsgi_server.start()
Ejemplo n.º 3
0
def add_torrents_from_cli(args):
    """ Parse command line args and try to load torrent files found

    :param args:
    :type args:
    :return:
    :rtype:
    """
    try:
        if len(args) <= 1:
            raise ConfigError("! Not enough arguments")

        torrent_data = []
        for torrent in args[1:]:
            try:
                torrent_data.append(open(torrent, 'r').read())
            except IOError as err:
                pass
        if len(torrent_data) != len(args[1:]):
            raise ConfigError("! Failed to locate any files")
    except (ConfigError, Exception) as err:
        print(err)
        return 1
    else:
        if torrent_data:
            client = init_client()
            print("> Connected to {}".format(client))
            for raw_torrent in torrent_data:
                torrent_struct = Torrent.from_str(raw_torrent)
                print("-> {} @ {}".format(
                    torrent_struct['info']['name'].decode('utf8'),
                    torrent_struct.size(human=True)))
                if client.add(raw_torrent):
                    print("--> Upload successful")
                    return 0
                else:
                    print("--> Upload failed")
                    return 1
Ejemplo n.º 4
0
def add_torrents_from_cli(args):
    """ Parse command line args and try to load torrent files found

    :param args:
    :type args:
    :return:
    :rtype:
    """
    try:
        if len(args) <= 1:
            raise ConfigError("! Not enough arguments")

        torrent_data = []
        for torrent in args[1:]:
            try:
                torrent_data.append(open(torrent, 'r').read())
            except IOError as err:
                pass
        if len(torrent_data) != len(args[1:]):
            raise ConfigError("! Failed to locate any files")
    except (ConfigError, Exception) as err:
        print(err)
        return 1
    else:
        if torrent_data:
            client = init_client()
            print("> Connected to {}".format(client))
            for raw_torrent in torrent_data:
                torrent_struct = Torrent.from_str(raw_torrent)
                print("-> {} @ {}".format(torrent_struct['info']['name'].decode('utf8'), torrent_struct.size(human=True)))
                if client.add(raw_torrent):
                    print("--> Upload successful")
                    return 0
                else:
                    print("--> Upload failed")
                    return 1