def __init__(self):
     if mainlineDHTChecker.__single:
         raise RuntimeError, "mainlineDHTChecker is Singleton"
     mainlineDHTChecker.__single = self
     
     self.dht = None
     self.torrent_db = TorrentDBHandler.getInstance()
 def register(self,session,metadata_handler,helpdir,dlconfig):
     self.session = session
     self.helpdir = helpdir
     # The default DownloadStartupConfig dict as set in the Session
     self.dlconfig = dlconfig
     self.torrent_db = TorrentDBHandler.getInstance()
     self.metadata_handler = metadata_handler
Exemple #3
0
    def __init__(self, interval=15, tor_col_dir="."):
        if TorrentChecking.__single:
            raise RuntimeError("Torrent Checking is singleton")
        TorrentChecking.__single = self

        Thread.__init__(self)

        self.setName('TorrentChecking' + self.getName())
        if DEBUG:
            print >> sys.stderr, 'TorrentChecking: Started torrentchecking from', threading.currentThread().getName()
        self.setDaemon(True)

        self.retryThreshold = 10
        self.interval = interval
        self.shouldquit = False

        self.queue = deque()
        self.queueset = set()
        self.queueLock = Lock()

        self.announceQueue = Queue()

        self.mldhtchecker = mainlineDHTChecker.getInstance()
        self.torrentdb = TorrentDBHandler.getInstance()

        self.sleepEvent = threading.Event()
        self.torrent_collection_dir = tor_col_dir

        self.start()
 def __init__(self, interval = 15):
     if TorrentChecking.__single:
         raise RuntimeError, "TorrentChecking is singleton"
     TorrentChecking.__single = self
     
     Thread.__init__(self)
     
     self.setName('TorrentChecking'+self.getName())
     if DEBUG:
         print >> sys.stderr, 'TorrentChecking: Started torrentchecking', threading.currentThread().getName()
     self.setDaemon(True)
     
     self.retryThreshold = 10
     self.gnThreashold = 0.9
     self.interval = interval
     
     self.queue = deque()
     self.queueset = set()
     self.queueLock = Lock()
     
     self.mldhtchecker = mainlineDHTChecker.getInstance()
     self.torrentdb = TorrentDBHandler.getInstance()
     self.notifier = Notifier.getInstance()
     
     self.sleepEvent = threading.Event()
     
     self.start()
    def __init__(self):
        if mainlineDHTChecker.__single:
            raise RuntimeError, "mainlineDHTChecker is Singleton"
        mainlineDHTChecker.__single = self

        self.dht = None
        self.torrent_db = TorrentDBHandler.getInstance()
    def __init__(self, interval=15):
        if TorrentChecking.__single:
            raise RuntimeError, "TorrentChecking is singleton"
        TorrentChecking.__single = self

        Thread.__init__(self)

        self.setName('TorrentChecking' + self.getName())
        if DEBUG:
            print >> sys.stderr, 'TorrentChecking: Started torrentchecking', threading.currentThread(
            ).getName()
        self.setDaemon(True)

        self.retryThreshold = 10
        self.gnThreashold = 0.9
        self.interval = interval

        self.queue = deque()
        self.queueset = set()
        self.queueLock = Lock()

        self.mldhtchecker = mainlineDHTChecker.getInstance()
        self.torrentdb = TorrentDBHandler.getInstance()
        self.notifier = Notifier.getInstance()

        self.sleepEvent = threading.Event()

        self.start()
 def register(self, session, metadata_handler, helpdir, dlconfig):
     self.session = session
     self.helpdir = helpdir
     # The default DownloadStartupConfig dict as set in the Session
     self.dlconfig = dlconfig
     self.torrent_db = TorrentDBHandler.getInstance()
     self.metadata_handler = metadata_handler
Exemple #8
0
    def __init__(self):

        if DEBUG:
            print >>sys.stderr,'mainlineDHTChecker: initialization'
        if mainlineDHTChecker.__single:
            raise RuntimeError, "mainlineDHTChecker is Singleton"
        mainlineDHTChecker.__single = self
        
        self.dht = None
        self.torrent_db = TorrentDBHandler.getInstance()
