本文整理匯總了Python中Resource.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python Resource.__init__方法的具體用法?Python Resource.__init__怎麽用?Python Resource.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Resource
的用法示例。
在下文中一共展示了Resource.__init__方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Copyright
# 需要導入模塊: import Resource [as 別名]
# 或者: from Resource import __init__ [as 別名]
## core.py## Copyright (C) 2009 John Doee <[email protected]>## Basic plugin template created by:# Copyright (C) 2008 Martijn Voncken <[email protected]># Copyright (C) 2007-2009 Andrew Resch <[email protected]># Copyright (C) 2009 Damien Churchil ... //#注:代碼行過長, 已省略後續字符...
import base64import jsonimport loggingimport osimport urllib
import deluge.configmanager
from collections import defaultdict
from deluge import componentfrom deluge._libtorrent import ltfrom deluge.core.rpcserver import exportfrom deluge.plugins.pluginbase import CorePluginBase
from twisted.internet import reactor, defer, taskfrom twisted.python import randbytesfrom twisted.web import server, resource, static, http, client
from .filelike import FilelikeObjectResourcefrom .resource import Resource
logger = logging.getLogger(__name__)
DEFAULT_PREFS = { 'ip': '127.0.0.1', 'port': 46123, 'allow_remote': False, 'reset_complete': True, 'use_stream_urls': True, 'auto_open_stream_urls': False, 'remote_username': 'username', 'remote_password': 'password',}
def sleep(seconds): d = defer.Deferred() reactor.callLater(seconds, d.callback, seconds) return d
class FileServeResource(resource.Resource): isLeaf = True def __init__(self): self.file_mapping = {} resource.Resource.__init__(self)
def generate_secure_token(self): return base64.urlsafe_b64encode(randbytes.RandomFactory().secureRandom(21, True)) def add_file(self, path): token = self.generate_secure_token() self.file_mapping[token] = path return token def render_GE ... //#注:代碼行過長, 已省略後續字符...
class StreamResource(Resource): isLeaf = True def __init__(self, client, *args, **kwargs): self.client = client Resource.__init__(self, *args, **kwargs) @defer.inlineCallbacks def render_GET(self, request): infohash = request.ar ... //#注:代碼行過長, 已省略後續字符...
class UnknownTorrentException(Exception): pass
class UnknownFileException(Exception): pass
class TorrentFileReader(object): def __init__(self, torrent_file): self.torrent_file = torrent_file self.size = torrent_file.size self.position = 0 self.waiting_for_piece = None self.current_piece = None self.current_piece_data = None @defer.inl ... //#注:代碼行過長, 已省略後續字符...
class TorrentFile(object): # can be read from, knows about itself def __init__(self, torrent, first_piece, last_piece, piece_size, offset, path, full_path, size, index): self.torrent = torrent self.first_piece = first_piece self.last_piece = last_ ... //#注:代碼行過長, 已省略後續字符...
class Torrent(object): def __init__(self, torrent_handler, infohash): self.infohash = infohash self.torrent = component.get("TorrentManager").torrents.get(infohash, None) self.torrent_handler = torrent_handler if not self.torrent: raise UnknownTo ... //#注:代碼行過長, 已省略後續字符...
class TorrentHandler(object): def __init__(self, config): self.torrents = {} self.config = config self.alerts = component.get("AlertManager") self.alerts.register_handler("torrent_removed_alert", self.on_alert_torrent_removed) def get_stream(sel ... //#注:代碼行過長, 已省略後續字符...
class Core(CorePluginBase): def enable(self): self.config = deluge.configmanager.ConfigManager("streaming.conf", DEFAULT_PREFS) self.fsr = FileServeResource() self.resource = Resource() self.resource.putChild('file', self.fsr) if self.config['all ... //#注:代碼行過長, 已省略後續字符...
@defer.inlineCallbacks def disable(self): self.site.stopFactory() self.torrent_handler.shutdown() yield self.listening.stopListening()
def update(self): pass
@export @defer.inlineCallbacks def set_config(self, config): """Sets the config dictionary""" for key in config.keys(): self.config[key] = config[key] self.config.save() yield self.disable() self.enable()
@export def get_config(self): """Returns the config dictionary""" return self.config.config @export @defer.inlineCallbacks def stream_torrent(self, infohash=None, url=None, filedump=None, filepath_or_index=None, includes_name=False): tor ... //#注:代碼行過長, 已省略後續字符...