def run_browser(self):
configpath = expanduser("~/.dockerproxy.conf")
logging.debug(configpath)
if os.path.isfile(configpath):
config = SafeConfigParser()
config.read(configpath)
httphandler = config.get('browser','httphandler')
if "chrome" in httphandler:
defaultbrowserpath = self.CHROMEPATH
elif "firefox" in httphandler:
defaultbrowserpath = self.FIREFOXPATH
elif "safari" in httphandler:
defaultbrowserpath = self.SAFARIPATH
else:
# *shrug* you're using something else
defaultbrowserpath = self.SAFARIPATH
#attempt to avoid cmd & arg injection
defaultbrowserpath += " {}"
cmd = shlex.split(defaultbrowserpath.format(pipes.quote(self.url)))
if self.DEBUG:
logging.debug("### Invoking: " + str(cmd))
result = Popen(cmd, shell=False, env=self.ENVIRONMENT, stdin=None, stdout=None, stderr=None, close_fds=True, preexec_fn=os.setpgrp)
# need to give the process a little time to load before exiting :)
time.sleep(2)
sys.exit(0)
else:
tkMessageBox.showinfo("Error", "Config file does not exist")
评论列表
文章目录