from ubiquity import misc, plugin, validation import os import inspect import socket NAME = 'lliurex' AFTER = 'console_setup' BEFORE = 'usersetup' WEIGHT = 13 class PageGtk(plugin.PluginUI): plugin_title = 'lliurex/installextradebs' 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'], 'UbiLliureXExtraPackages.ui')) builder.connect_signals(self) self.page = builder.get_object('UbiLliureXExtraPackages') # Office self.ocrfeeder = builder.get_object('cb_ocrfeeder') self.posterazor = builder.get_object('cb_posterazor') # PDI self.mrpdi = builder.get_object('cb_mrpdi') self.sankore = builder.get_object('cb_sankore') # Technology self.s4a = builder.get_object('cb_s4a') self.appinventor = builder.get_object('cb_appinventor') self.arduino = builder.get_object('cb_arduino') self.openscad = builder.get_object('cb_openscad') # End 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 = [] # First office if self.ui.ocrfeeder.get_active(): list_packages.append('ocrfeeder') if self.ui.posterazor.get_active(): list_packages.append('posterazor') # Secondly PDI if self.ui.mrpdi.get_active(): list_packages.append('mrpdi-gui') if self.ui.sankore.get_active(): list_packages.append('open-sankore') # At last technology if self.ui.s4a.get_active(): list_packages.append('s4a') if self.ui.appinventor.get_active(): list_packages.append('appinventor-setup') if self.ui.arduino.get_active(): list_packages.append('arduino-ide') if self.ui.openscad.get_active(): list_packages.append('openscad') # End of checkboxes #s = inspect.stack() #ob = s[1][0] #parent = inspect.getargvalues(ob).locals['self'] #parent.success_cmd = 'chroot /target apt-get update && apt-get install ' +' '.join(list_packages) os.system("mkdir -p /var/lib/ubiquity/") for p in list_packages: f = open("/var/lib/ubiquity/apt-installed","a") f.write(str(p)+"\n") f.close() plugin.Plugin.ok_handler(self)