def deactivate(self): value = True etc_files = self.controller.install_profile.get_etc_files() etc_files = self.create_etc_files(etc_files) if self.keymap.GetValue(): etc_files['conf.d/keymaps']['KEYMAP'] = self.keymap.GetValue() etc_files['conf.d/keymaps']['SET_WINDOWSKEYS'] = self.windowkeys.GetValue() if self.extkeymap.GetValue() != "": etc_files['conf.d/keymaps']['EXTENDED_KEYMAPS'] = self.extkeymap.GetValue() if self.font.GetValue(): if not "conf.d/consolefont" in etc_files: etc_files['conf.d/consolefont'] = {} etc_files['conf.d/consolefont']['CONSOLEFONT'] = self.font.GetValue() etc_files['conf.d/clock']['CLOCK'] = self.clock.GetValue() etc_files['rc.conf']['EDITOR'] = self.editor.GetValue() if self.displaymanager.GetValue() != "": etc_files['rc.conf']['DISPLAYMANAGER'] = self.displaymanager.GetValue() if self.xsession.GetValue() != "": etc_files['rc.conf']['XSESSION'] = self.xsession.GetValue() try: self.controller.install_profile.set_etc_files(etc_files) except: msgbox=Widgets().error_Box("Error","An internal error occurred!") msgbox.run() msgbox.destroy() return value
def save_clicked(self, widget, data=None): # retrieve the data data = self.get_information() # only proceed if the ethernet device isn't blank if data["ethernet_device"] != "": # save the gateway if its not set # the user must unset the gateway to change it to a different device. if self.widgets["gateway"].get_text() != "": self.gateway[0] = self.widgets["ethernet_device"].get_child().get_text() self.gateway[1] = self.widgets["gateway"].get_text() self.gateway_is_set = True # this will occur when the gateway is unset! if self.widgets["gateway"].get_text() == "" and self.gateway_is_set == True and \ self.widgets["ethernet_device"].get_child().get_text() == self.gateway[0]: self.gateway[0] = "" self.gateway[1] = "" self.gateway_is_set = False if self.gateway_is_set == True and self.widgets["ethernet_device"].get_child().get_text() == self.gateway[0]: gateway = self.gateway[1] else: gateway = "" # store it in the top box. self.add_to_treedata([0, data["ethernet_device"], data["ipaddress"], data["broadcast"], data["netmask"], data["dhcp_options"],gateway]) else: msgdialog = Widgets().error_Box("No Ethernet Device","Please enter a device!") result = msgdialog.run() msgdialog.destroy()
def __buttonpress(self): # rename drugs handler try: from Matcher import Matcher matcher = Matcher(self.mas[0], self.mas[1], self.mas[2], self.mas[3]) try: matcher.rename_drugs() self.showComplete() except IOError: from Widgets import Widgets Widgets.showFNF() except Exception as e: print(e)
def deactivate(self): value = True rc_conf = self.generate_rc_conf_dictionary() #print "saving:"+str(rc_conf) try: self.etc_files['rc.conf'] = rc_conf self.controller.install_profile.set_etc_files(self.etc_files) except: msgbox=Widgets().error_Box("Error","An internal error occurred!") msgbox.run() msgbox.destroy() return value
def verify_root_password(self, widget, data=None): if self.root1.get_text() == self.root2.get_text() and self.root1.get_text()!="": # passwords match! self.root_verified = True # disable the boxen self.root1.set_sensitive(False) self.root2.set_sensitive(False) self.verified.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_SMALL_TOOLBAR) else: # password's don't match. msgbox=Widgets().error_Box("Error","Passwords do not match! ( or they are blank )") msgbox.run() msgbox.destroy()
def deactivate(self): return_value = False # save the space seperated list #print self.custom_box.get_text() try: packages_to_emerge = "" packages_to_emerge = self.entry.get_text() + " " + " ".join(self.checked_items) self.controller.install_profile.set_install_packages(None, packages_to_emerge, None) #print packages_to_emerge return_value = True except: box = Widgets().error_Box("Error saving packages","You need to fix your input! \n Theres a problem, are you sure didn't enter \n funny characters?") box.show() return_value = False return return_value
def deactivate(self): # store everything if (self.root_verified): if self.is_root_pass_set(): # don't hash the password, just store it root_hash = self.root1.get_text() else: # hash the password root_hash = GLIUtility.hash_password(self.root1.get_text()) # store the root password self.controller.install_profile.set_root_pass_hash(None,root_hash,None) # now store all the entered users #( <user name>, <password hash>, (<tuple of groups>), <shell>, # <home directory>, <user id>, <user comment> ) # retrieve everything data = self.get_treeview_data() stored_users = [] # get the array of stored usernames for item in list(self.controller.install_profile.get_users()): stored_users.append(item[0]) for user in data: if user[0] not in self.current_users and user[0] not in stored_users: # user is not in stored profile, and hasn't been previously added self.controller.install_profile.add_user(None, (user[0], user[1], user[2], user[3], user[4], user[5], user[6]), None) #self.current_users.append(user[0]) elif user[0] in stored_users: # user is in stored profile, need to remove, then readd the user self.controller.install_profile.remove_user(user[0]) self.controller.install_profile.add_user(None, (user[0], user[1], user[2], user[3], user[4], user[5], user[6]), None) #self.current_users.append(user[0]) return True else: msgbox=Widgets().error_Box("Error","You have not verified your root password!") msgbox.run() msgbox.destroy()
def add_user(self,data): return_val = False # test to make sure uid is an INT!!! if data["userid"] != "": test = False try: uid_test = int(data["userid"]) test = True except: # its not an integer, raise the exception. msgbox=Widgets().error_Box("Error","UID must be an integer, and you entered a string!") msgbox.run() msgbox.destroy() else: test = True if self.is_data_empty(data) and test==True: # now add it to the box # ( <user name>, <password hash>, (<tuple of groups>), <shell>, # <home directory>, <user id>, <user comment> ) # if they were previously added, modify them if self.is_in_treeview(data['username']): list = self.find_iter(data) self.treedata.set(list[data['username']],0,data["password"], 1,data['username'], 2,data["groups"], 3,data["shell"], 4,data["homedir"], 5,data["userid"], 6,data["comment"] ) else: self.treedata.append([data["password"],data["username"], data["groups"], data["shell"], data["homedir"], data["userid"], data["comment"]]) #self.current_users.append(data['username']) return_val=True return return_val
def deactivate(self): value = True etc_files = self.controller.install_profile.get_etc_files() etc_files = self.create_etc_files(etc_files) if self.keymap.GetValue(): etc_files['conf.d/keymaps']['KEYMAP'] = self.keymap.GetValue() etc_files['conf.d/keymaps'][ 'SET_WINDOWSKEYS'] = self.windowkeys.GetValue() if self.extkeymap.GetValue() != "": etc_files['conf.d/keymaps'][ 'EXTENDED_KEYMAPS'] = self.extkeymap.GetValue() if self.font.GetValue(): if not "conf.d/consolefont" in etc_files: etc_files['conf.d/consolefont'] = {} etc_files['conf.d/consolefont'][ 'CONSOLEFONT'] = self.font.GetValue() etc_files['conf.d/clock']['CLOCK'] = self.clock.GetValue() etc_files['rc.conf']['EDITOR'] = self.editor.GetValue() if self.displaymanager.GetValue() != "": etc_files['rc.conf'][ 'DISPLAYMANAGER'] = self.displaymanager.GetValue() if self.xsession.GetValue() != "": etc_files['rc.conf']['XSESSION'] = self.xsession.GetValue() try: self.controller.install_profile.set_etc_files(etc_files) except: msgbox = Widgets().error_Box("Error", "An internal error occurred!") msgbox.run() msgbox.destroy() return value
def deactivate(self): return_value = False # save the space seperated list #print self.custom_box.get_text() try: packages_to_emerge = "" packages_to_emerge = self.entry.get_text() + " " + " ".join( self.checked_items) self.controller.install_profile.set_install_packages( None, packages_to_emerge, None) #print packages_to_emerge return_value = True except: box = Widgets().error_Box( "Error saving packages", "You need to fix your input! \n Theres a problem, are you sure didn't enter \n funny characters?" ) box.show() return_value = False return return_value
def __init__(self, controller): GLIScreen.GLIScreen.__init__(self, controller) vert = gtk.VBox( False, 10 ) # This box is content so it should fill space to force title to top horiz = gtk.HBox(False, 10) content_str = """ If you click Install here, the installer will generate the xml profile. """ # pack the description vert.pack_start(gtk.Label(content_str), expand=False, fill=False, padding=10) widgets = Widgets() self.treestore = gtk.TreeStore(str) # we'll add some data now - 4 rows with 3 child rows each #for parent in range(5): # piter = self.treestore.append(None, ['parent %i' % parent]) # for child in range(4): # self.treestore.append(piter, ['child %i of parent %i' % (child, parent)]) for item in self.controller.menuItems: self.treestore.append(None, [item['text']]) self.treeview = gtk.TreeView(self.treestore) self.tvcolumn = gtk.TreeViewColumn('Current Install Options') self.treeview.append_column(self.tvcolumn) self.cell = gtk.CellRendererText() self.tvcolumn.pack_start(self.cell, True) self.tvcolumn.add_attribute(self.cell, 'text', 0) self.treeview.set_search_column(0) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_border_width(10) scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) vert.pack_start(scrolled_window, True, True, 0) scrolled_window.show() scrolled_window.add_with_viewport(self.treeview) #vert.pack_start(self.treeview, expand=False, fill=False, padding=10) self.add_content(vert)
def deactivate(self): value = True rc_conf = self.generate_rc_conf_dictionary() #print "saving:"+str(rc_conf) try: self.etc_files['rc.conf'] = rc_conf self.controller.install_profile.set_etc_files(self.etc_files) except: msgbox = Widgets().error_Box("Error", "An internal error occurred!") msgbox.run() msgbox.destroy() return value
def deactivate(self): # store everything if (self.root_verified): if self.is_root_pass_set(): # don't hash the password, just store it root_hash = self.root1.get_text() else: # hash the password root_hash = GLIUtility.hash_password(self.root1.get_text()) # store the root password self.controller.install_profile.set_root_pass_hash( None, root_hash, None) # now store all the entered users #( <user name>, <password hash>, (<tuple of groups>), <shell>, # <home directory>, <user id>, <user comment> ) # retrieve everything data = self.get_treeview_data() stored_users = [] # get the array of stored usernames for item in list(self.controller.install_profile.get_users()): stored_users.append(item[0]) for user in data: if user[0] not in self.current_users and user[ 0] not in stored_users: # user is not in stored profile, and hasn't been previously added self.controller.install_profile.add_user( None, (user[0], user[1], user[2], user[3], user[4], user[5], user[6]), None) #self.current_users.append(user[0]) elif user[0] in stored_users: # user is in stored profile, need to remove, then readd the user self.controller.install_profile.remove_user(user[0]) self.controller.install_profile.add_user( None, (user[0], user[1], user[2], user[3], user[4], user[5], user[6]), None) #self.current_users.append(user[0]) return True else: msgbox = Widgets().error_Box( "Error", "You have not verified your root password!") msgbox.run() msgbox.destroy()
def Generate_GTK(self): # Generate GTK needed. hbox = gtk.HBox(True, 0) name = gtk.Label("") name.set_markup( '<span size="x-large" weight="bold" foreground="white">' + self.category_name + '</span>') name.set_justify(gtk.JUSTIFY_LEFT) table = gtk.Table(1, 1, False) table.set_col_spacings(10) table.set_row_spacings(6) table.attach(name, 0, 1, 0, 1) eb = gtk.EventBox() eb.add(Widgets().hBoxIt2(False, 0, table)) eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#737db5")) hbox.pack_start(eb, expand=True, fill=True, padding=5) return hbox
def Generate_GTK(self): # Generate the pygtk code ncessary for this object. hbox = gtk.HBox(False, 0) table = gtk.Table(2, 2, False) table.set_col_spacings(10) table.set_row_spacings(1) button = gtk.CheckButton() title = gtk.Label("") title.set_markup('<span weight="bold">' + self._display_name + '</span>' + " - " + self.description) button.add(title) button.connect("toggled", self.checkbox_callback, self.portage_name) self.checkbox = button table.attach(Widgets().hBoxIt2(False, 0, button), 1, 2, 0, 1) hbox.pack_start(table, expand=False, fill=False, padding=0) return hbox
def verify_root_password(self, widget, data=None): if self.root1.get_text() == self.root2.get_text( ) and self.root1.get_text() != "": # passwords match! self.root_verified = True # disable the boxen self.root1.set_sensitive(False) self.root2.set_sensitive(False) self.verified.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_SMALL_TOOLBAR) else: # password's don't match. msgbox = Widgets().error_Box( "Error", "Passwords do not match! ( or they are blank )") msgbox.run() msgbox.destroy()
def add_user(self, data): return_val = False # test to make sure uid is an INT!!! if data["userid"] != "": test = False try: uid_test = int(data["userid"]) test = True except: # its not an integer, raise the exception. msgbox = Widgets().error_Box( "Error", "UID must be an integer, and you entered a string!") msgbox.run() msgbox.destroy() else: test = True if self.is_data_empty(data) and test == True: # now add it to the box # ( <user name>, <password hash>, (<tuple of groups>), <shell>, # <home directory>, <user id>, <user comment> ) # if they were previously added, modify them if self.is_in_treeview(data['username']): list = self.find_iter(data) self.treedata.set(list[data['username']], 0, data["password"], 1, data['username'], 2, data["groups"], 3, data["shell"], 4, data["homedir"], 5, data["userid"], 6, data["comment"]) else: self.treedata.append([ data["password"], data["username"], data["groups"], data["shell"], data["homedir"], data["userid"], data["comment"] ]) #self.current_users.append(data['username']) return_val = True return return_val
def deactivate(self): return_value = False # save everything to profile interfaces={} # iterate over the liststore store = self.widgets["treedata"] iter = store.get_iter_first() while(iter != None): number, device, ip, broadcast, netmask, options, gateway = store.get(iter, 0, 1, 2, 3, 4, 5, 6) if ip != "dhcp": interfaces[device] = (ip, broadcast, netmask) else: print options interfaces[device]=(ip, options, None) if gateway != "": # store the gateway try: self.controller.install_profile.set_default_gateway(None,self.gateway[1], \ {'interface':self.gateway[0]}) except: msgdialog=Widgets().error_Box("Malformed IP","Malformed IP address in your gateway!") result = msgdialog.run() msgdialog.destroy() return False iter = store.iter_next(iter) # If there are no interfaces configured, confirm this is what the user actually wants if not interfaces: msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format="You have not configured any interfaces. Continue?") resp = msgdlg.run() msgdlg.destroy() if resp == gtk.RESPONSE_NO: return False # store the stuff try: self.controller.install_profile.set_network_interfaces(interfaces) except: msgdialog=Widgets().error_Box("Malformed IP","Malformed IP address in one of your interfaces!") result = msgdialog.run() msgdialog.destroy() return False # store dnsdomainname and hostname hostname = self.widgets["hostname"].get_text() domainname = self.widgets["domainname"].get_text() if( hostname != "" and domainname != ""): self.controller.install_profile.set_hostname(None, hostname, None) self.controller.install_profile.set_domainname(None, domainname, None) return_value = True elif( self.first_run == True): msgdialog=Widgets().error_Box("Missing information","You didn't set your hostname and/or dnsdomainname!") result = msgdialog.run() msgdialog.destroy() return_value = False else: return_value = True return return_value