当前位置: 首页>>代码示例>>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;未经允许,请勿转载。