def __init__(self): # This allows to translate all py texts (not the glade ones) gettext.textdomain(APP_NAME) gettext.bindtextdomain(APP_NAME, LOCALE_DIR) locale_code, encoding = locale.getdefaultlocale() lang = gettext.translation(APP_NAME, LOCALE_DIR, [locale_code], None, True) lang.install() # With this we can use _("string") to translate gettext.install(APP_NAME, localedir=LOCALE_DIR, codeset=None, names=[locale_code]) # Check if we have administrative privileges if os.getuid() != 0: show.fatal_error(_('This installer must be run with administrative' ' privileges, and cannot continue without them.')) setup_logging() # Check if we're already running tmp_running = "/tmp/.setup-running" if os.path.exists(tmp_running): show.error(_('You cannot run two instances of this installer.\n\n' 'If you are sure that the installer is not already running\n' 'you can manually delete the file %s\n' 'and run this installer again.') % tmp_running) sys.exit(1) super().__init__() logging.info("Cnchi installer version %s" % info.cnchi_VERSION) p = multiprocessing.current_process() logging.debug("[%d] %s started" % (p.pid, p.name)) self.settings = config.Settings() self.ui_dir = self.settings.get('ui') if not os.path.exists(self.ui_dir): cnchi_dir = os.path.join(os.path.dirname(__file__), './') self.settings.set('cnchi', cnchi_dir) ui_dir = os.path.join(os.path.dirname(__file__), 'ui/') self.settings.set('ui', ui_dir) data_dir = os.path.join(os.path.dirname(__file__), 'data/') self.settings.set('data', data_dir) self.ui_dir = self.settings.get('ui') self.settings.set('cache', _cache_dir) # Set enabled desktops self.settings.set("desktops", _desktops) # Set if a grub type must be installed (user choice) self.settings.set("force_grub_type", _force_grub_type) self.ui = Gtk.Builder() self.ui.add_from_file(self.ui_dir + "cnchi.ui") self.add(self.ui.get_object("main")) self.header = self.ui.get_object("header") self.forward_button = self.ui.get_object("forward_button") self.logo = self.ui.get_object("logo") data_dir = self.settings.get('data') logo_dir = os.path.join(data_dir, "antergos-logo-mini.png") self.logo.set_from_file(logo_dir) self.title = self.ui.get_object("title") # To honor our css self.title.set_name("title") self.logo.set_name("logo") self.main_box = self.ui.get_object("main_box") self.progressbar = self.ui.get_object("progressbar1") self.forward_button = self.ui.get_object("forward_button") self.exit_button = self.ui.get_object("exit_button") self.backwards_button = self.ui.get_object("backwards_button") # Create a queue. Will be used to report pacman messages (pac.py) # to the main thread (installer_*.py) self.callback_queue = multiprocessing.JoinableQueue() # Save in config if we have to use aria2 to download pacman packages self.settings.set("use_aria2", _use_aria2) if _use_aria2: logging.info(_("Using Aria2 to download packages - EXPERIMENTAL")) # Load all pages # (each one is a screen, a step in the install process) self.pages = dict() params = dict() params['title'] = self.title params['ui_dir'] = self.ui_dir params['forward_button'] = self.forward_button params['backwards_button'] = self.backwards_button params['exit_button'] = self.exit_button params['callback_queue'] = self.callback_queue params['settings'] = self.settings params['main_progressbar'] = self.ui.get_object('progressbar1') params['alternate_package_list'] = _alternate_package_list params['disable_tryit'] = _disable_tryit if len(_alternate_package_list) > 0: logging.info(_("Using '%s' file as package list") % _alternate_package_list) self.pages["welcome"] = welcome.Welcome(params) self.pages["language"] = language.Language(params) self.pages["location"] = location.Location(params) self.pages["check"] = check.Check(params) self.pages["desktop"] = desktop.DesktopAsk(params) self.pages["features"] = features.Features(params) self.pages["keymap"] = keymap.Keymap(params) self.pages["timezone"] = timezone.Timezone(params) self.pages["installation_ask"] = installation_ask.InstallationAsk(params) self.pages["installation_automatic"] = installation_automatic.InstallationAutomatic(params) self.pages["installation_alongside"] = installation_alongside.InstallationAlongside(params) self.pages["installation_advanced"] = installation_advanced.InstallationAdvanced(params) self.pages["user_info"] = user_info.UserInfo(params) self.pages["slides"] = slides.Slides(params) self.connect("delete-event", Gtk.main_quit) self.ui.connect_signals(self) self.set_title(_('Antergos Installer')) self.set_position(Gtk.WindowPosition.CENTER) self.set_resizable(False) self.set_size_request(_main_window_width, _main_window_height); # Set window icon icon_dir = os.path.join(data_dir, 'antergos-icon.png') self.set_icon_from_file(icon_dir) # Set the first page to show self.current_page = self.pages["welcome"] self.main_box.add(self.current_page) # Header style testing style_provider = Gtk.CssProvider() style_css = os.path.join(data_dir, "css", "gtk-style.css") with open(style_css, 'rb') as css: css_data = css.read() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) # Show main window self.show_all() self.vertical_image = self.ui.get_object('vertical_image') self.vertical_image.hide() #logo_90_dir = os.path.join(data_dir, "antergos-logo-mini-90.png") #self.vertical_image.set_from_file(logo_90_dir) self.current_page.prepare('forwards') # Hide backwards button self.backwards_button.hide() # Hide titlebar but show border decoration self.get_window().set_accept_focus(True) self.get_window().set_decorations(Gdk.WMDecoration.BORDER) # Hide progress bar as it's value is zero self.progressbar.set_fraction(0) self.progressbar.hide() self.progressbar_step = 1.0 / (len(self.pages) - 2) # We drop privileges, but where we should do it? before this? ¿? misc.drop_privileges() with open(tmp_running, "wt") as tmp_file: tmp_file.write("Cnchi %d\n" % 1234) GLib.timeout_add(1000, self.pages["slides"].manage_events_from_cb_queue)
def __init__(self): # This allows to translate all py texts (not the glade ones) gettext.textdomain(APP) gettext.bindtextdomain(APP, DIR) locale_code, encoding = locale.getdefaultlocale() lang = gettext.translation (APP, DIR, [locale_code], None, True) lang.install() # With this we can use _("string") to translate gettext.install(APP, localedir=DIR, codeset=None, names=[locale_code]) if os.getuid() != 0: show.fatal_error(_('This installer must be run with administrative' ' privileges, and cannot continue without them.')) # check if we're already running tmp_running = "/tmp/.setup-running" if os.path.exists(tmp_running): show.error(_('You cannot run two instances of this installer.\n\n' 'If you are sure that the installer is not already running\n' 'you can manually delete the file %s\n' 'and run this installer again.') % tmp_running) sys.exit(1) super().__init__() self.settings = config.Settings() self.ui_dir = self.settings.get("UI_DIR") if not os.path.exists(self.ui_dir): cnchi_dir = os.path.join(os.path.dirname(__file__), './') self.settings.set("CNCHI_DIR", cnchi_dir) ui_dir = os.path.join(os.path.dirname(__file__), 'ui/') self.settings.set("UI_DIR", ui_dir) data_dir = os.path.join(os.path.dirname(__file__), 'data/') self.settings.set("DATA_DIR", data_dir) self.ui_dir = self.settings.get("UI_DIR") # set enabled desktops self.settings.set("desktops", _desktops) self.ui = Gtk.Builder() self.ui.add_from_file(self.ui_dir + "cnchi.ui") self.add(self.ui.get_object("main")) self.header = self.ui.get_object("box5") self.forward_button = self.ui.get_object("forward_button") self.logo = self.ui.get_object("logo") logo_dir = os.path.join(self.settings.get("DATA_DIR"), "antergos-logo-mini.png") self.logo.set_from_file(logo_dir) self.title = self.ui.get_object("title") # To honor our css self.title.set_name("header") self.logo.set_name("header") self.main_box = self.ui.get_object("main_box") self.progressbar = self.ui.get_object("progressbar1") self.forward_button = self.ui.get_object("forward_button") self.exit_button = self.ui.get_object("exit_button") self.backwards_button = self.ui.get_object("backwards_button") # Create a queue. Will be used to report pacman messages (pac.py) # to the main thread (installer_*.py) #self.callback_queue = queue.Queue(0) # Doing some tests with a LIFO queue #self.callback_queue = queue.LifoQueue(0) self.callback_queue = Queue() # save in config if we have to use aria2 to download pacman packages self.settings.set("use_aria2", _use_aria2) if _use_aria2: log.debug(_("Cnchi will use pm2ml and aria2 to download packages - EXPERIMENTAL")) # load all pages # (each one is a screen, a step in the install process) self.pages = dict() params = dict() params['title'] = self.title params['ui_dir'] = self.ui_dir params['forward_button'] = self.forward_button params['backwards_button'] = self.backwards_button params['exit_button'] = self.exit_button params['callback_queue'] = self.callback_queue params['settings'] = self.settings params['alternate_package_list'] = _alternate_package_list params['enable_alongside'] = _enable_alongside if len(_alternate_package_list) > 0: log.debug(_("Using '%s' file as package list") % _alternate_package_list) self.pages["welcome"] = welcome.Welcome(params) self.pages["language"] = language.Language(params) self.pages["location"] = location.Location(params) self.pages["check"] = check.Check(params) self.pages["desktop"] = desktop.DesktopAsk(params) self.pages["keymap"] = keymap.Keymap(params) self.pages["timezone"] = timezone.Timezone(params) self.pages["installation_ask"] = installation_ask.InstallationAsk(params) self.pages["installation_automatic"] = installation_automatic.InstallationAutomatic(params) self.pages["installation_alongside"] = installation_alongside.InstallationAlongside(params) self.pages["installation_advanced"] = installation_advanced.InstallationAdvanced(params) self.pages["user_info"] = user_info.UserInfo(params) self.pages["slides"] = slides.Slides(params) self.connect("delete-event", Gtk.main_quit) self.ui.connect_signals(self) self.set_title(_('Antergos Installer')) self.set_position(Gtk.WindowPosition.CENTER) self.set_resizable(False) self.set_size_request(_main_window_width, _main_window_height); # set window icon icon_dir = os.path.join(self.settings.get("DATA_DIR"), 'antergos-icon.png') self.set_icon_from_file(icon_dir) # set the first page to show self.current_page = self.pages["welcome"] self.main_box.add(self.current_page) # Header style testing style_provider = Gtk.CssProvider() style_css = os.path.join(self.settings.get("DATA_DIR"), "css", "gtk-style.css") with open(style_css, 'rb') as css: css_data = css.read() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) # show main window self.show_all() self.current_page.prepare('forwards') # hide backwards button self.backwards_button.hide() # Hide titlebar but show border decoration self.get_window().set_accept_focus(True) self.get_window().set_decorations(Gdk.WMDecoration.BORDER) # hide progress bar as it's value is zero self.progressbar.set_fraction(0) self.progressbar.hide() self.progressbar_step = 1.0 / (len(self.pages) - 2) # we drop privileges, but where we should do it? before this? ¿? misc.drop_privileges() with open(tmp_running, "wt") as tmp_file: tmp_file.write("Cnchi %d\n" % 1234) GLib.timeout_add(100, self.pages["slides"].manage_events_from_cb_queue)
def __init__(self): # This allows to translate all py texts (not the glade ones) gettext.textdomain(APP) gettext.bindtextdomain(APP, DIR) locale_code, encoding = locale.getdefaultlocale() lang = gettext.translation (APP, DIR, [locale_code], None, True) lang.install() # With this we can use _("string") to translate gettext.install(APP, localedir=DIR, codeset=None, names=[locale_code]) if os.getuid() != 0: show.fatal_error(_('This installer must be run with administrative' ' privileges, and cannot continue without them.')) # check if we're already running tmp_running = "/tmp/.setup-running" if os.path.exists(tmp_running): show.error(_('You cannot run two instances of this installer.\n\n' 'If you are sure that the installer is not already running\n' 'you can manually delete the file %s\n' 'and run this installer again.') % tmp_running) sys.exit(1) super().__init__() self.settings = config.Settings() self.ui_dir = self.settings.get("UI_DIR") if not os.path.exists(self.ui_dir): cnchi_dir = os.path.join(os.path.dirname(__file__), './') self.settings.set("CNCHI_DIR", cnchi_dir) ui_dir = os.path.join(os.path.dirname(__file__), 'ui/') self.settings.set("UI_DIR", ui_dir) data_dir = os.path.join(os.path.dirname(__file__), 'data/') self.settings.set("DATA_DIR", data_dir) self.ui_dir = self.settings.get("UI_DIR") self.ui = Gtk.Builder() self.ui.add_from_file(self.ui_dir + "cnchi.ui") self.add(self.ui.get_object("main")) self.header = self.ui.get_object("box5") self.forward_button = self.ui.get_object("forward_button") self.logo = self.ui.get_object("logo") logo_dir = os.path.join(self.settings.get("DATA_DIR"), "logo_mini.png") self.logo.set_from_file(logo_dir) self.title = self.ui.get_object("title") # To honor our css self.title.set_name("header") self.logo.set_name("header") self.main_box = self.ui.get_object("main_box") self.progressbar = self.ui.get_object("progressbar1") self.forward_button = self.ui.get_object("forward_button") self.exit_button = self.ui.get_object("exit_button") self.backwards_button = self.ui.get_object("backwards_button") # Create a queue. Will be used to report pacman messages (pac.py) # to the main thread (installer_*.py) #self.callback_queue = queue.Queue(0) # Doing some tests with a LIFO queue self.callback_queue = queue.LifoQueue(0) # load all pages # (each one is a screen, a step in the install process) self.pages = dict() params = dict() params['title'] = self.title params['ui_dir'] = self.ui_dir params['forward_button'] = self.forward_button params['backwards_button'] = self.backwards_button params['exit_button'] = self.exit_button params['callback_queue'] = self.callback_queue params['settings'] = self.settings self.pages["welcome"] = welcome.Welcome(params) self.pages["language"] = language.Language(params) self.pages["location"] = location.Location(params) self.pages["check"] = check.Check(params) self.pages["keymap"] = keymap.Keymap(params) self.pages["timezone"] = timezone.Timezone(params) self.pages["installation_ask"] = installation_ask.InstallationAsk(params) self.pages["installation_automatic"] = installation_automatic.InstallationAutomatic(params) self.pages["installation_easy"] = installation_easy.InstallationEasy(params) self.pages["installation_advanced"] = installation_advanced.InstallationAdvanced(params) self.pages["user_info"] = user_info.UserInfo(params) self.pages["slides"] = slides.Slides(params) self.connect("delete-event", Gtk.main_quit) self.ui.connect_signals(self) self.set_title(_('Cinnarch Installer')) self.set_position(Gtk.WindowPosition.CENTER) self.set_resizable(False) self.set_size_request(_main_window_width, _main_window_height); # set window icon icon_dir = os.path.join(self.settings.get("DATA_DIR"), 'cinnarch-icon.png') self.set_icon_from_file(icon_dir) # set the first page to show #self.current_page = self.pages["language"] self.current_page = self.pages["welcome"] self.main_box.add(self.current_page) # Header style testing style_provider = Gtk.CssProvider() style_css = os.path.join(self.settings.get("DATA_DIR"), "gtk-style.css") css = open(style_css, 'rb') css_data = css.read() css.close() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) # show main window self.show_all() self.current_page.prepare('forwards') # hide backwards button self.backwards_button.hide() # Hide titlebar but show border decoration self.get_window().set_accept_focus(True) self.get_window().set_decorations(Gdk.WMDecoration.BORDER) # hide progress bar as it's value is zero self.progressbar.set_fraction(0) self.progressbar.hide() self.progressbar_step = 1.0 / (len(self.pages) - 2) # we drop privileges, but where we should do it? before this? ¿? misc.drop_privileges() with open(tmp_running, "wt") as tmp_file: tmp_file.write("Cnchi %d\n" % 1234) GLib.timeout_add(100, self.pages["slides"].manage_events_from_cb_queue)
def __init__(self): # This allows to translate all py texts (not the glade ones) gettext.textdomain(APP) gettext.bindtextdomain(APP, DIR) locale_code, encoding = locale.getdefaultlocale() lang = gettext.translation (APP, DIR, [locale_code], None, True) lang.install() # With this we can use _("string") to translate gettext.install(APP, localedir=DIR, codeset=None, names=[locale_code]) if os.getuid() != 0: fatal_error(_('This installer must be run with administrative' ' privileges, and cannot continue without them.')) super().__init__() self.ui_dir = installer_settings["UI_DIR"] if not os.path.exists(self.ui_dir): cnchi_dir = os.path.join(os.path.dirname(__file__), './') installer_settings["CNCHI_DIR"] = cnchi_dir ui_dir = os.path.join(os.path.dirname(__file__), 'ui/') installer_settings["UI_DIR"] = ui_dir data_dir = os.path.join(os.path.dirname(__file__), 'data/') installer_settings["DATA_DIR"] = data_dir self.ui_dir = installer_settings["UI_DIR"] self.ui = Gtk.Builder() self.ui.add_from_file(self.ui_dir + "cnchi.ui") self.add(self.ui.get_object("main")) self.header = self.ui.get_object("box5") self.forward_button = self.ui.get_object("forward_button") self.logo = self.ui.get_object("logo") logo_dir = os.path.join(installer_settings["DATA_DIR"], "logo_mini.png") self.logo.set_from_file(logo_dir) self.title = self.ui.get_object("title") # To honor our css self.title.set_name("header") self.logo.set_name("header") self.main_box = self.ui.get_object("main_box") self.progressbar = self.ui.get_object("progressbar1") self.forward_button = self.ui.get_object("forward_button") self.exit_button = self.ui.get_object("exit_button") self.backwards_button = self.ui.get_object("backwards_button") # load all pages # (each one is a screen, a step in the install process) self.pages = dict() params = dict() params['title'] = self.title params['ui_dir'] = self.ui_dir params['forward_button'] = self.forward_button params['backwards_button'] = self.backwards_button params['exit_button'] = self.exit_button self.pages["language"] = language.Language(params) self.pages["check"] = check.Check(params) self.pages["keymap"] = keymap.Keymap(params) self.pages["timezone"] = timezone.Timezone(params) self.pages["installation_ask"] = installation_ask.InstallationAsk(params) self.pages["installation_automatic"] = installation_automatic.InstallationAutomatic(params) self.pages["installation_easy"] = installation_easy.InstallationEasy(params) self.pages["installation_advanced"] = installation_advanced.InstallationAdvanced(params) self.pages["user_info"] = user_info.UserInfo(params) self.pages["slides"] = slides.Slides(params) self.connect("delete-event", Gtk.main_quit) self.ui.connect_signals(self) self.set_title(_('Cinnarch Installer')) self.set_position(Gtk.WindowPosition.CENTER) self.set_resizable(False) self.set_size_request(_main_window_width, _main_window_height); # set window icon icon_dir = os.path.join(installer_settings["DATA_DIR"], 'cinnarch-icon.png') self.set_icon_from_file(icon_dir) # set the first page to show #self.current_page = self.pages["language"] #self.current_page = self.pages["installation_ask"] self.current_page = self.pages["installation_advanced"] #self.current_page = self.pages["installation_easy"] #self.current_page = self.pages["slides"] #self.current_page = self.pages["timezone"] self.main_box.add(self.current_page) # Header style testing style_provider = Gtk.CssProvider() style_css = os.path.join(installer_settings["DATA_DIR"], "gtk-style.css") css = open(style_css, 'rb') css_data = css.read() css.close() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) # show main window self.show_all() self.current_page.prepare() # hide backwards button self.backwards_button.hide() # Hide titlebar but show border decoration self.get_window().set_accept_focus(True) self.get_window().set_decorations(Gdk.WMDecoration.BORDER) # we drop privileges, but where we should do it? before this? ¿? misc.drop_privileges()