當前位置: 首頁>>代碼示例>>Python>>正文


Python transmissionrpc.Client方法代碼示例

本文整理匯總了Python中transmissionrpc.Client方法的典型用法代碼示例。如果您正苦於以下問題:Python transmissionrpc.Client方法的具體用法?Python transmissionrpc.Client怎麽用?Python transmissionrpc.Client使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在transmissionrpc的用法示例。


在下文中一共展示了transmissionrpc.Client方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: start

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def start(self):
        try:
            self.torrent_client = transmissionrpc.Client(
                self.config.get('transmission', 'rpc_host'),
                port=self.config.get('transmission', 'rpc_port'),
                user=self.config['transmission']['rpc_user'],
                password=self.config['transmission']['rpc_password'])
        except transmissionrpc.error.TransmissionError:
            print("ERROR: Couldn't connect to Transmission. Check rpc configuration.")
            sys.exit()

        try:
            self.bot = telepot.Bot(self.config.get('telegram', 'bot_token'))
            self.bot.setWebhook('') # Remove existent webhook
            self.bot.message_loop(
                self.handle_mesasge,
                relax=self.config.getint('telegram', 'polling_interval'))
        except telepot.exception.TelegramError:
            print("ERROR: Couldn't start Telegram bot. Check telegram bot configuration.")
            sys.exit() 
開發者ID:gbrlmza,項目名稱:transmission-telegram-remote,代碼行數:22,代碼來源:transmission-telegram-remote.py

示例2: remove_torrent

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def remove_torrent(client, torrent, reason="None", dry_run=False):
    """ Remove a torrent from the client stopping it first if its in a started state.

    :param client: Transmission RPC Client
    :type client: transmissionrpc.Client
    :param torrent: Torrent instance to remove
    :type torrent: transmissionrpc.Torrent
    :param reason: Reason for removal
    :type reason: str
    :param dry_run: Do a dry run without actually running any commands
    :type dry_run: bool
    :return:
    """
    if torrent.status != "stopped":
        if not dry_run:
            client.stop_torrent(torrent.hashString)
    if not dry_run:
        client.remove_torrent(torrent.hashString, delete_data=False)
    logger.info("Removed: {} {}\nReason: {}".format(torrent.name, torrent.hashString, reason)) 
開發者ID:leighmacdonald,項目名稱:transmission_scripts,代碼行數:21,代碼來源:__init__.py

示例3: clean_min_time_ratio

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def clean_min_time_ratio(client):
    """ Remove torrents that are either have seeded enough time-wise or ratio-wise.
    The correct rule set is determined by checking the torrent announce url and
    matching it to a specific rule set defined above.

    :param client: Transmission RPC Client
    :type client: transmissionrpc.Client
    """
    for torrent in client.get_torrents():
        if torrent.error or torrent.status != "seeding":
            continue
        rule_set = find_rule_set(torrent)
        if torrent.ratio > rule_set['max_ratio']:
            remove_torrent(client, torrent, "max_ratio threshold passed", dry_run=False)
        if torrent.secondsSeeding > rule_set['min_time']:
            remove_torrent(client, torrent, "min_time threshold passed", dry_run=False) 
開發者ID:leighmacdonald,項目名稱:transmission_scripts,代碼行數:18,代碼來源:__init__.py

示例4: configureCallback

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
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() 
開發者ID:opendreambox,項目名稱:enigma2-plugins,代碼行數:20,代碼來源:EmissionOverview.py

