Exemple #1
0
    def __init__(self):
        wx.EvtHandler.__init__(self)
        SafeInvocation.__init__(self)
        
        utility.queue = self
        
        utility.actionhandler = ActionHandler()
        self.ratemanager = RateManager()
        self.addtorrents = AddTorrents()

        self.timers = {}
        
        self.doneflag = Event()

        self.totals = { 'up' : 0.0, 
                        'down' : 0.0, 
                        'connections': 0 }

        self.totals_kb = { 'up': 0.0, 
                           'down': 0.0 }

        self.volume = {'up': utility.config.Read('uploadvolume', "int"),
                       'down': utility.config.Read('downloadvolume', "int") }
        
        self.whenidle = 0   # 0=Nothing, 1=Close, 2=Shutdown
        self.lastDirScan = 0
        self.lastScrape = 0
        
        self.UpdateRunningTorrentCounters()
Exemple #2
0
    def __init__(self, textCtrl):
        wx.PyLog.__init__(self)
        wx.EvtHandler.__init__(self)
        SafeInvocation.__init__(self)

        self.doneflag = Event()
        self.tc = textCtrl
        self.enabledFileLogger(utility.config.Read('filelogger', "boolean"))
Exemple #3
0
    def __init__(self, parent):

        # Initialization
        self.doneflag = Event()
        SafeInvocation.__init__(self)
        
        # Main management
        self.feeds = []
        self.rules = []
        self.history = {}
        
        # Set up config
        self.config = ConfigManager(self)

        # html scanner threads
        self.htmlscanners = {}

        # timer
        self.timer = wx.Timer(self, -1)
        self.timerCount = -1
        self.Bind(wx.EVT_TIMER, self.onTimer)
