Exemplo n.º 1
0
    def connect(self, host, username, password):
        if self.conn is not None:
            return self.conn

        if not host:
            return False
        try:
            if username and password:
                self.conn = Client(host, user=username, password=password)
            else:
                self.conn = Client(host)
        except:
            logger.error('Could not connect to %h' % host)
            return False

        return self.conn
 def __init__(self, config, persistence):
     self.conn = Client(config.address,
                        port=config.port,
                        user=config.user,
                        password=config.password)
     self.secret = config.secret
     self.persistence = persistence
Exemplo n.º 3
0
def createClient(*args, **kwargs):
    test_name = None
    if 'test_name' in kwargs:
        test_name = kwargs['test_name']
        del kwargs['test_name']
    kwargs['http_handler'] = TestHTTPHandler(test_name)
    return Client(*args, **kwargs)
Exemplo n.º 4
0
	def __init__(self, session):
		Screen.__init__(self, session)
		HelpableScreen.__init__(self)

		try:
			self.transmission = Client(
				address = config.plugins.emission.hostname.value,
				port = config.plugins.emission.port.value,
				user = config.plugins.emission.username.value,
				password = config.plugins.emission.password.value
			)
		except TransmissionError as te:
			self.transmission = None

		self["SetupActions"] = HelpableActionMap(self, "SetupActions",
		{
			"ok": (self.ok, _("show details")),
			"cancel": (self.close, _("close")),
		})

		self["ColorActions"] = HelpableActionMap(self, "ColorActions",
		{
			"green": (self.bandwidth, _("open bandwidth settings")),
			"yellow": (self.prevlist, _("show previous list")),
			"blue": (self.nextlist, _("show next list")),
		})

		self["MenuActions"] = HelpableActionMap(self, "MenuActions",
		{
			"menu": (self.menu, _("open context menu")),
		})

		self["key_red"] = StaticText(_("Close"))
		self["key_green"] = StaticText(_("Bandwidth"))
		self["key_yellow"] = StaticText("")
		self["key_blue"] = StaticText("")

		self["all_text"] = StaticText(_("All"))
		self["downloading_text"] = StaticText(_("DL"))
		self["seeding_text"] = StaticText(_("UL"))
		self["upspeed"] = StaticText("")
		self["downspeed"] = StaticText("")
		self["torrents"] = StaticText("")

		self["all_sel"] = Pixmap()
		self["downloading_sel"] = Pixmap()
		self["seeding_sel"] = Pixmap()

		self['list'] = List([])

		self.list_type = config.plugins.emission.last_tab.value
		self.sort_type = config.plugins.emission.last_sort.value
		self.showHideSetTextMagic()

		self.timer = eTimer()
		self.timer.callback.append(self.updateList)
		self.timer.start(0, 1)
Exemplo n.º 5
0
def reader():
    """Read data and dispatch"""
    client = Client(user=USERNAME, password=PASSWORD)
    stats = client.session_stats()

    dispatch_value('transmission_speed', [
        stats.cumulative_stats['downloadedBytes'],
        stats.cumulative_stats['uploadedBytes']
    ])

    dispatch_value('transmission_count',
                   [stats.activeTorrentCount, stats.pausedTorrentCount])
Exemplo n.º 6
0
 def connect(self):
     try:
         self.client = Client(address=self.host,
                              port=self.port,
                              user=self.user,
                              password=self.password)
     except TransmissionError as err:
         if err.original.code == 111:
             self.log.error(
                 "Failed to connect to transmission-daemon, is it running?")
         elif err.original.code == 113:
             self.log.error("No route to host")
         else:
             self.log.exception("Error connecting to transmission server")
         raise
Exemplo n.º 7
0
 def configureCallback(self):
     try:
         self.transmission = Client(
             address=config.plugins.emission.hostname.value,
             port=config.plugins.emission.port.value,
             user=config.plugins.emission.username.value,
             password=config.plugins.emission.password.value)
     except TransmissionError as te:
         self.transmission = None
         self.session.open(
             MessageBox,
             _("Error communicating with transmission-daemon: %s.") % (te),
             type=MessageBox.TYPE_ERROR,
             timeout=5)
     else:
         self.updateList()
