def applyoptions(self, temp_config): with open('%s/config_temp.json' % (HOMEDIR), 'w') as config: json.dump(temp_config, config) update_cmd = [ 'sudo', sys.executable, '-m', 'qomui.mv_config', '-d', '%s' % (HOMEDIR) ] update = Popen(update_cmd, stdin=PIPE, stdout=PIPE, universal_newlines=True) prompt = update.communicate("" + '\n')[1] if update.returncode == 0: print("Configuration successfully changed") self.qomui_service.load_firewall() try: if temp_config["bypass"] == 1: self.qomui_service.bypass(utils.get_user_group()) except KeyError: pass else: print("Configuration change failed") self.show_config(self.get_config())
def establish_connection(self, server): self.ovpn_dict = utils.create_server_dict(self.server_dict[server], self.protocol_dict) if self.hop_server_dict is not None: self.ovpn_dict.update({"hop": "2"}) else: self.ovpn_dict.update({"hop": "0"}) self.kill() self.qomui_service.connect_to_server(self.ovpn_dict) config = self.get_config() try: if config["bypass"] == 1: self.qomui_service.bypass(utils.get_user_group()) except KeyError: pass