예제 #1
0
def get_session_stats():
	try:
		check_preallocation()
	except PreallocationException:
		raise

	logger.info('Will attempt to get session stats')
	return util.object_to_json(rpc.session_stats())
예제 #2
0
def add_torrent_magnet_link(magnet_link):
	try:
		check_preallocation()
	except PreallocationException:
		raise

	logger.info('Got magnet_link: "%s"', magnet_link)
	added_torrent = rpc.add_torrent(magnet_link)
	json_torrent_data = util.object_to_json(added_torrent)
	logger.debug('Added torrent data:\n%s', json.dumps(json_torrent_data))
	return json_torrent_data
예제 #3
0
def get_torrent_info_by_id(ids):
	try:
		check_preallocation()
	except PreallocationException:
		raise

	ids = handle_ids_argument(ids)

	logger.info('Will attempt to get information for torrents with ids: %s', json.dumps(ids))

	return [util.object_to_json(x) for x in rpc.get_torrents(ids)]
예제 #4
0
def pause_torrent(hash_or_id):
	try:
		check_preallocation()
	except PreallocationException:
		raise

	if util.is_hash_not_id(hash_or_id):
		logger.debug('%s seems to be a torrent hash. Proceeding...', hash_or_id)
		hash_or_id = torrent_hash_to_id(hash_or_id)
	else:
		logger.debug('%s seems to be a torrent id. Proceeding...', hash_or_id)

	return util.object_to_json(rpc.get_torrents(hash_or_id)[0])
예제 #5
0
 def on_close(self):
     WSHandler.clients.remove(self)
     WSHandler.broadcast(object_to_json(CloseData(id(self))))
예제 #6
0
 def open(self):
     WSHandler.clients.add(self)
     self.write_message(object_to_json(InitData(id(self))))
예제 #7
0
def initialize():
	global rpc
	logger.info('Initializing Transmission Daemon Driver module at [%s:%s]', TRANSMISSION_DAEMON_HOSTNAME, TRANSMISSION_DAEMON_PORT)
	rpc = transmissionrpc.Client(address=TRANSMISSION_DAEMON_HOSTNAME, port=TRANSMISSION_DAEMON_PORT)
	logger.debug('Initialized session information:\n%s', json.dumps(util.object_to_json(rpc.get_session())))
	logger.debug('RPC timeout: %s', rpc.timeout)