def __init__(self, data_handler, overlay_bridge, log = '', dnsindb = None):
    
        if DEBUG:
            print >> sys.stderr, "=================Initializing bartercast core"
    
        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.overlay_bridge = overlay_bridge
        self.bartercastdb = BarterCastDBHandler.getInstance()
        
        self.network_delay = 30
        self.send_block_list = {}
        self.recv_block_list = {}
        self.block_interval = 1*60*60   # block interval for a peer to barter   cast

        self.topn = self.bartercastdb.getTopNPeers(NO_PEERS_IN_MSG, local_only = True)['top']
        self.overlay_bridge.add_task(self.refreshTopN, REFRESH_TOPN_INTERVAL)
        
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
            
        if LOG:
            self.logfile = '/Users/michel/packages/bartercast_dataset/bartercast42.log'
            if not os.path.exists(self.logfile):
                log = open(self.logfile, 'w')
                log.close()
示例#2
0
    def __init__(self, data_handler, secure_overlay, session, buddycast_interval_function, log = '', dnsindb = None):
        """ Returns an instance of this class
        """
        #Keep reference to interval-function of BuddycastFactory
        self.interval = buddycast_interval_function
        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.secure_overlay = secure_overlay
        self.votecastdb = VoteCastDBHandler.getInstance()
        self.my_permid = self.votecastdb.my_permid
        self.session = session
        self.max_length = SINGLE_VOTECAST_LENGTH * (session.get_votecast_random_votes() + session.get_votecast_recent_votes())       

        self.network_delay = 30
        #Reference to buddycast-core, set by the buddycast-core (as it is created by the
        #buddycast-factory after calling this constructor).
        self.buddycast_core = None
        
        
        self.notifier = Notifier.getInstance()
        
        #Extend logging with VoteCast-messages and status
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
示例#3
0
    def __init__(self,
                 data_handler,
                 secure_overlay,
                 session,
                 buddycast_interval_function,
                 log='',
                 dnsindb=None):
        """ Returns an instance of this class """
        #Keep reference to interval-function of BuddycastFactory
        self.interval = buddycast_interval_function
        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.secure_overlay = secure_overlay
        self.channelcastdb = ChannelCastDBHandler.getInstance()
        self.rtorrent_handler = RemoteTorrentHandler.getInstance()
        self.my_permid = self.channelcastdb.my_permid
        self.session = session

        self.network_delay = 30
        #Reference to buddycast-core, set by the buddycast-core (as it is created by the
        #buddycast-factory after calling this constructor).
        self.buddycast_core = None

        #Extend logging with ChannelCast-messages and status
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
            self.dnsindb = self.data_handler.get_dns_from_peerdb
        self.hits = []
示例#4
0
    def __init__(self, data_handler, overlay_bridge, log='', dnsindb=None):

        if DEBUG:
            print >> sys.stderr, "=================Initializing bartercast core"

        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.overlay_bridge = overlay_bridge
        self.bartercastdb = BarterCastDBHandler.getInstance()

        self.network_delay = 30
        self.send_block_list = {}
        self.recv_block_list = {}
        self.block_interval = 1 * 60 * 60  # block interval for a peer to barter   cast

        self.topn = self.bartercastdb.getTopNPeers(NO_PEERS_IN_MSG,
                                                   local_only=True)['top']
        self.overlay_bridge.add_task(self.refreshTopN, REFRESH_TOPN_INTERVAL)

        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)

        if LOG:
            self.logfile = '/Users/michel/packages/bartercast_dataset/bartercast42.log'
            if not os.path.exists(self.logfile):
                log = open(self.logfile, 'w')
                log.close()
 def register(self,overlay_bridge,launchmany,config,bc_fac,log=''):
     if DEBUG:
         print >> sys.stderr,"rquery: register"
     self.overlay_bridge = overlay_bridge
     self.session =  launchmany.session
     self.torrent_db = launchmany.torrent_db
     self.peer_db = launchmany.peer_db
     self.channelcast_db = launchmany.channelcast_db
     # debug
     # self.superpeer_db = launchmany.superpeer_db
     
     self.config = config
     self.bc_fac = bc_fac # May be None
     if log:
         self.overlay_log = OverlayLogger.getInstance(log)
     self.torrent_dir = os.path.abspath(self.config['torrent_collecting_dir'])
     self.registered = True