Exemple #4
0
    def __init__(self, ID, params):
        """
        Initialize the main frame
        """
        utility.frame = self
        self.doneflag = Event()

        title = product_name + " " + version_short
        size, position = self._getWindowSettings()
        wx.Frame.__init__(self, None, ID, title, position, size, name = "MainFrame")
        SafeInvocation.__init__(self)

        #if wx.Platform == "__WXMSW__":
        #    if wx.GetApp().GetComCtl32Version() >= 600 and wx.DisplayDepth() >= 32:
        #        wx.SystemOptions.SetOptionInt("msw.remap", 2)
        #if wx.Platform == "__WXMAC__":
            #wx.SystemOptions.SetOptionInt("mac.listctrl.always_use_generic", 1)
            #self.SetExtraStyle(wx.FRAME_EX_METAL)

        # Don't update GUI as often when iconized
        self.GUIupdate = True

        # Set Application icon
        try:
            self.SetIcon(utility.icon)
        except:
            pass
        
        #######################################################
        # Main GUI stuff
        #######################################################

        # Scheduler
        ##############
        utility.queue  = Scheduler()
        
        # StatusBar
        ##############
        self.SetStatusBar(StatusBar(self))

        # MenuBar
        ##############
        self.SetMenuBar(MenuBar(self))

        # TaskBar icon
        ##############
        try:
            self.tbicon = TaskBarIcon(self)
        except:
            self.tbicon = None

        # Main Panel 
        ##############
        self.window = MainPanel(self)

        # Pref. Frame
        ##############
        self.preferences = None

        # ToolBar
        ##############
        self.tb = MainToolBar(self)
        self.SetToolBar(self.tb)
        
        # Command Scheduler
        ##############
        self.commandScheduler = CommandScheduler()

        # Win Settings  
        ##############
        self._loadWindowSettings()

        # Update Menu
        ##############
        self.updateMenuChecks()

        wx.LogMessage('GUI loaded')
        
        # Hot Key
        ############## 
        if wx.Platform == "__WXMSW__":
            self.openwin = []
            self.modaldlg = {}
            utility.hotkey = {"ID": wx.NewId(),
                              "modifiers": utility.config.Read('hotkeymod', "int"),
                              "keys": utility.config.Read('hotkeykeycode', "int"),
                              "wxkeycode": utility.config.Read('hotkeywxkeycode', "int"),
                              "current": {"modifiers": None,
                                          "keys": None,
                                          "wxkeycode": None},
                              "active": False,
                              "hiding": False}
            
            if utility.config.Read('hotkey', "boolean"):
                utility.hotkey["current"]["modifiers"] = utility.hotkey["modifiers"]
                utility.hotkey["current"]["keys"] = utility.hotkey["keys"]
                utility.hotkey["current"]["wxkeycode"] = utility.hotkey["wxkeycode"]     
                self.RegisterHotKey(utility.hotkey["ID"], utility.hotkey["modifiers"], utility.hotkey["keys"])
                utility.hotkey["active"] = True

        #######################################################
        # Events Table
        #######################################################
        self.Bind(wx.EVT_QUERY_END_SESSION, self.OnCloseWindow)
        self.Bind(wx.EVT_END_SESSION, self.OnCloseWindow)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_ICONIZE, self.onIconify)
        self.Bind(wx.EVT_SIZE, self.onSize)
        self.Bind(wx.EVT_SHOW, self.onShow)
        if wx.Platform == "__WXMSW__":
            self.Bind(wx.EVT_HOTKEY, self.HotKeyDown, id = utility.hotkey["ID"])
            self.Bind(wx.EVT_SYS_COLOUR_CHANGED, self.OnSysColourChange)
        if wx.Platform == "__WXMAC__":
            self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
        
        # Accelerator Table
        fsID = wx.NewId()
        self.Bind(wx.EVT_MENU, self.onFullScreen, id = fsID)
        accelTable = wx.AcceleratorTable([(wx.ACCEL_NORMAL, wx.WXK_F11, fsID)])
        self.SetAcceleratorTable(accelTable)

        #######################################################
        # Set Up Filter Manager
        #######################################################
        utility.ipfilter = FilterManager()
        if utility.ipfilter:
            wx.LogMessage('Filter Manager: %d IP ranges loaded' % len(utility.ipfilter))
        #######################################################
        # Start the controller
        #######################################################
        utility.controller = LaunchMany()
        utility.controller.start()
        utility.queue.postInitTasks()
        wx.LogMessage('Controller loaded and started')

        #######################################################
        # Start DHT
        #######################################################
        if utility.dht:
            utility.dht.start()
            wx.LogMessage('DHT loaded')
            
        #######################################################
        # Set Up Label Manager
        #######################################################
        utility.labelmanager = LabelManager()
        
        #######################################################
        # Web Service
        #######################################################
        if WEBSERVICE:
            WebService()
        else:
            wx.LogMessage(_("Web Service disabled: Please download wsgiref or update to Python 2.5")) 

        #######################################################
        # Startup params
        #######################################################
        for param in params:
            wx.GetApp().MacOpenFile(param)  # Yes, even if the platform isn't Mac

        #######################################################
        # Check For Update
        #######################################################
        if utility.config.Read('checkforupdates', "boolean"):
            utility.actions[ACTION_UPDATECHECK].action()
            
        self.Show(True)
        
        # Check to see if ABC is associated with torrents
        #######################################################
        if (sys.platform[:3] == 'win') and \
           utility.config.Read('associate', "boolean") and \
           not utility.regchecker.testRegistry():
            dialog = RegCheckDialog(self)
            dialog.ShowModal()
            dialog.Destroy()