Exemplo n.º 8
0
def simplerss_update_callback(id=None):
    try:
        from Plugins.Extensions.SimpleRSS.plugin import rssPoller
    except ImportError as e:
        pass  # should not happen since the poller has to be active for us to be called :-)
    else:
        errors = 0
        # we only check the "new items" feed currently since we do not keep track of the files we downloaded
        if id is None:
            client = None
            for item in rssPoller.newItemFeed.history:
                for file in item[3]:
                    if file.mimetype == "application/x-bittorrent":
                        if client is None:
                            client = Client(
                                address=config.plugins.emission.hostname.value,
                                port=config.plugins.emission.port.value,
                                user=config.plugins.emission.username.value,
                                password=config.plugins.emission.password.value
                            )
                        try:
                            # XXX: we might want to run this in the background cause this might block...
                            client.add_url(file.path)
                        except TransmissionError:
                            errors += 1

        # Inform the user if an error occured
        # XXX: we could also either open a notification per torrent (success/failure)
        #      or create a custom screen which gives this information in a
        #      more understandable and less annyoing way (e.g. a list of torrent
        #      names with an X or hook symbol next to it...)
        if errors > 0:
            from Tools.Notifications import AddPopup
            from Screens.MessageBox import MessageBox

            AddPopup(
                _("Failed to add %d torrents.") % (errors),
                MessageBox.TYPE_WARNING, 5, NOTIFICATIONID)
Exemplo n.º 9
0
def filescan_open(item, session, **kwargs):
    client = Client(address=config.plugins.emission.hostname.value,
                    port=config.plugins.emission.port.value,
                    user=config.plugins.emission.username.value,
                    password=config.plugins.emission.password.value)

    added = 0
    errors = 0

    # XXX: a list of failed/added torrents would be nice, see comment in simplerss_update_callback
    for each in item:
        try:
            if client.add_url(each):
                added += 1
        except TransmissionError:
            errors += 1

    from Screens.MessageBox import MessageBox

    session.open(MessageBox,
                 _("%d Torrents(s) were scheduled for download, %d failed.") %
                 (added, errors),
                 type=MessageBox.TYPE_INFO,
                 timeout=5)
 def __init__(self, user, password):
     #TODO: host/port/url
     self.client = Client(user=user, password=password)
     self.torrent_props = {}
     for t in self.client.get_torrents():
         self.sort_by_episodes(t)
Exemplo n.º 11
0
 def __init__(self, host, port, username, password):
     self.client = Client(host, port=port, user=username, password=password)
     self.torrent = os.path.join(
         os.path.expanduser('~'), 'Downloads',
         'E5340FB5C061E4E53618F41B48D7E1CEA445BB02.torrent')
     print(self.torrent)
    trk_remote = []
    config['local_lists'].append(cache_file)

trk_local = readLocalLists()
if trk_local:
    dbg('Local lists loaded: {} trackers'.format(len(trk_local)))

trackers = set(trk_remote + trk_local)
dbg('Total trackers: {}'.format(len(trackers)))

if not trackers:
    lg("No trackers loaded, nothing to do")
    exit(1)

try:
    tc = Client(**client)
except:
    if not config['err_on_connect']:
        exit()

    print("Unable to connect to Transmission: ", sys.exc_info()[0])
    raise

torrents = tc.get_torrents()

dbg('{} torrents total'.format(len(torrents)))

for t in torrents:
    if config['status_filter'] and not t.status in config['status_filter']:
        dbg('{}: skipping due to status filter'.format(t.name))
        continue
Exemplo n.º 13
0
def connect(settings):
    return Client(**to_rpcclient_settings(settings))
Exemplo n.º 14
0
#!/usr/bin/env python3

from transmissionrpc import Client

if __name__ == "__main__":
    client = Client('localhost', port=9091)
    torrents = client.get_torrents()
    for torrent in torrents:
        if "S02E05" in torrent.name:
            client.remove_torrent(torrent.id)
Exemplo n.º 15
0
 def __init__(self):
     print(f"user={TS_USER}, password={PASSWORD}")
     self.conn = Client(ADDRESS, PORT, user=TS_USER, password=PASSWORD)
     self.persistence = PERSISTENCE_FILE