示例#6
0
    def register(self, overlay_bridge, launchmany, config, bc_fac, log=''):
        if DEBUG:
            print >> sys.stderr, "rquery: register"
        self.overlay_bridge = overlay_bridge
        self.session = launchmany.session
        self.torrent_db = launchmany.torrent_db
        self.peer_db = launchmany.peer_db
        self.channelcast_db = launchmany.channelcast_db
        # debug
        # self.superpeer_db = launchmany.superpeer_db

        self.config = config
        self.bc_fac = bc_fac  # May be None
        if log:
            self.overlay_log = OverlayLogger.getInstance(log)
        self.torrent_dir = os.path.abspath(
            self.config['torrent_collecting_dir'])
        self.registered = True
示例#7
0
    def __init__(self, data_handler, overlay_bridge, session, buddycast_interval_function, log = '', dnsindb = None):
        """ Returns an instance of this class """
        #Keep reference to interval-function of BuddycastFactory
        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.my_permid = self.channelcastdb.my_permid
        self.session = session
        
        self.network_delay = 30
        #Reference to buddycast-core, set by the buddycast-core (as it is created by the
        #buddycast-factory after calling this constructor).
        self.buddycast_core = None
        
        #Extend logging with ChannelCast-messages and status
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
            self.dnsindb = self.data_handler.get_dns_from_peerdb
        
        self.hits = []
        
        self.notifier = Notifier.getInstance()

        self.metadataDbHandler = MetadataDBHandler.getInstance()
        
        #subtitlesHandler = SubtitlesHandler.getInstance()
        subtitleSupport = SubtitlesSupport.getInstance()
        # better if an instance of RMDInterceptor was provided from the
        # outside
        self.peersHaveManger = PeersHaveManager.getInstance()
        if not self.peersHaveManger.isRegistered():
                self.peersHaveManger.register(self.metadataDbHandler, self.overlay_bridge)
        self.richMetadataInterceptor = RichMetadataInterceptor(self.metadataDbHandler,self.votecastdb,
                                                               self.my_permid, subtitleSupport, self.peersHaveManger,
                                                               self.notifier)
示例#8
0
    def __init__(self, data_handler, secure_overlay, session, buddycast_interval_function, log = '', dnsindb = None):
        """ Returns an instance of this class
        """
        #Keep reference to interval-function of BuddycastFactory
        self.interval = buddycast_interval_function
        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.secure_overlay = secure_overlay
        self.votecastdb = VoteCastDBHandler.getInstance()
        self.my_permid = self.votecastdb.my_permid
        self.session = session
        self.max_length = SINGLE_VOTECAST_LENGTH * (session.get_votecast_random_votes() + session.get_votecast_recent_votes())       

        self.network_delay = 30
        #Reference to buddycast-core, set by the buddycast-core (as it is created by the
        #buddycast-factory after calling this constructor).
        self.buddycast_core = None
        
        #Extend logging with VoteCast-messages and status
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
示例#9
0
 def register(self,overlay_bridge,launchmany,config,bc_fac,log=''):
     if DEBUG:
         print >> sys.stderr,"rquery: register"
     self.overlay_bridge = overlay_bridge
     self.session =  launchmany.session
     self.torrent_db = launchmany.torrent_db
     self.peer_db = launchmany.peer_db
     self.channelcast_db = launchmany.channelcast_db
     # debug
     # self.superpeer_db = launchmany.superpeer_db
     
     self.config = config
     self.bc_fac = bc_fac # May be None
     if log:
         self.overlay_log = OverlayLogger.getInstance(log)
     self.torrent_dir = os.path.abspath(self.config['torrent_collecting_dir'])
     self.registered = True
     
     # 14-04-2010, Andrea: limit the size of channel query results.
     # see create_channel_query_reply (here) and process_query_reply
     # for other details. (The whole thing is done to avoid freezes in the GUI
     # when there are too many results)
     self.max_channel_query_results = self.config['max_channel_query_results']
 def __init__(self, data_handler, secure_overlay, session, buddycast_interval_function, log = '', dnsindb = None):
     """ Returns an instance of this class """
     #Keep reference to interval-function of BuddycastFactory
     self.interval = buddycast_interval_function
     self.data_handler = data_handler
     self.dnsindb = dnsindb
     self.log = log
     self.secure_overlay = secure_overlay
     self.channelcastdb = ChannelCastDBHandler.getInstance()
     self.rtorrent_handler = RemoteTorrentHandler.getInstance()
     self.my_permid = self.channelcastdb.my_permid
     self.session = session
     
     self.network_delay = 30
     #Reference to buddycast-core, set by the buddycast-core (as it is created by the
     #buddycast-factory after calling this constructor).
     self.buddycast_core = None
     
     #Extend logging with ChannelCast-messages and status
     if self.log:
         self.overlay_log = OverlayLogger.getInstance(self.log)
         self.dnsindb = self.data_handler.get_dns_from_peerdb
     self.hits = []