Exemple #9
0
    def __init__(self):

        if DEBUG:
            print >>sys.stderr,'mainlineDHTChecker: initialization'
        if mainlineDHTChecker.__single:
            raise RuntimeError, "mainlineDHTChecker is Singleton"
        mainlineDHTChecker.__single = self
        
        self.dht = None
        self.torrent_db = TorrentDBHandler.getInstance()
    def register(self, session, metadata_handler, proxydir, dlconfig):
        """ Called from OverlayApps.py:166
        """
        self.session = session
        self.proxydir = proxydir

        # The default DownloadStartupConfig dict as set in the Session
        self.dlconfig = dlconfig

        self.metadata_handler = metadata_handler
        self.torrent_db = TorrentDBHandler.getInstance()
    def register(self, session, metadata_handler, proxydir, dlconfig):
        """ Called from OverlayApps.py:166
        """
        self.session = session
        self.proxydir = proxydir

        # The default DownloadStartupConfig dict as set in the Session
        self.dlconfig = dlconfig

        self.metadata_handler = metadata_handler
        self.torrent_db = TorrentDBHandler.getInstance()
 def _PostInit(self):
     # Do all init here
     self.guiUtility = GUIUtility.getInstance()
     self.utility = self.guiUtility.utility
     self.categorykey = None
     self.torrent_db = TorrentDBHandler.getInstance()
     self.mypreference_db = MyPreferenceDBHandler.getInstance()
   
     self.mode = None
     self.data = {} #keeps gui elements for each mode
     for mode in OVERVIEW_MODES:
         self.data[mode] = {} #each mode has a dictionary of gui elements with name and reference
     self.currentPanel = None
     self.addComponents()
     #self.Refresh()
     
     self.guiUtility.initStandardOverview(self)    # show file panel
     self.toggleLoadingDetailsPanel(True)
    def _PostInit(self):
        # Do all init here
        self.guiUtility = GUIUtility.getInstance()
        self.utility = self.guiUtility.utility
        self.categorykey = None
        self.torrent_db = TorrentDBHandler.getInstance()
        self.mypreference_db = MyPreferenceDBHandler.getInstance()

        self.mode = None
        self.data = {}  #keeps gui elements for each mode
        for mode in OVERVIEW_MODES:
            self.data[mode] = {
            }  #each mode has a dictionary of gui elements with name and reference
        self.currentPanel = None
        self.addComponents()
        #self.Refresh()

        self.guiUtility.initStandardOverview(self)  # show file panel
        self.toggleLoadingDetailsPanel(True)
Exemple #14
0
 def onListDClick(self, event):
     if self.infohash_List:
         item = self.GetFirstSelected()
         if item != -1 and item < len(self.infohash_List):
             infohash = self.infohash_List[item] 
             # jie.done: clicke to download. fix it by replacing by db
             torrent_db = TorrentDBHandler.getInstance()
             torrent = torrent_db.getTorrent(infohash)
             torrent['infohash'] = infohash
             ret = self.guiUtility.standardDetails.download(torrent)
             if ret:
                 self.infohash_List.pop(item)
                 self.DeleteItem(item)
                 if self.other_List is not None:    
                     # only used to move items to common item list in peer view
                     if self.other_List.isEmpty:
                         self.other_List.DeleteAllItems()
                     self.other_List.InsertStringItem(sys.maxint, torrent['name'])
                     self.other_List.isEmpty = False
         event.Skip()
         if self.updateFunc:
             self.updateFunc(self.other_List, self)
             
