def register(self, overlay_bridge, metadataDBHandler, session):
        self.overlay_bridge = overlay_bridge
        self.subtitlesDb = metadataDBHandler
        self.config_dir = os.path.abspath(session.get_state_dir())
        subs_path = os.path.join(self.config_dir, session.get_subtitles_collecting_dir())
        self.subs_dir = os.path.abspath(session.get_subtitles_collecting_dir())
        self._upload_rate = session.get_subtitles_upload_rate()
        self.max_subs_message_size = MAX_SUBS_MESSAGE_SIZE
        self._session = session
        tokenBucket = SimpleTokenBucket(self._upload_rate, self.max_subs_message_size)
        self._subsMsgHndlr = SubsMessageHandler(self.overlay_bridge, tokenBucket, MAX_SUBTITLE_SIZE)
        self._subsMsgHndlr.registerListener(self)
        if os.path.isdir(self.config_dir):
            if not os.path.isdir(self.subs_dir):
                try:
                    os.mkdir(self.subs_dir)
                except:
                    msg = u'Cannot create collecting dir %s ' % self.subs_dir
                    print >> sys.stderr, 'Error: %s' % msg
                    raise IOError(msg)

        else:
            msg = u'Configuration dir %s does not exists' % self.subs_dir
            print >> sys.stderr, 'Error: %s' % msg
            raise IOError(msg)
        self._notifier = Notifier.getInstance()
        self.registered = True
 def __init__(self,
              data_handler,
              overlay_bridge,
              session,
              buddycast_interval_function,
              log='',
              dnsindb=None):
     self.interval = buddycast_interval_function
     self.data_handler = data_handler
     self.dnsindb = dnsindb
     self.log = log
     self.overlay_bridge = overlay_bridge
     self.channelcastdb = ChannelCastDBHandler.getInstance()
     self.votecastdb = VoteCastDBHandler.getInstance()
     self.rtorrent_handler = RemoteTorrentHandler.getInstance()
     self.session = session
     self.my_permid = session.get_permid()
     self.network_delay = 30
     self.buddycast_core = None
     if self.log:
         self.overlay_log = OverlayLogger.getInstance(self.log)
         self.dnsindb = self.data_handler.get_dns_from_peerdb
     self.notifier = Notifier.getInstance()
     self.metadataDbHandler = MetadataDBHandler.getInstance()
     subtitleSupport = SubtitlesSupport.getInstance()
     self.peersHaveManger = PeersHaveManager.getInstance()
     if not self.peersHaveManger.isRegistered():
         self.peersHaveManger.register(self.metadataDbHandler,
                                       self.overlay_bridge)
Exemplo n.º 3
0
 def __init__(self, session):
     self.session = session
     self.sesslock = session.sesslock
     self.sessconfig = session.sessconfig
     mode = globalConfig.get_mode()
     if mode == "stream" or mode == "node" or mode == "tracker":
         count_threads = 1
     else:
         count_threads = 10
     self.threadpool = ThreadPool(count_threads)
     self.notifier = Notifier.getInstance(self.threadpool)
Exemplo n.º 4
0
 def __init__(self, session):
     self.session = session
     self.sesslock = session.sesslock
     self.sessconfig = session.sessconfig
     mode = globalConfig.get_mode()
     if mode == 'stream' or mode == 'node' or mode == 'tracker':
         count_threads = 1
     else:
         count_threads = 10
     self.threadpool = ThreadPool(count_threads)
     self.notifier = Notifier.getInstance(self.threadpool)
 def __init__(self, data_handler, secure_overlay, session, buddycast_interval_function, log = '', dnsindb = None):
     self.interval = buddycast_interval_function
     self.data_handler = data_handler
     self.dnsindb = dnsindb
     self.log = log
     self.peerdb = PeerDBHandler.getInstance()
     self.votecastdb = VoteCastDBHandler.getInstance()
     self.session = session
     self.my_permid = session.get_permid()
     self.max_length = SINGLE_VOTECAST_LENGTH * (session.get_votecast_random_votes() + session.get_votecast_recent_votes())
     self.buddycast_core = None
     self.notifier = Notifier.getInstance()
     if self.log:
         self.overlay_log = OverlayLogger.getInstance(self.log)
 def __init__(self, data_handler, overlay_bridge, session, buddycast_interval_function, log = '', dnsindb = None):
     self.interval = buddycast_interval_function
     self.data_handler = data_handler
     self.dnsindb = dnsindb
     self.log = log
     self.overlay_bridge = overlay_bridge
     self.channelcastdb = ChannelCastDBHandler.getInstance()
     self.votecastdb = VoteCastDBHandler.getInstance()
     self.rtorrent_handler = RemoteTorrentHandler.getInstance()
     self.session = session
     self.my_permid = session.get_permid()
     self.network_delay = 30
     self.buddycast_core = None
     if self.log:
         self.overlay_log = OverlayLogger.getInstance(self.log)
         self.dnsindb = self.data_handler.get_dns_from_peerdb
     self.notifier = Notifier.getInstance()
     self.metadataDbHandler = MetadataDBHandler.getInstance()
     subtitleSupport = SubtitlesSupport.getInstance()
     self.peersHaveManger = PeersHaveManager.getInstance()
     if not self.peersHaveManger.isRegistered():
         self.peersHaveManger.register(self.metadataDbHandler, self.overlay_bridge)