Exemple #5
0
    def __init__(self, torrent, myid):
        wx.EvtHandler.__init__(self)
        SafeInvocation.__init__(self)
        self.doneflag = Event()
        
        self.torrent = torrent

        self.downsize = { 'old' : self.torrent.files.downsize, 
                          'new' : 0.0,
                          'prev': 0.0 }
        self.upsize = { 'old' : self.torrent.files.upsize, 
                        'new' : 0.0,
                        'prev': 0.0 }
        
        self.spewwait = time()

        self.reannouncelast = 0

        self.timers = { 'lastupload': time(), 
                        'lastdownload': time(),
                        'infrequent': None }

        self.btstatus = _('waiting')
        self.progress = self.torrent.files.progress
        self.sizeDone = self.torrent.files.sizeDone
        
        self.eta = None
        self.elapsed = ""
        self.rate = { "down" : 0.0, 
                      "up" : 0.0 }

        self.numpeers = 0
        self.numseeds = 0

        self.numconnections = 0
        self.numcopies = None
        self.peeravg = None
        self.totalspeed = 0.0
        self.curtracker = None
        self.numerrortracker=0
        self.lasterrortracker=0
        
        # What is the current rate set at?
        self.ratesetting = {}
        self.ratesetting['up'] = 0.0
        self.ratesetting['down'] = 0.0
        
        self.seedingtimelastcheck = None

        # To compute mean over several last values of uprate/downrate        
        self.pastrate = { "down" : [0.0] * 20, 
                          "up" : [0.0] * 20 }
        self.meanrate = { "down" : 0.0, 
                          "up" : 0.0 }
                     
        # Keep track of if we have any connections
        self.hasConnections = False
        
        # New stuff....

        self.controller = utility.controller
        
        self.waiting = True
        self.checking = False
        self.working = False
        self.seed = False
        self.closed = False

        self.hadextern = False

        
        self.start_time = 0
        
        self.status_err = ['']
        self.status_errtime = 0
        self.status_done = 0.0
                
        self.response = self.torrent.metainfo
        hash = unhexlify(self.torrent.infohash)

        self.rawserver = self.controller.handler.newRawServer(hash, self.doneflag)
        
        btconfig = utility.getBTParams()

        self.dow = BT1Download(self.display, 
                               self.finished,
                               self.unfinished,
                               self.error, 
                               self.error, # Use this rather than controller.exchandler
                               self.info,
                               self.doneflag, 
                               btconfig,
                               self.response, 
                               hash, 
                               myid, 
                               self.rawserver, 
                               self.controller.listen_port,
                               utility.configdir,
                               private = self.torrent.private,
                               dht = utility.dht,
                               ipfilter = utility.ipfilter.filter)
    def __init__(self, parent, d, announce, params, filelist):
        wx.EvtHandler.__init__(self)
        SafeInvocation.__init__(self)
        self.doneflag = Event()

        self.d = d
        self.a = announce
        self.filelist = filelist
        self.params = params
        self.parent = parent
        self.separatetorrents = False
        self.generatedfiles = []
        
        # See if we need to get md5sums for each file
        if 'gethash' in params:
            self.gethash = params['gethash']
        else:
            self.gethash = None
            
        # Can remove it from params before we pass things on
        if 'gethash' in params:
            del params['gethash']

        if isdir(d):
            self.choicemade = Event()
            frame = wx.Frame(None, -1, _('Make Torrent'), size = (1, 1))
            self.frame = frame
            panel = wx.Panel(frame, -1)
            gridSizer = wx.FlexGridSizer(cols = 1, vgap = 8, hgap = 8)
            gridSizer.AddGrowableRow(1)
            gridSizer.Add(wx.StaticText(panel, -1, 
                           _('Do you want to make a separate .torrent\nfor every item in this directory?')),
                           0, wx.ALIGN_CENTER)
            gridSizer.Add(wx.StaticText(panel, -1, ''))

            b = wx.FlexGridSizer(cols = 3, hgap = 10)
            yesbut = wx.Button(panel, -1, _('Yes'))
            def saidyes(e, self = self):
                self.frame.Destroy()
                self.separatetorrents = True
                self.begin()
            wx.EVT_BUTTON(frame, yesbut.GetId(), saidyes)
            b.Add(yesbut, 0)

            nobut = wx.Button(panel, -1, _('No'))
            def saidno(e, self = self):
                self.frame.Destroy()
                self.begin()
            wx.EVT_BUTTON(frame, nobut.GetId(), saidno)
            b.Add(nobut, 0)

            cancelbut = wx.Button(panel, -1, _('Cancel'))
            def canceled(e, self = self):
                self.frame.Destroy()                
            wx.EVT_BUTTON(frame, cancelbut.GetId(), canceled)
            b.Add(cancelbut, 0)
            gridSizer.Add(b, 0, wx.ALIGN_CENTER)
            border = wx.BoxSizer(wx.HORIZONTAL)
            border.Add(gridSizer, 1, wx.EXPAND | wx.ALL, 4)
            
            panel.SetSizerAndFit(border)
            panel.SetAutoLayout(True)
            frame.Show()
            border.Fit(panel)
            frame.Fit()
        else:
            self.begin()