示例5: setup_platform

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Transmission switch."""
    import transmissionrpc
    from transmissionrpc.error import TransmissionError

    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)
    port = config.get(CONF_PORT)

    transmission_api = transmissionrpc.Client(
        host, port=port, user=username, password=password)
    try:
        transmission_api.session_stats()
    except TransmissionError:
        _LOGGING.error("Connection to Transmission API failed")
        return False

    add_devices([TransmissionSwitch(transmission_api, name)]) 
開發者ID:NAStools,項目名稱:homeassistant,代碼行數:22,代碼來源:transmission.py

示例6: remove_unknown_torrents

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def remove_unknown_torrents(client):
    """ Remove torrents that the remote tracker no longer tracking for whatever
    reason, usually removed by admins.

    :param client: Transmission RPC Client
    :type client: transmissionrpc.Client
    """
    for torrent in client.get_torrents():
        if torrent.error >= 2 and torrent.errorString.lower() in REMOTE_MESSAGES:
            remove_torrent(client, torrent) 
開發者ID:leighmacdonald,項目名稱:transmission_scripts,代碼行數:12,代碼來源:__init__.py

示例7: download

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def download(self):
        try:
            import transmissionrpc
            tc = transmissionrpc.Client(TRANSMISSION_RPC_URL, port=TRANSMISSION_RPC_PORT)
            tc.add_torrent(self.torrent, download_dir=self.save_path)
            print_info('Add torrent into the download queue, the file will be saved at {0}'.format(self.save_path))
        except ImportError:
            pass 
開發者ID:RicterZ,項目名稱:BGmi,代碼行數:10,代碼來源:services.py

示例8: download_status

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def download_status(status=None):
        print_info('Print download status in database')
        DownloadService.download_status(status=status)
        print()
        print_info('Print download status in transmission-rpc')
        try:
            import transmissionrpc
            tc = transmissionrpc.Client(TRANSMISSION_RPC_URL, port=TRANSMISSION_RPC_PORT)
            for torrent in tc.get_torrents():
                print_info('  * {0}: {1}'.format(torrent.status, torrent), indicator=False)
        except ImportError:
            pass 
開發者ID:RicterZ,項目名稱:BGmi,代碼行數:14,代碼來源:services.py

示例9: connect

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def connect(self) -> bool:
        try:
            if 'https://' in self.address:
                http_handler = TransmissionHTTPSHandler(secure=self.secure)
            else:
                http_handler = None
            self.trans = transmissionrpc.Client(
                address=self.address,
                user=self.user,
                password=self.password,
                http_handler=http_handler
            )
        except transmissionrpc.TransmissionError:
            return False
        return True 
開發者ID:pandabuilder,項目名稱:pandachaika,代碼行數:17,代碼來源:transmission.py

示例10: __init__

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def __init__(self):
        try:
            self._client = transmissionrpc.Client(
                address=settings.TRANSMISSION_HOST,
                port=settings.TRANSMISSION_PORT,
                user=settings.TRANSMISSION_USERNAME,
                password=settings.TRANSMISSION_PASSWORD)
        except transmissionrpc.TransmissionError as e:
            raise TorrentClientException(str(e)) 
開發者ID:danielkoster,項目名稱:argosd,代碼行數:11,代碼來源:torrentclient.py

示例11: update_blocklist

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def update_blocklist():
    transmission_client = transmissionrpc.Client(
        transmission_host, port=transmission_port, user=transmission_user,
        password=transmission_password
    )
    transmission_client.blocklist_update() 
開發者ID:craigcabrey,項目名稱:axel,代碼行數:8,代碼來源:core.py

示例12: handle_finished_download

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def handle_finished_download():
    torrent_id = os.environ['TR_TORRENT_ID']
    syslog.syslog('Beginning processing of torrent {0}'.format(torrent_id))

    transmission_client = transmissionrpc.Client(
        transmission_host, port=transmission_port, user=transmission_user,
        password=transmission_password
    )
    torrent = transmission_client.get_torrent(torrent_id)

    # Make sure transmission called us with a completed torrent
    if torrent.progress != 100.0:
        syslog.syslog(syslog.LOG_ERR, 'Called with an incomplete torrent')
        sys.exit(1)

    if couchpotato_category in torrent.downloadDir:
        if not ignore_couchpotato:
            handle_couchpotato(torrent)
    elif sonarr_category in torrent.downloadDir:
        if not ignore_sonarr:
            handle_sonarr(torrent)
    else:
        handle_manual(torrent)

    # Immediately remove torrents that are not whitelisted (by tracker)
    if not whitelisted(torrent):
        transmission_client.remove_torrent(torrent_id)
        pb_notify('Removed non-whitelisted torrent {0}'.format(torrent.name)) 
開發者ID:craigcabrey,項目名稱:axel,代碼行數:30,代碼來源:core.py

示例13: remove_local_errors

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def remove_local_errors(client):
    """ Removed torrents that have local filesystem errors, usually caused by moving data
    outside of transmission.

    :param client: Transmission RPC Client
    :type client: transmissionrpc.Client
    """
    for torrent in client.get_torrents():
        if torrent.error == 3:
            for errmsg in LOCAL_ERRORS:
                if errmsg in torrent.errorString.lower():
                    remove_torrent(client, torrent)
                    break 
開發者ID:leighmacdonald,項目名稱:transmission_scripts,代碼行數:15,代碼來源:__init__.py

示例14: __init__

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def __init__(self, config):
        self.tc = transmissionrpc.Client(
            address=config['transmission']['address'],
            port=config['transmission']['port'],
            user=config['transmission'].get('user', None),
            password=config['transmission'].get('password', None))

        self.torrent_session = self.tc.get_session() 
開發者ID:benjiao,項目名稱:slack-torrent-bot,代碼行數:10,代碼來源:torrents.py

示例15: simplerss_update_callback

# 需要導入模塊: import transmissionrpc [as 別名]
# 或者: from transmissionrpc import Client [as 別名]
def simplerss_update_callback(id = None):
	try:
		from Plugins.Extensions.SimpleRSS.plugin import rssPoller
	except ImportError:
		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
			) 
開發者ID:opendreambox,項目名稱:enigma2-plugins,代碼行數:43,代碼來源:plugin.py


注:本文中的transmissionrpc.Client方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。