def check_changes(self, widget, event): if self.not_validate: sys.exit(0) if self.core.current_var != None and self.core.current_var != self.core.var: if not self.changes_detected_dialog(): return True #Listamos lo que se ha publicado: COMMENT = [] apt_list = False list_apt_pub = [] for id in self.core.var['apt']: if self.core.var['apt'][id]['packages'] not in [ None, "", [], "[]" ]: apt_list = True for pkg in self.core.var['apt'][id]['packages']: list_apt_pub.append(pkg) if apt_list: COMMENT.append("APT:") COMMENT = COMMENT + list_apt_pub COMMENT.append("") if self.core.var['deb']['packages'] not in [None, "", [], "[]"]: COMMENT.append("DEB:") COMMENT = COMMENT + self.core.var['deb']['packages'] COMMENT.append("") if self.core.var['sh']['packages'] not in [None, "", [], "[]"]: COMMENT.append("EXECUTABLES:") pkg_list = [] for (pkg, md5) in self.core.var['sh']['packages']: pkg_list.append(pkg) COMMENT = COMMENT + pkg_list if self.core.var['epi']['packages'] not in [None, "", {}, "{}"]: COMMENT.append("ZMD:") pkg_list = [] for (pkg) in self.core.var['epi']['packages']: pkg_list.append(pkg) COMMENT = COMMENT + pkg_list COMMENT.append("") if self.core.var['update']['activate'] == "True": COMMENT.append("UPDATE: Sheduled from " + self.core.var['update']['url']) COMMENT.append("Minimum update version: " + (self.core.var['update']['version'])) #COMMENT.append(self.core.var['update']['url']) COMMENT.append("") if COMMENT not in [None, "", []]: COMMENT = '\n'.join(COMMENT) dialog = Dialog.InfoDialog( self.main_window, _("LliureX Remote Installer Summary"), _("You published this list to install:\n\n%s") % (COMMENT)) response = dialog.run() dialog.destroy() sys.exit(0)
def get_other_info(self): #discover the desktop session env_file = "/tmp/.first-aid-kit.%s" % self.current_user f = open(env_file) lines = f.readlines() f.close() os.remove(env_file) self.xwindows_access = True self.current_session = "plasma" for line in lines: if "DESKTOP_SESSION=" in line: self.current_session = line.split("=")[1].strip("\n") self.xwindows_access = True if not self.xwindows_access: self.current_session = False d = Dialog.InfoDialog( None, "First Aid Kit", "Sorry this user can't access to Xwindows,\nplease login with another one." ) d.run() d.destroy() sys.exit(1) #discover if you are a server lliurex_version = "/tmp/.FK.%s" % self.current_user os.system('lliurex-version -f > %s' % lliurex_version) #IS SERVER? if 'server' in open(lliurex_version).read(): self.server = True else: self.server = False os.remove(lliurex_version) os.system('lliurex-version > %s' % lliurex_version) #IS XENIAL? if '16.' in open(lliurex_version).read(): self.xenial = True self.restart_net = "systemctl restart networking" self.configure_net = "" else: self.xenial = False self.restart_net = "sleep 3" self.configure_net = "" os.remove(lliurex_version)
def close_fak(self, widget, event): try: if not self.core.working: Gtk.main_quit() else: mw = self.core.lri.main_window d = Dialog.InfoDialog( mw, "First Aid Kit", "You can't close First Aid Kit now\nbecause you are working with the system.\nPlease wait..." ) response = d.run() d.destroy() return True except Exception as e: return 0 self.core.dprint("(close_fak)Error: %s" % e, "[FirstAidKit]")
def uninstall_clicked(self,widget): try: #CANCEL OPERATION IF THIS KERNEL IS IN USE AT THE MOMENT OR KERNEL IS IN META LLIUREX kernel_file='/tmp/.uname' os.system('uname -r > %s'%kernel_file) f=open(kernel_file) lines=f.readlines() f.close() os.remove(kernel_file) for line in lines: if widget.label in line: mw=self.core.lri.main_window d=Dialog.InfoDialog(mw,_("First Aid Kit"),_("You can't delete this kernel because you are using now.")) response=d.run() d.destroy() self.core.dprint("You can't delete this kernel because you are using now: %s"%(widget.label),"[KernelBox]") self.update_kernels_button.set_sensitive(True) self.filter_kernels_button.set_sensitive(True) self.apply_kernel_button.set_sensitive(True) self.entry_kernel.set_can_focus(True) self.switch_kernel_installed.set_sensitive(True) return True # CANCEL OPERATION IF LLIUREX-META I AFFECTED WITH THIS OPERATION kernel_file='/tmp/.uname' os.system('LANG=C apt show linux-headers-generic > %s'%kernel_file) f=open(kernel_file) lines=f.readlines() f.close() os.remove(kernel_file) for line in lines: if 'Depends' in line: if widget.label in line: mw=self.core.lri.main_window a=_("First Aid Kit") b=_("You can't delete this kernel because is essential for LliureX.") d=Dialog.InfoDialog(mw,a,b) response=d.run() d.destroy() self.core.dprint("You can't delete this kernel because is essential for LliureX: %s"%(widget.label),"[KernelBox]") self.update_kernels_button.set_sensitive(True) self.filter_kernels_button.set_sensitive(True) self.apply_kernel_button.set_sensitive(True) self.entry_kernel.set_can_focus(True) self.switch_kernel_installed.set_sensitive(True) return True mw=self.core.lri.main_window a = _("First Aid Kit") b = _("Do you want to DELETE this kernel?") d=Dialog.QuestionDialog(mw,a,("%s\n%s"%(b,widget.label))) response=d.run() d.destroy() if response== Gtk.ResponseType.OK: self.info_box_stack.set_visible_child_name("info_kernel") self.core.dprint('delete %s %s'%(widget.label,[widget.data[1],widget.data[3]]),"[KernelBox]") self.kernel_install('delete',widget.label,[widget.data[1],widget.data[3]]) else: self.info_box_stack.set_visible_child_name("info_kernel") a = _("You cancel to uninstall kernel:") self.txt_check_kernel.set_name("INFO_LABEL") self.txt_check_kernel.set_text(_("%s %s")%(a,widget.label)) self.core.dprint("You cancel to uninstall kernel: %s"%(widget.label),"[KernelBox]") self.update_kernels_button.set_sensitive(True) self.filter_kernels_button.set_sensitive(True) self.apply_kernel_button.set_sensitive(True) self.entry_kernel.set_can_focus(True) self.switch_kernel_installed.set_sensitive(True) except Exception as e: self.core.dprint("(uninstall_clicked) Error: %s"%e,"[KernelBox]") self.info_box_stack.set_visible_child_name("info_kernel") a=_("(uninstall_clicked) Error:") self.txt_check_kernel.set_name("INFO_LABEL_ERROR") self.txt_check_kernel.set_text("%s %s"%(a,e))
def apply_button_clicked(self, widget=True): try: delete = {} delete[self.home] = [] delete[self.net] = [] info = {} info[self.students] = {} info[self.students][self.home] = self.checkb1.get_active() if info[self.students][self.home]: delete[self.home].append("students") info[self.students][self.net] = self.checkb4.get_active() if info[self.students][self.net]: delete[self.net].append("students") info[self.teachers] = {} info[self.teachers][self.home] = self.checkb2.get_active() if info[self.teachers][self.home]: delete[self.home].append("teachers") info[self.teachers][self.net] = self.checkb5.get_active() if info[self.teachers][self.net]: delete[self.net].append("teachers") info[self.admins] = {} info[self.admins][self.home] = self.checkb3.get_active() if info[self.admins][self.home]: delete[self.home].append("admins") info[self.admins][self.net] = self.checkb6.get_active() if info[self.admins][self.net]: delete[self.net].append("admins") for g in info: self.dprint(g) for d in info[g]: self.dprint("\t %s : %s" % (d, info[g][d])) self.dprint("Summary to remove this elements: %s" % (delete)) #Are you sure to delete???? if (len(delete[self.home]) > 0) or (len(delete[self.net]) > 0): #dialog = Gtk.MessageDialog(None,0,Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO, "HOME ERASER") #dialog.format_secondary_text(_("Are you sure you want to delete?")) dialog = Dialog.QuestionDialog( self.main_window, _(u"HOME ERASER"), _(u"Are you sure you want to delete?")) response = dialog.run() dialog.destroy() #if response == Gtk.ResponseType.YES: if response == Gtk.ResponseType.OK: self.apply_button.set_sensitive(False) self.checkb1.set_sensitive(False) self.checkb2.set_sensitive(False) self.checkb3.set_sensitive(False) self.checkb4.set_sensitive(False) self.checkb5.set_sensitive(False) self.checkb6.set_sensitive(False) self.txt_apply.set_text(_("Working........")) self.apply_delete_methods_thread(delete) else: #dialog = Gtk.MessageDialog(None,0,Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "HOME ERASER") #dialog.format_secondary_text(_("You didn't select any option to delete.")) dialog = Dialog.InfoDialog( self.main_window, _(u"HOME ERASER"), _(u"You didn't select any option to delete.")) response = dialog.run() dialog.destroy() except Exception as e: self.dprint(e) print("[HomeEraserGUI](apply_button_clicked) %s" % e) return [False, str(e)]