本文整理汇总了Python中Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python TorrentDBHandler.getInstance方法的具体用法?Python TorrentDBHandler.getInstance怎么用?Python TorrentDBHandler.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler
的用法示例。
在下文中一共展示了TorrentDBHandler.getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import getInstance [as 别名]
def __init__(self, master, integrate_with_tribler = True):
super(SearchCommunity, self).__init__(master)
self.integrate_with_tribler = integrate_with_tribler
self.taste_buddies = []
#To always connect to a peer uncomment/modify the following line
#self.taste_buddies.append([1, time(), Candidate(("127.0.0.1", 1234), False))
if self.integrate_with_tribler:
from Tribler.Core.CacheDB.SqliteCacheDBHandler import ChannelCastDBHandler, TorrentDBHandler, MyPreferenceDBHandler
from Tribler.Core.CacheDB.Notifier import Notifier
# tribler channelcast database
self._channelcast_db = ChannelCastDBHandler.getInstance()
self._torrent_db = TorrentDBHandler.getInstance()
self._mypref_db = MyPreferenceDBHandler.getInstance()
self._notifier = Notifier.getInstance()
# torrent collecting
self._rtorrent_handler = RemoteTorrentHandler.getInstance()
else:
self._channelcast_db = ChannelCastDBStub(self._dispersy)
self._torrent_db = None
self._mypref_db = None
self._notifier = None
self.taste_bloom_filter = None
self.taste_bloom_filter_key = None
self.torrent_cache = None
self.dispersy.callback.register(self.create_torrent_collect_requests, delay = CANDIDATE_WALK_LIFETIME)
self.dispersy.callback.register(self.fast_walker)
示例2: __init__
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import getInstance [as 别名]
def __init__(self, parent):
HomePanel.__init__(self, parent, 'Newest Torrents' , LIST_BLUE)
self.Layout()
self.torrentdb = TorrentDBHandler.getInstance()
session = Session.get_instance()
session.add_observer(self.OnNotify, NTFY_TORRENTS, [NTFY_INSERT])
示例3: __init__
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import getInstance [as 别名]
def __init__(self, master, integrate_with_tribler = True):
super(SearchCommunity, self).__init__(master)
self.integrate_with_tribler = integrate_with_tribler
self.taste_buddies = []
if self.integrate_with_tribler:
from Tribler.Core.CacheDB.SqliteCacheDBHandler import ChannelCastDBHandler, TorrentDBHandler, MyPreferenceDBHandler
from Tribler.Core.CacheDB.Notifier import Notifier
# tribler channelcast database
self._channelcast_db = ChannelCastDBHandler.getInstance()
self._torrent_db = TorrentDBHandler.getInstance()
self._mypref_db = MyPreferenceDBHandler.getInstance()
self._notifier = Notifier.getInstance()
# torrent collecting
self._rtorrent_handler = RemoteTorrentHandler.getInstance()
else:
self._channelcast_db = ChannelCastDBStub(self._dispersy)
self._torrent_db = None
self._mypref_db = None
self._notifier = None
self.taste_bloom_filter = None
self.taste_bloom_filter_key = None
self.dispersy.callback.register(self.create_torrent_collect_requests, delay = CANDIDATE_WALK_LIFETIME)
示例4: setUp
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import getInstance [as 别名]
def setUp(self):
AbstractDB.setUp(self)
self.tdb = TorrentDBHandler.getInstance()
self.tdb.torrent_dir = FILES_DIR
self.tdb.mypref_db = MyPreferenceDBHandler.getInstance()
self.tdb._nb = NetworkBuzzDBHandler.getInstance()
示例5: __init__
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import getInstance [as 别名]
def __init__(self, parent):
HomePanel.__init__(self, parent, 'Network info' , SEPARATOR_GREY, (0, 1))
self.torrentdb = TorrentDBHandler.getInstance()
self.channelcastdb = ChannelCastDBHandler.getInstance()
self.remotetorrenthandler = RemoteTorrentHandler.getInstance()
self.timer = None
session = Session.get_instance()
session.add_observer(self.OnNotify, NTFY_TORRENTS, [NTFY_INSERT])
self.UpdateStats()
示例6: setUp
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import getInstance [as 别名]
def setUp(self):
self.setUpCleanup()
config = {}
config['state_dir'] = self.getStateDir()
config['install_dir'] = '.'
init_db(config)
self.tdb = TorrentDBHandler.getInstance()
self.tdb.torrent_dir = FILES_DIR
self.tdb.mypref_db = MyPreferenceDBHandler.getInstance()
self.tdb._nb = NetworkBuzzDBHandler.getInstance()
self.torrentChecking = TorrentChecking()
sleep(5)
示例7: _printDBStats
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import getInstance [as 别名]
def _printDBStats(self):
torrentdb = TorrentDBHandler.getInstance()
tables = torrentdb._db.fetchall("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name");
for table, in tables:
print >> sys.stderr, table, torrentdb._db.fetchone("SELECT COUNT(*) FROM %s"%table)
示例8: register
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import getInstance [as 别名]
#.........这里部分代码省略.........
if config['dispersy']:
from Tribler.dispersy.callback import Callback
from Tribler.dispersy.dispersy import Dispersy
from Tribler.dispersy.endpoint import RawserverEndpoint, TunnelEndpoint
from Tribler.dispersy.community import HardKilledCommunity
# set communication endpoint
if config['dispersy-tunnel-over-swift'] and self.swift_process:
endpoint = TunnelEndpoint(self.swift_process)
else:
endpoint = RawserverEndpoint(self.rawserver, config['dispersy_port'])
callback = Callback("Dispersy") # WARNING NAME SIGNIFICANT
working_directory = unicode(config['state_dir'])
self.dispersy = Dispersy(callback, endpoint, working_directory)
# TODO: see if we can postpone dispersy.start to improve GUI responsiveness.
# However, for now we must start self.dispersy.callback before running
# try_register(nocachedb, self.database_thread)!
self.dispersy.start()
print >> sys.stderr, "lmc: Dispersy is listening on port", self.dispersy.wan_address[1], "using", endpoint
self.upnp_ports.append((self.dispersy.wan_address[1], 'UDP'))
self.dispersy.callback.call(self.dispersy.define_auto_load, args=(HardKilledCommunity,), kargs={'load': True})
# notify dispersy finished loading
self.session.uch.notify(NTFY_DISPERSY, NTFY_STARTED, None)
from Tribler.Core.permid import read_keypair
from Tribler.dispersy.crypto import ec_to_public_bin, ec_to_private_bin
keypair = read_keypair(self.session.get_permid_keypair_filename())
self.session.dispersy_member = callback.call(self.dispersy.get_member, (ec_to_public_bin(keypair), ec_to_private_bin(keypair)))
self.database_thread = callback
else:
class FakeCallback():
def __init__(self):
from Tribler.Utilities.TimedTaskQueue import TimedTaskQueue
self.queue = TimedTaskQueue("FakeCallback")
def register(self, call, args=(), kargs=None, delay=0.0, priority=0, id_=u"", callback=None, callback_args=(), callback_kargs=None, include_id=False):
def do_task():
if kargs:
call(*args, **kargs)
else:
call(*args)
if callback:
if callback_kargs:
callback(*callback_args, **callback_kargs)
else:
callback(*callback_args)
self.queue.add_task(do_task, t=delay)
def shutdown(self, immediately=False):
self.queue.shutdown(immediately)
self.database_thread = FakeCallback()
if config['megacache']:
import Tribler.Core.CacheDB.cachedb as cachedb
from Tribler.Core.CacheDB.SqliteCacheDBHandler import PeerDBHandler, TorrentDBHandler, MyPreferenceDBHandler, VoteCastDBHandler, ChannelCastDBHandler, NetworkBuzzDBHandler, UserEventLogDBHandler
from Tribler.Category.Category import Category
from Tribler.Core.Tag.Extraction import TermExtraction
from Tribler.Core.CacheDB.sqlitecachedb import try_register
if DEBUG:
print >> sys.stderr, 'tlm: Reading Session state from', config['state_dir']
nocachedb = cachedb.init(config, self.rawserver_fatalerrorfunc)
try_register(nocachedb, self.database_thread)
self.cat = Category.getInstance(config['install_dir'])
self.term = TermExtraction.getInstance(config['install_dir'])
self.peer_db = PeerDBHandler.getInstance()
self.peer_db.registerConnectionUpdater(self.session)
self.torrent_db = TorrentDBHandler.getInstance()
self.torrent_db.register(os.path.abspath(config['torrent_collecting_dir']))
self.mypref_db = MyPreferenceDBHandler.getInstance()
self.votecast_db = VoteCastDBHandler.getInstance()
self.votecast_db.registerSession(self.session)
self.channelcast_db = ChannelCastDBHandler.getInstance()
self.channelcast_db.registerSession(self.session)
self.nb_db = NetworkBuzzDBHandler.getInstance()
self.ue_db = UserEventLogDBHandler.getInstance()
if self.dispersy:
self.dispersy.database.attach_commit_callback(self.channelcast_db._db.commitNow)
else:
config['torrent_checking'] = 0
self.rtorrent_handler = None
if config['torrent_collecting']:
from Tribler.Core.RemoteTorrentHandler import RemoteTorrentHandler
self.rtorrent_handler = RemoteTorrentHandler()