Exemple #15
0
 def onListDClick(self, event):
     if self.infohash_List:
         item = self.GetFirstSelected()
         if item != -1 and item < len(self.infohash_List):
             infohash = self.infohash_List[item]
             # jie.done: clicke to download. fix it by replacing by db
             torrent_db = TorrentDBHandler.getInstance()
             torrent = torrent_db.getTorrent(infohash)
             torrent['infohash'] = infohash
             ret = self.guiUtility.standardDetails.download(torrent)
             if ret:
                 self.infohash_List.pop(item)
                 self.DeleteItem(item)
                 if self.other_List is not None:
                     # only used to move items to common item list in peer view
                     if self.other_List.isEmpty:
                         self.other_List.DeleteAllItems()
                     self.other_List.InsertStringItem(
                         sys.maxint, torrent['name'])
                     self.other_List.isEmpty = False
         event.Skip()
         if self.updateFunc:
             self.updateFunc(self.other_List, self)
Exemple #16
0
 def run(self):
     """ Gets one torrent from good or unknown list and checks it """
     
     try:
         if DEBUG:
             print >> sys.stderr, "Torrent Checking: RUN", threading.currentThread().getName()
             
         event = threading.Event()
         return_value = safe_dict()
         return_value['event'] = event
         return_value['torrent'] = None
         if self.infohash is None:   # select torrent by a policy
             policy = self.selectPolicy()
             if self.db_thread:
                 self.db_thread.add_task(lambda:
                     TorrentDBHandler.getInstance().selectTorrentToCheck(policy=policy, return_value=return_value))
             else:
                 TorrentDBHandler.getInstance().selectTorrentToCheck(policy=policy, return_value=return_value)
         else:   # know which torrent to check
             if self.db_thread:
                 self.db_thread.add_task(lambda:
                                              TorrentDBHandler.getInstance().selectTorrentToCheck(infohash=self.infohash, return_value=return_value))
             else:
                 TorrentDBHandler.getInstance().selectTorrentToCheck(infohash=self.infohash, return_value=return_value)
         event.wait(60.0)
         
         torrent = return_value['torrent']
         if DEBUG:
             print >> sys.stderr, "Torrent Checking: get value from DB:", torrent
         
         if not torrent:
             return
 
         if self.infohash is None and torrent['ignored_times'] > 0:
             if self.db_thread:
                 self.db_thread.add_task(lambda:
                     TorrentDBHandler.getInstance().updateTracker(torrent_id, torrent['ignored_times']-1))
             else:
                 TorrentDBHandler.getInstance().updateTracker(torrent_id, torrent['ignored_times']-1)
             return
 
         # may be block here because the internet IO
         torrent = self.readTorrent(torrent)    # read the torrent 
         if 'info' not in torrent:    #torrent has been deleted
             if self.db_thread:
                 self.db_thread.add_task(lambda:
                     TorrentDBHandler.getInstance().deleteTorrent(torrent['infohash']))
             return
         
         # TODO: tracker checking also needs to be update
         if DEBUG:
             print >> sys.stderr, "Tracker Checking"
         trackerChecking(torrent)
         
         # Must come after tracker check, such that if tracker dead and DHT still alive, the
         # status is still set to good
         self.mldhtchecker.lookup(torrent['infohash'])
         
         self.updateTorrentInfo(torrent)            # set the ignored_times
         
         kw = {
             'last_check_time': int(time()),
             'seeder': torrent['seeder'],
             'leecher': torrent['leecher'],
             'status': torrent['status'],
             'ignored_times': torrent['ignored_times'],
             'retried_times': torrent['retried_times'],
             #'info': torrent['info']
             }
         
         if DEBUG:
             print >> sys.stderr, "Torrent Checking: selectTorrentToCheck:", kw
         
         if self.db_thread:
             self.db_thread.add_task(lambda:
                 TorrentDBHandler.getInstance().updateTorrent(torrent['infohash'], updateFlag=True, **kw))
         else:
             TorrentDBHandler.getInstance().updateTorrent(torrent['infohash'], updateFlag=True, **kw)
     finally:
         if not self.db_thread:
             TorrentDBHandler.getInstance().close()
 def __init__(self):
     if RemoteTorrentHandler.__single:
         raise RuntimeError, "RemoteTorrentHandler is singleton"
     RemoteTorrentHandler.__single = self
     self.torrent_db = TorrentDBHandler.getInstance()
     self.requestedtorrents = {}
 def run(self):
     """ Gets one torrent from good or unknown list and checks it """
     
     try:
         if DEBUG:
             print >> sys.stderr, time.asctime(),'-', "Torrent Checking: RUN", threading.currentThread().getName()
             
         event = threading.Event()
         return_value = safe_dict()
         return_value['event'] = event
         return_value['torrent'] = None
         if self.infohash is None:   # select torrent by a policy
             policy = self.selectPolicy()
             if self.db_thread:
                 self.db_thread.add_task(lambda:
                     TorrentDBHandler.getInstance().selectTorrentToCheck(policy=policy, return_value=return_value))
             else:
                 TorrentDBHandler.getInstance().selectTorrentToCheck(policy=policy, return_value=return_value)
         else:   # know which torrent to check
             if self.db_thread:
                 self.db_thread.add_task(lambda:TorrentDBHandler.getInstance().selectTorrentToCheck(infohash=self.infohash, return_value=return_value))
             else:
                 TorrentDBHandler.getInstance().selectTorrentToCheck(infohash=self.infohash, return_value=return_value)
         event.wait(60.0)
         
         torrent = return_value['torrent']
         if DEBUG:
             print >> sys.stderr, time.asctime(),'-', "Torrent Checking: get value from DB:", torrent
         
         if not torrent:
             return
 
         if self.infohash is None and torrent['ignored_times'] > 0:
             if DEBUG:
                 print >> sys.stderr, time.asctime(),'-', 'Torrent_checking: torrent: %s' % torrent
             kw = { 'ignored_times': torrent['ignored_times']-1 }
             if self.db_thread:
                 self.db_thread.add_task(lambda:
                     TorrentDBHandler.getInstance().updateTracker(torrent['infohash'], kw))
             else:
                 TorrentDBHandler.getInstance().updateTracker(torrent['infohash'], kw)
             return
 
         # may be block here because the internet IO
         torrent = self.readTorrent(torrent)    # read the torrent 
         if 'info' not in torrent:    #torrent has been deleted
             if self.db_thread:
                 self.db_thread.add_task(lambda:
                     TorrentDBHandler.getInstance().deleteTorrent(torrent['infohash']))
             else:
                 TorrentDBHandler.getInstance().deleteTorrent(torrent['infohash'])
             return
         
         # TODO: tracker checking also needs to be update
         if DEBUG:
             print >> sys.stderr, time.asctime(),'-', "Tracker Checking"
         trackerChecking(torrent)
         
         # Must come after tracker check, such that if tracker dead and DHT still alive, the
         # status is still set to good
         self.mldhtchecker.lookup(torrent['infohash'])
         
         self.updateTorrentInfo(torrent)            # set the ignored_times
         
         kw = {
             'last_check_time': int(time()),
             'seeder': torrent['seeder'],
             'leecher': torrent['leecher'],
             'status': torrent['status'],
             'ignored_times': torrent['ignored_times'],
             'retried_times': torrent['retried_times'],
             #'info': torrent['info']
             }
         
         if DEBUG:
             print >> sys.stderr, time.asctime(),'-', "Torrent Checking: selectTorrentToCheck:", kw
         
         if self.db_thread:
             self.db_thread.add_task(lambda:
                 TorrentDBHandler.getInstance().updateTorrent(torrent['infohash'], **kw))
         else:
             TorrentDBHandler.getInstance().updateTorrent(torrent['infohash'], **kw)
     finally:
         if not self.db_thread:
             TorrentDBHandler.getInstance().close()
Exemple #19
0
 def __init__(self):
     if RemoteTorrentHandler.__single:
         raise RuntimeError, "RemoteTorrentHandler is singleton"
     RemoteTorrentHandler.__single = self
     self.torrent_db = TorrentDBHandler.getInstance()
     self.requestedtorrents = {}