forked from SolusOS-discontinued/os-installer
-
Notifications
You must be signed in to change notification settings - Fork 11
/
os-installer-gtk
executable file
·68 lines (56 loc) · 2.09 KB
/
os-installer-gtk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
#
# This file is part of os-installer
#
# Copyright 2013-2016 Ikey Doherty <ikey@solus-project.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
import sys
import os
from os_installer2.application import InstallerApplication
from os_installer2.permissions import PermissionsManager
from os_installer2 import SOURCE_FILESYSTEM, join_resource_path
from gi.repository import Gdk, GObject, Gtk, Gio
def init_css():
""" Set up the CSS before we throw any windows up """
try:
f = Gio.File.new_for_path(join_resource_path("styling.css"))
css = Gtk.CssProvider()
css.load_from_file(f)
screen = Gdk.Screen.get_default()
prio = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
Gtk.StyleContext.add_provider_for_screen(screen,
css,
prio)
except Exception as e:
print("Error loading CSS: {}".format(e))
if __name__ == "__main__":
if os.geteuid() != 0:
sys.stderr.write("You must be root to use OsInstaller\n")
sys.stderr.flush()
sys.exit(1)
# No source filesystem? No cookies for you!
if not os.path.exists(SOURCE_FILESYSTEM):
msg = "Source file system is missing, cannot continue.\n\n{}".format(
SOURCE_FILESYSTEM)
d = Gtk.MessageDialog(parent=None, flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.WARNING,
buttons=Gtk.ButtonsType.CLOSE,
message_format=msg)
d.run()
d.destroy()
sys.exit(1)
# Immediately drop permissions before we init GTK
p = PermissionsManager()
p.down_permissions()
GObject.threads_init()
Gdk.threads_init()
init_css()
app = InstallerApplication()
r = app.run(sys.argv)
sys.exit(r)