def config(self):
return wx.Config.Get()
python类Config()的实例源码
def postrd(self, value, obj):
# cPickle expexts str but wx.Config returns unicode cPickle
# gives me a standard list which needs to be turned into our
# special MutableSequence
iterable = cPickle.loads(str(value))
return self.defclass(iterable=iterable, owner=self, instance=obj)
def _load_config(self):
# Handle legacy file location
if os.path.exists(self._legacy_dir):
print("Migrating config from legacy location")
shutil.move(self._legacy_dir, self.config_dir)
# Create the kicad bom manager folder if it doesn't already exist
if not os.path.exists(self.config_dir):
os.makedirs(self.config_dir)
self.filehistory = wx.FileHistory(8)
self.config = wx.Config("BOMsAway",
localFilename=self.config_file,
style=wx.CONFIG_USE_LOCAL_FILE)
self.filehistory.Load(self.config)
def main():
app = wx.App(False)
if len(sys.argv) >= 2 and sys.argv[1] == '-test':
config = wx.Config("padherder_proxy_test")
print "In test mode"
else:
config = wx.Config("padherder_proxy")
wx.ConfigBase.Set(config)
frame = MainWindow(None, "Padherder Proxy v%s" % PH_PROXY_VERSION)
host = config.Read("host") or socket.gethostbyname(socket.gethostname())
logger = dnsproxy.MyDNSLogger(frame.dns_tab)
thread.start_new_thread(dnsproxy.serveDNS, (logger, frame.main_tab, frame))
try:
app_config = proxy.ProxyConfig(port=8080, host=host)
app_server = ProxyServer(app_config)
app_master = dump.DumpMaster(app_server, dump.Options(app_host='mitm.it', app_port=80, app=True))
frame.app_master = app_master
thread.start_new_thread(app_master.run, ())
except:
evt = custom_events.wxStatusEvent(message='Error initalizing mitm proxy:\n' + traceback.format_exc() + '\n\nYou probably put in an incorrect IP address in Settings')
wx.PostEvent(frame.main_tab, evt)
app.MainLoop()