1 | from ubiquity import misc, plugin, validation |
---|
2 | import os |
---|
3 | import inspect |
---|
4 | import socket |
---|
5 | |
---|
6 | NAME = 'lliurexSupportedHardware' |
---|
7 | AFTER = 'console_setup' |
---|
8 | BEFORE = 'usersetup' |
---|
9 | WEIGHT = 11 |
---|
10 | |
---|
11 | class PageGtk(plugin.PluginUI): |
---|
12 | plugin_title = 'lliurex/supportedHardware' |
---|
13 | |
---|
14 | def __init__(self, controller, *args, **kwargs): |
---|
15 | from gi.repository import Gio, Gtk |
---|
16 | self.resolver = Gio.Resolver.get_default() |
---|
17 | self.controller = controller |
---|
18 | builder = Gtk.Builder() |
---|
19 | self.controller.add_builder(builder) |
---|
20 | builder.add_from_file(os.path.join( |
---|
21 | os.environ['UBIQUITY_GLADE'], 'UbiLliureXSupportedHardware.ui')) |
---|
22 | builder.connect_signals(self) |
---|
23 | self.page = builder.get_object('UbiLliureXSupportedHardware') |
---|
24 | self.graphic_model_label = builder.get_object('label_lliurex_graphics_model') |
---|
25 | os.system("lspci | grep -i 'vga' | cut -d ':' -f3 > /tmp/llx.supportedHardware.vga") |
---|
26 | fich=open("/tmp/llx.supportedHardware.vga","r") |
---|
27 | self.graphic_hardware = fich.read() |
---|
28 | fich.close() |
---|
29 | |
---|
30 | self.graphic_model_label.set_text(str(self.graphic_hardware)) |
---|
31 | self.supportedHardware = builder.get_object('label_supportedHardware') |
---|
32 | self.plugin_widgets = self.page |
---|
33 | |
---|
34 | self.skip = False |
---|
35 | |
---|
36 | def plugin_skip_page(self): |
---|
37 | # Set from the command line with --wireless |
---|
38 | ip_success="" |
---|
39 | internet= False |
---|
40 | |
---|
41 | try: |
---|
42 | ip_success = socket.gethostbyname("lliurex.net") |
---|
43 | print ("LliureX is reachable : " + ip_success) |
---|
44 | internet = True |
---|
45 | except Exception as e: |
---|
46 | print ("LliureX is unreachable: "+ str(e)) |
---|
47 | |
---|
48 | try: |
---|
49 | ip_success = socket.gethostbyname("server") |
---|
50 | print ("Server is reachable : " + ip_success) |
---|
51 | internet = True |
---|
52 | except Exception as e: |
---|
53 | print ("Server is unreachable: "+ str(e)) |
---|
54 | |
---|
55 | if internet: |
---|
56 | return False |
---|
57 | else: |
---|
58 | return True |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | class Page(plugin.Plugin): |
---|
63 | |
---|
64 | @misc.raise_privileges |
---|
65 | def ok_handler(self): |
---|
66 | list_packages = [] |
---|
67 | if self.ui.supportedHardware.get_active(): |
---|
68 | os.system("mkdir -p /var/lib/ubiquity/") |
---|
69 | f = open("/var/lib/ubiquity/apt-installed","a") |
---|
70 | f.write("nvidia-304\n") |
---|
71 | f.close() |
---|
72 | |
---|
73 | plugin.Plugin.ok_handler(self) |
---|
74 | |
---|