def initialise_encryption_key(self): import uuid uid = uuid.uuid4() self.enc_passwd = uid.hex try: with os.fdopen(os.open(self.key_file, os.O_WRONLY | os.O_CREAT, 0600), 'w') as f: f.write(self.enc_passwd) except: msgbox("Error initialising key_file")
def load_encryption_key(self): try: if os.path.exists(self.key_file): with open(self.key_file) as f: self.enc_passwd = f.read() else: self.initialise_encryption_key() except: msgbox("Error trying to open key_file") vars.enc_passwd = ''
def initialise_encryption_key(self): import uuid uid = uuid.uuid4() self.enc_passwd = uid.hex try: with os.fdopen( os.open(self.key_file, os.O_WRONLY | os.O_CREAT, 0600), 'w') as f: f.write(self.enc_passwd) except: msgbox("Error initialising key_file")
def mode0(): nr = gl.get_value("nr") nc = gl.get_value("nc") poij = gl.get_value("poij") lmij = gl.get_value("lmij") rkij = gl.get_value("rkij") print(nr, nc) m = Map(int(nr), int(nc)) m.set_obstacle(utils.set_obstacle(rkij)) start = m.map[poij[0] - 1][poij[1] - 1] end = m.map[lmij[0] - 1][lmij[1] - 1] gl.set_value("end", end) dstar = Dstar(m) dstar.run(start, end) utils.msgbox()
def on_btnAdd_clicked(self, widget, *args): local = self.txtLocalPort.get_text().strip() host = self.txtRemoteHost.get_text().strip() remote = self.txtRemotePort.get_text().strip() if self.chkDynamic.get_active(): host = '*' remote = '*' # Validar datos del tunel if host == "": msgbox(_("Enter remote host")) return for x in self.treeModel: if x[0] == local: msgbox(_("Local port already assigned")) return tunel = self.treeModel.append([local, host, remote, '%s:%s:%s' % (local, host, remote)])
def rig1(): if gl.get_value("if_escape") == True: utils.move(2, -1, 1) utils.msgbox_escape() utils.rk_follow() utils.msgbox_escape() else: if gl.get_value("if_start") == False: utils.move(gl.get_value("sel_role"), -1, 1) else: if gl.get_value("MODE") == 2: utils.move(gl.get_value("sel_role"), -1, 1) utils.loop_role() utils.msgbox() elif gl.get_value("MODE") == 1: xx = gl.get_value("xx") yy = gl.get_value("yy") r = random.randint(0, 7) utils.move(1, -1, 1) utils.move(0, xx[r], yy[r]) utils.msgbox()
def on_btnAdd_clicked(self, widget, *args): local = self.txtLocalPort.get_text().strip() host = self.txtRemoteHost.get_text().strip() remote = self.txtRemotePort.get_text().strip() if self.chkDynamic.get_active(): host = '*' remote = '*' # Validar datos del tunel if host == "": msgbox(_("Enter remote host")) return for x in self.treeModel: if x[0] == local: msgbox(_("Local port already assigned")) return tunel = self.treeModel.append( [local, host, remote, '%s:%s:%s' % (local, host, remote)])
def on_okbutton1_clicked(self, widget, *args): group = self.cmbGroup.get_active_text().strip() name = self.txtName.get_text().strip() description = self.txtDescription.get_text().strip() host = self.txtHost.get_text().strip() ctype = self.cmbType.get_active_text().strip() user = self.txtUser.get_text().strip() password = self.txtPass.get_text().strip() private_key = self.txtPrivateKey.get_text().strip() port = self.txtPort.get_text().strip() buf = self.txtCommands.get_buffer() commands = buf.get_text(buf.get_start_iter(), buf.get_end_iter( )).strip() if self.chkCommands.get_active() else "" keepalive = self.txtKeepAlive.get_text().strip() if self.get_widget("chkDefaultColors").get_active(): fcolor = "" bcolor = "" else: fcolor = self.btnFColor.selected_color bcolor = self.btnBColor.selected_color x11 = self.chkX11.get_active() agent = self.chkAgent.get_active() compression = self.chkCompression.get_active() compressionLevel = self.txtCompressionLevel.get_text().strip() extra_params = self.txtExtraParams.get_text() log = self.chkLogging.get_active() backspace_key = self.cmbBackspace.get_active() delete_key = self.cmbDelete.get_active() if ctype == "": ctype = "ssh" tunnel = "" if ctype == "ssh": for x in self.treeModel: tunnel = '%s,%s' % (x[3], tunnel) tunnel = tunnel[:-1] # Validar datos if group == "" or name == "" or (host == "" and ctype != 'local'): msgbox(_("Fields group, name and host are required")) return if not (port and port.isdigit() and 1 <= int(port) <= 65535): msgbox(_("Invalid port")) return host = Host(group, name, description, host, user, password, private_key, port, tunnel, ctype, commands, keepalive, fcolor, bcolor, x11, agent, compression, compressionLevel, extra_params, log, backspace_key, delete_key) try: # Guardar if not group not in self.config.groups: self.config.groups[group] = [] if self.isNew: for h in self.config.groups[group]: if h.name == name: msgbox("%s [%s] %s [%s]" % (_("Host name"), name, _("already exists for group"), group)) return # agregar host a grupo self.config.groups[group].append(host) else: if self.oldGroup != group: # revisar que no este el nombre en el nuevo grupo if not group not in self.config.groups: self.config.groups[group] = [host] else: for h in self.config.groups[group]: if h.name == name: msgbox("%s [%s] %s [%s]" % (_("Host name"), name, _("already exists for group"), group)) return self.config.groups[group].append(host) for h in self.config.groups[self.oldGroup]: if h.name == self.oldName: self.config.groups[self.oldGroup].remove(h) break else: if self.oldName != name: for h in self.config.groups[self.oldGroup]: if h.name == name: msgbox("%s [%s] %s [%s]" % (_("Host name"), name, _("already exists for group"), group)) return for h in self.config.groups[self.oldGroup]: if h.name == self.oldName: index = self.config.groups[ self.oldGroup].index(h) self.config.groups[self.oldGroup][index] = host break else: for h in self.config.groups[self.oldGroup]: if h.name == self.oldName: index = self.config.groups[ self.oldGroup].index(h) self.config.groups[self.oldGroup][index] = host break except: traceback.print_exc() msgbox("%s [%s]" % (_("Error saving host. Description"), sys.exc_info()[1])) self.config.writeConfig() self.get_widget("wHost").destroy()
def on_okbutton1_clicked(self, widget, *args): group = self.cmbGroup.get_active_text().strip() name = self.txtName.get_text().strip() description = self.txtDescription.get_text().strip() host = self.txtHost.get_text().strip() ctype = self.cmbType.get_active_text().strip() user = self.txtUser.get_text().strip() password = self.txtPass.get_text().strip() private_key = self.txtPrivateKey.get_text().strip() port = self.txtPort.get_text().strip() buf = self.txtCommands.get_buffer() commands = buf.get_text(buf.get_start_iter(), buf.get_end_iter()).strip() if self.chkCommands.get_active() else "" keepalive = self.txtKeepAlive.get_text().strip() if self.get_widget("chkDefaultColors").get_active(): fcolor = "" bcolor = "" else: fcolor = self.btnFColor.selected_color bcolor = self.btnBColor.selected_color x11 = self.chkX11.get_active() agent = self.chkAgent.get_active() compression = self.chkCompression.get_active() compressionLevel = self.txtCompressionLevel.get_text().strip() extra_params = self.txtExtraParams.get_text() log = self.chkLogging.get_active() backspace_key = self.cmbBackspace.get_active() delete_key = self.cmbDelete.get_active() if ctype == "": ctype = "ssh" tunnel = "" if ctype == "ssh": for x in self.treeModel: tunnel = '%s,%s' % (x[3], tunnel) tunnel = tunnel[:-1] # Validar datos if group == "" or name == "" or (host == "" and ctype != 'local'): msgbox(_("Fields group, name and host are required")) return if not (port and port.isdigit() and 1 <= int(port) <= 65535): msgbox(_("Invalid port")) return host = Host(group, name, description, host, user, password, private_key, port, tunnel, ctype, commands, keepalive, fcolor, bcolor, x11, agent, compression, compressionLevel, extra_params, log, backspace_key, delete_key) try: # Guardar if not group not in self.config.groups: self.config.groups[group] = [] if self.isNew: for h in self.config.groups[group]: if h.name == name: msgbox("%s [%s] %s [%s]" % (_("Host name"), name, _("already exists for group"), group)) return # agregar host a grupo self.config.groups[group].append(host) else: if self.oldGroup != group: # revisar que no este el nombre en el nuevo grupo if not group not in self.config.groups: self.config.groups[group] = [host] else: for h in self.config.groups[group]: if h.name == name: msgbox("%s [%s] %s [%s]" % (_("Host name"), name, _("already exists for group"), group)) return self.config.groups[group].append(host) for h in self.config.groups[self.oldGroup]: if h.name == self.oldName: self.config.groups[self.oldGroup].remove(h) break else: if self.oldName != name: for h in self.config.groups[self.oldGroup]: if h.name == name: msgbox("%s [%s] %s [%s]" % (_("Host name"), name, _("already exists for group"), group)) return for h in self.config.groups[self.oldGroup]: if h.name == self.oldName: index = self.config.groups[self.oldGroup].index(h) self.config.groups[self.oldGroup][index] = host break else: for h in self.config.groups[self.oldGroup]: if h.name == self.oldName: index = self.config.groups[self.oldGroup].index(h) self.config.groups[self.oldGroup][index] = host break except: traceback.print_exc() msgbox("%s [%s]" % (_("Error saving host. Description"), sys.exc_info()[1])) self.config.writeConfig() self.get_widget("wHost").destroy()