from ubiquity import misc, plugin, validation import os import inspect import socket NAME = 'lliurexSupportedHardware' AFTER = 'console_setup' BEFORE = 'usersetup' WEIGHT = 11 class PageGtk(plugin.PluginUI): plugin_title = 'lliurex/supportedHardware' def __init__(self, controller, *args, **kwargs): from gi.repository import Gio, Gtk self.resolver = Gio.Resolver.get_default() self.controller = controller builder = Gtk.Builder() self.controller.add_builder(builder) builder.add_from_file(os.path.join( os.environ['UBIQUITY_GLADE'], 'UbiLliureXSupportedHardware.ui')) builder.connect_signals(self) self.page = builder.get_object('UbiLliureXSupportedHardware') self.graphic_model_label = builder.get_object('label_lliurex_graphics_model') os.system("lspci | grep -i 'vga' | cut -d ':' -f3 > /tmp/llx.supportedHardware.vga") fich=open("/tmp/llx.supportedHardware.vga","r") self.graphic_hardware = fich.read() fich.close() self.graphic_model_label.set_text(str(self.graphic_hardware)) self.supportedHardware = builder.get_object('label_supportedHardware') self.plugin_widgets = self.page self.skip = False def plugin_skip_page(self): # Set from the command line with --wireless ip_success="" internet= False try: ip_success = socket.gethostbyname("lliurex.net") print ("LliureX is reachable : " + ip_success) internet = True except Exception as e: print ("LliureX is unreachable: "+ str(e)) try: ip_success = socket.gethostbyname("server") print ("Server is reachable : " + ip_success) internet = True except Exception as e: print ("Server is unreachable: "+ str(e)) if internet: return False else: return True class Page(plugin.Plugin): @misc.raise_privileges def ok_handler(self): list_packages = [] if self.ui.supportedHardware.get_active(): os.system("mkdir -p /var/lib/ubiquity/") f = open("/var/lib/ubiquity/apt-installed","a") f.write("nvidia-304\n") f.close() plugin.Plugin.ok_handler(self)