当前位置: 首页>>代码示例>>Python>>正文


Python Resource.__init__方法代码示例

本文整理汇总了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  ... //#注:代码行过长, 已省略后续字符...
开发者ID:ccavxx,项目名称:py-search,代码行数:27,代码来源:JohnDoee_core.py


注:本文中的Resource.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。