⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configreader.py

📁 ABC-win32-v3.1 一个P2P软源代码
💻 PY
📖 第 1 页 / 共 4 页
字号:
            datasizer.Add(StaticText('Max peer connections:'), 1, wxALIGN_CENTER_VERTICAL)
            datasizer.Add(self.maxconnections_data)
            datasizer.Add(StaticText('Default seeding mode:'), 1, wxALIGN_CENTER_VERTICAL)
            datasizer.Add(self.superseeder_data)
            datasizer.Add(StaticText('Expire resume data(days):'), 1, wxALIGN_CENTER_VERTICAL)
            datasizer.Add(self.expirecache_data)
            
            twocolsizer.Add(datasizer)
    
            infosizer = wxFlexGridSizer(cols = 1)
            self.hinttext = StaticText('', self.FONT, False, 'Blue')
            infosizer.Add(self.hinttext, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL)
            infosizer.SetMinSize((180, 100))
            twocolsizer.Add(infosizer, 1, wxEXPAND)
    
            colsizer.Add(twocolsizer)
    
            savesizer = wxGridSizer(cols = 3, hgap = 20)
            okButton = wxButton(panel, -1, 'OK')
    #        okButton.SetFont(self.default_font)
            savesizer.Add(okButton, 0, wxALIGN_CENTER)
    
            cancelButton = wxButton(panel, -1, 'Cancel')
    #        cancelButton.SetFont(self.default_font)
            savesizer.Add(cancelButton, 0, wxALIGN_CENTER)
    
            defaultsButton = wxButton(panel, -1, 'Revert to Defaults')
    #        defaultsButton.SetFont(self.default_font)
            savesizer.Add(defaultsButton, 0, wxALIGN_CENTER)
            colsizer.Add(savesizer, 1, wxALIGN_CENTER)
    
            resizewarningtext=StaticText('None of these settings will take effect until the next time you start BitTorrent', self.FONT-2)
            colsizer.Add(resizewarningtext, 1, wxALIGN_CENTER)
    
            border = wxBoxSizer(wxHORIZONTAL)
            border.Add(colsizer, 1, wxEXPAND | wxALL, 4)
            
            panel.SetSizer(border)
            panel.SetAutoLayout(True)
    
            def setDefaults(evt, self = self):
                try:
                    self.ip_data.SetValue(self.defaults['ip'])
                    self.bind_data.SetValue(self.defaults['bind'])
                    if sys.version_info >= (2, 3) and socket.has_ipv6:
                        self.ipv6bindsv4_data.SetSelection(self.defaults['ipv6_binds_v4'])
                    self.minpeers_data.SetValue(self.defaults['min_peers'])
                    self.displayinterval_data.SetValue(int(self.defaults['display_interval']*1000))
                    self.alloctype_data.SetStringSelection(self.defaults['alloc_type'])
                    self.allocrate_data.SetValue(int(self.defaults['alloc_rate']))
                    if self.defaults['lock_files']:
                        if self.defaults['lock_while_reading']:
                            self.locking_data.SetSelection(2)
                        else:
                            self.locking_data.SetSelection(1)
                    else:
                        self.locking_data.SetSelection(0)
                    if self.defaults['double_check']:
                        if self.defaults['triple_check']:
                            self.doublecheck_data.SetSelection(2)
                        else:
                            self.doublecheck_data.SetSelection(1)
                    else:
                        self.doublecheck_data.SetSelection(0)
                    setval = self.defaults['max_files_open']
                    if setval == 0:
                        setval = 'no limit '
                    else:
                        setval = str(setval)
                    if not setval in self.maxfilesopen_choices:
                        setval = self.maxfilesopen_choices[0]
                    self.maxfilesopen_data.SetStringSelection(setval)
                    setval = self.defaults['max_connections']
                    if setval == 0:
                        setval = 'no limit '
                    else:
                        setval = str(setval)
                    if not setval in self.maxconnections_choices:
                        setval = self.maxconnections_choices[0]
                    self.maxconnections_data.SetStringSelection(setval)
                    self.superseeder_data.SetSelection(int(self.defaults['super_seeder']))
                    setval = self.defaults['expire_cache_data']
                    if setval == 0:
                        setval = 'never '
                    else:
                        setval = str(setval)
                    if not setval in self.expirecache_choices:
                        setval = self.expirecache_choices[0]
                    self.expirecache_data.SetStringSelection(setval)
                except:
                    self.parent.exception()
    
            def saveConfigs(evt, self = self):
                try:
                    self.advancedConfig['ip'] = self.ip_data.GetValue()
                    self.advancedConfig['bind'] = self.bind_data.GetValue()
                    if sys.version_info >= (2, 3) and socket.has_ipv6:
                        self.advancedConfig['ipv6_binds_v4'] = self.ipv6bindsv4_data.GetSelection()
                    self.advancedConfig['min_peers'] = self.minpeers_data.GetValue()
                    self.advancedConfig['display_interval'] = float(self.displayinterval_data.GetValue())/1000
                    self.advancedConfig['alloc_type'] = self.alloctype_data.GetStringSelection()
                    self.advancedConfig['alloc_rate'] = float(self.allocrate_data.GetValue())
                    self.advancedConfig['lock_files'] = int(self.locking_data.GetSelection() >= 1)
                    self.advancedConfig['lock_while_reading'] = int(self.locking_data.GetSelection() > 1)
                    self.advancedConfig['double_check'] = int(self.doublecheck_data.GetSelection() >= 1)
                    self.advancedConfig['triple_check'] = int(self.doublecheck_data.GetSelection() > 1)
                    try:
                        self.advancedConfig['max_files_open'] = int(self.maxfilesopen_data.GetStringSelection())
                    except:       # if it ain't a number, it must be "no limit"
                        self.advancedConfig['max_files_open'] = 0
                    try:
                        self.advancedConfig['max_connections'] = int(self.maxconnections_data.GetStringSelection())
                        self.advancedConfig['max_initiate'] = min(
                            2*self.advancedConfig['min_peers'], self.advancedConfig['max_connections'])
                    except:       # if it ain't a number, it must be "no limit"
                        self.advancedConfig['max_connections'] = 0
                        self.advancedConfig['max_initiate'] = 2*self.advancedConfig['min_peers']
                    self.advancedConfig['super_seeder']=int(self.superseeder_data.GetSelection())
                    try:
                        self.advancedConfig['expire_cache_data'] = int(self.expirecache_data.GetStringSelection())
                    except:
                        self.advancedConfig['expire_cache_data'] = 0
                    self.advancedMenuBox.Close()
                except:
                    self.parent.exception()
    
            def cancelConfigs(evt, self = self):            
                self.advancedMenuBox.Close()
    
            def ip_hint(evt, self = self):
                self.hinttext.SetLabel('\n\n\nThe IP reported to the tracker.\n' +
                                      'unless the tracker is on the\n' +
                                      'same intranet as this client,\n' +
                                      'the tracker will autodetect the\n' +
                                      "client's IP and ignore this\n" +
                                      "value.")
    
            def bind_hint(evt, self = self):
                self.hinttext.SetLabel('\n\n\nThe IP the client will bind to.\n' +
                                      'Only useful if your machine is\n' +
                                      'directly handling multiple IPs.\n' +
                                      "If you don't know what this is,\n" +
                                      "leave it blank.")
    
            def ipv6bindsv4_hint(evt, self = self):
                self.hinttext.SetLabel('\n\n\nCertain operating systems will\n' +
                                      'open IPv4 protocol connections on\n' +
                                      'an IPv6 socket; others require you\n' +
                                      "to open two sockets on the same\n" +
                                      "port, one IPv4 and one IPv6.")
    
            def minpeers_hint(evt, self = self):
                self.hinttext.SetLabel('\n\n\nThe minimum number of peers the\n' +
                                      'client tries to stay connected\n' +
                                      'with.  Do not set this higher\n' +
                                      'unless you have a very fast\n' +
                                      "connection and a lot of system\n" +
                                      "resources.")
    
            def displayinterval_hint(evt, self = self):
                self.hinttext.SetLabel('\n\n\nHow often to update the\n' +
                                      'graphical display, in 1/1000s\n' +
                                      'of a second. Setting this too low\n' +
                                      "will strain your computer's\n" +
                                      "processor and video access.")
    
            def alloctype_hint(evt, self = self):
                self.hinttext.SetLabel('\n\nHow to allocate disk space.\n' +
                                      'normal allocates space as data is\n' +
                                      'received, background also adds\n' +
                                      "space in the background, pre-\n" +
                                      "allocate reserves up front, and\n" +
                                      'sparse is only for filesystems\n' +
                                      'that support it by default.')
    
            def allocrate_hint(evt, self = self):
                self.hinttext.SetLabel('\n\n\nAt what rate to allocate disk\n' +
                                      'space when allocating in the\n' +
                                      'background.  Set this too high on a\n' +
                                      "slow filesystem and your download\n" +
                                      "will slow to a crawl.")
    
            def locking_hint(evt, self = self):
                self.hinttext.SetLabel('\n\n\n\nFile locking prevents other\n' +
                                      'programs (including other instances\n' +
                                      'of BitTorrent) from accessing files\n' +
                                      "you are downloading.")
    
            def doublecheck_hint(evt, self = self):
                self.hinttext.SetLabel('\n\n\nHow much extra checking to do\n' +
                                      'making sure no data is corrupted.\n' +
                                      'Double-check mode uses more CPU,\n' +
                                      "while triple-check mode increases\n" +
                                      "disk accesses.")
    
            def maxfilesopen_hint(evt, self = self):
                self.hinttext.SetLabel('\n\n\nThe maximum number of files to\n' +
                                      'keep open at the same time.  Zero\n' +
                                      'means no limit.  Please note that\n' +
                                      "if this option is in effect,\n" +
                                      "files are not guaranteed to be\n" +
                                      "locked.")
    
            def maxconnections_hint(evt, self = self):
                self.hinttext.SetLabel('\n\nSome operating systems, most\n' +
                                      'notably Windows 9x/ME combined\n' +
                                      'with certain network drivers,\n' +
                                      "cannot handle more than a certain\n" +
                                      "number of open ports.  If the\n" +
                                      "client freezes, try setting this\n" +
                                      "to 60 or below.")
    
            def superseeder_hint(evt, self = self):
                self.hinttext.SetLabel('\n\nThe "super-seed" method allows\n' +
                                      'a single source to more efficiently\n' +
                                      'seed a large torrent, but is not\n' +
                                      "necessary in a well-seeded torrent,\n" +
                                      "and causes problems with statistics.\n" +
                                      "Unless you routinely seed torrents\n" +
                                      "you can enable this by selecting\n" +
                                      '"SUPER-SEED" for connection type.\n' +
                                      '(once enabled it does not turn off.)')
    
            def expirecache_hint(evt, self = self):
                self.hinttext.SetLabel('\n\nThe client stores temporary data\n' +
                                      'in order to handle downloading only\n' +
                                      'specific files from the torrent and\n' +
                                      "so it can resume downloads more\n" +
                                      "quickly.  This sets how long the\n" +
                                      "client will keep this data before\n" +
                                      "deleting it to free disk space.")
    
            EVT_BUTTON(self.advancedMenuBox, okButton.GetId(), saveConfigs)
            EVT_BUTTON(self.advancedMenuBox, cancelButton.GetId(), cancelConfigs)
            EVT_BUTTON(self.advancedMenuBox, defaultsButton.GetId(), setDefaults)
            EVT_ENTER_WINDOW(self.ip_data, ip_hint)
            EVT_ENTER_WINDOW(self.bind_data, bind_hint)
            if sys.version_info >= (2, 3) and socket.has_ipv6:
                EVT_ENTER_WINDOW(self.ipv6bindsv4_data, ipv6bindsv4_hint)
            EVT_ENTER_WINDOW(self.minpeers_data, minpeers_hint)
            EVT_ENTER_WINDOW(self.displayinterval_data, displayinterval_hint)
            EVT_ENTER_WINDOW(self.alloctype_data, alloctype_hint)
            EVT_ENTER_WINDOW(self.allocrate_data, allocrate_hint)
            EVT_ENTER_WINDOW(self.locking_data, locking_hint)
            EVT_ENTER_WINDOW(self.doublecheck_data, doublecheck_hint)
            EVT_ENTER_WINDOW(self.maxfilesopen_data, maxfilesopen_hint)
            EVT_ENTER_WINDOW(self.maxconnections_data, maxconnections_hint)
            EVT_ENTER_WINDOW(self.superseeder_data, superseeder_hint)
            EVT_ENTER_WINDOW(self.expirecache_data, expirecache_hint)
    
            self.advancedMenuBox.Show()
            border.Fit(panel)
            self.advancedMenuBox.Fit()
        except:
            self.parent.exception()


    def CloseAdvanced(self):
        if self.advancedMenuBox is not None:
            try:
                self.advancedMenuBox.Close()
            except wxPyDeadObjectError, e:
                self.advancedMenuBox = None

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -