def ask_info_question(info, in_question, window=None, okay=False): q = resin_ui.info_box(info, in_question, window) if okay == True: q.no_button.hide() q.yes_button.set_label("ok") while q.wait: extra_functions.update_ui() return (q.input, q)
def build_interface(self): self.saved_cat = ['0', '0'] self.current_cat = None self.saved_page = None self.type_state = 0 self.menu_options = [] self.main_window = resin_ui.main_interface() usage = resin_config.get_usage_log() self.main_window.menu_restore.connect("activate", self.restore_sources) self.main_window.menu_about.connect("activate", self.main_window.show_about) self.main_window.menu_licence.connect("activate", self.licence_info) self.main_window.menu_credits.connect("activate", self.credits_info) self.main_window.menu_errors_and_information.connect( "activate", self.show_errorbox) self.main_window.window.connect("destroy", resin_controllers.exit_routine) self.main_window.window.connect("delete-event", resin_controllers.no_destroy) self.main_window.menu_quit.connect("activate", resin_controllers.exit_routine) self.main_window.window.set_icon_from_file( resin_config.images['windowIcon']) extra_functions.set_title(self.main_window.window) self.main_window.about.window.hide() self.generate_menu_columns() self.generate_catalog_columns() self.main_window.start_button.connect("clicked", self.start_exec) self.main_window.toggle_apps.connect("clicked", self.do_toggle_apps) self.main_window.catalog_tree.connect("cursor-changed", self.catalog_change) self.main_window.catalog_tree_page2.connect("cursor-changed", self.catalog_change) self.switch_handler = self.main_window.notebook.connect( "switch-page", self.switch_type_page) conf.need_generate = 1 self.generate_menus() self.check_notebook() extra_functions.update_ui() self.error_box = resin_ui.error_report() self.textviewer = resin_ui.textviewer() """self.main.window.menu_keep_debs.connect("activate",self.keep_debs)##added""" self.main_window.menu_view_help.connect("activate", self.view_help) self.main_window.menu_view_activity_log1.connect( "activate", self.show_activity) self.main_window.menu_view_sources.connect("activate", self.show_sources) self.main_window.menu_view_changelog.connect("activate", self.show_changelog) self.app_switch = 0 self.write_info_html( '<h1>Welcome to <a href="http://home.exetel.com.au/declanhoare/hypermatix64">Hypermatix64</a>.</h1><p>Choose a category from the left-hand side to see what you can install. Check the box for each item you want to install, then click Start to install them.</p><p>To uninstall an item, click the Uninstall tab, check the box for each item you want to uninstall, then click Start to uninstall them.</p>' )
def switch_type_page(self, button, page, number): prestate = self.type_state tmp = self.current_cat if self.type_state == 0 and resin_config.get_installed() != []: self.type_state = 1 tree = self.main_window.catalog_tree_page2 else: self.type_state = 0 tree = self.main_window.catalog_tree if self.main_window.notebook.get_current_page() == 1: self.type_state = 0 tree = self.main_window.catalog_tree self.generate_menus() tree.set_cursor(self.saved_cat[self.type_state]) self.saved_cat[prestate] = tmp extra_functions.update_ui()
def __init__(self): self.about = AX_About() gladeUI = resin_config.gladeUI gladeUI.signal_autoconnect(self) self.window = gladeUI.get_widget("main_interface") self.catalog_tree = gladeUI.get_widget("catalog_tree") self.menu_tree = gladeUI.get_widget("menu_tree") self.catalog_tree_page2 = gladeUI.get_widget("catalog_tree_page2") self.menu_tree_page2 = gladeUI.get_widget("menu_tree_page2") self.status_bar = gladeUI.get_widget("statusbar1") self.menu_quit = gladeUI.get_widget("quit1") self.menu_about = gladeUI.get_widget("about_automatix2") self.menu_licence = gladeUI.get_widget("licence_info") self.menu_credits = gladeUI.get_widget("menu_credits") self.menu_restore = gladeUI.get_widget("restore_sources") self.menu_keep_debs = gladeUI.get_widget("keep_debs") self.menu_view_help = gladeUI.get_widget("view_help") self.menu_view_activity_log1 = gladeUI.get_widget("view_activity_log1") self.menu_view_sources = gladeUI.get_widget("sources") self.menu_view_changelog = gladeUI.get_widget("change_log") self.menu_errors_and_information = gladeUI.get_widget("errors_and_information1") self.start_button = gladeUI.get_widget("start_scripts") self.notebook = gladeUI.get_widget("notebook1") self.page2_label = gladeUI.get_widget("page2_label") self.toolbar = gladeUI.get_widget("toolbar1") self.toggle_apps = gladeUI.get_widget("toggle-apps") self.toggle_icon = gtk.Image() self.toggle_icon.set_from_file(conf.toggle_icons[0]) self.toggle_apps.set_icon_widget(self.toggle_icon); self.toggle_apps.set_label("Deselect all") self.show_apps = gladeUI.get_widget("showButton") self.view_menu = gladeUI.get_widget("view1_menu") self.show_apps.connect("clicked",lambda signal:self.show_apps.get_menu().popup()); self.showIcon = gtk.Image() self.showIcon.set_from_file(resin_config.images["viewIcon"]) self.show_apps.set_icon_widget(self.showIcon) #self.show_apps.set_menu(self.view_menu) self.info_holder = gladeUI.get_widget("infoholder") self.info_html = webkit.WebView() self.info_html.get_settings().set_property("enable-default-context-menu", False) self.info_html.load_html_string("<html><head></head><body></body></html>", "about:blank") self.info_holder.add(self.info_html) conf.trayIcon = self.makeTrayIcon(self.window) extra_functions.update_ui() self.window.set_role("MAIN_WINDOW") self.window.show_all()
def check_notebook(self): if len(resin_config.get_installed()) == 0: self.main_window.notebook.set_current_page(0) if self.saved_page == None: self.saved_page = self.main_window.notebook.get_nth_page(1) self.main_window.notebook.remove_page(1) extra_functions.update_ui() else: if self.saved_page != None: self.main_window.notebook.append_page(self.saved_page, gtk.Label("Uninstall")) self.saved_page = None self.main_window.notebook.set_current_page(0) return True self.main_window.page2_label.set_text("Uninstall") self.uni_mode = 1 extra_functions.update_ui()
def __init__(self): ## add code to ask the user to add repos ///TheeMahn #aa = unlock_apt() if "AUTOMATIX" != "AUTOMATIX BLEEDER": repo_check = resin_ui.ask_info_question( axConf.version['repos'].strip(), "Do you wish to modify your sources.list?") if repo_check[0]: repo_check[1].window.hide() conf.restricted = 1 else: repo_check[1].window.hide() alert( "Some scripts simply will not work, without the repositories enabled." ) conf.restricted = 0 conf.restricted = 0 #self.splashArea = splash() extra_functions.update_ui() #time.sleep(.5) #self.checkEnviroment(); ## End addition #repo_check = ask_info_question(axConf.version['legal'].strip(),"Do you agree?") #quest = ask_question("<b>Ultamatix & Mediaubuntu Repositories are not in your list, many apps / games will not install without them. Would you like to add them?</b>") #tempunlock = unlock_apt() try: if not self.term: self.term = quick_terminal() except: self.term = quick_terminal() try: conf.trayIcon.set_window(self.term.terminal.window) conf.trayIcon.set_label("Updating Apt") except: traceback.print_exc() extra_functions.update_ui() self.term.terminal.window.show() call = "#!/bin/bash\necho 'Updating your sources list please wait...'\nsleep 1\napt-get update\n" script = axUser.conf_folder + "/update.autoscript" open(script, 'w').write(call) os.chmod(script, 0777) self.term.connect_pipe(script) os.unlink(script) self.term.terminal.window.hide() axUser.log("Updated APT")
def __init__(self): ## add code to ask the user to add repos ///TheeMahn if "AUTOMATIX" != "AUTOMATIX BLEEDER": repo_check = ask_info_question( axConf.version['repos'].strip(), "Do you wish to modify your sources.list?") if repo_check[0]: repo_check[1].window.hide() conf.restricted = 1 else: repo_check[1].window.hide() alert( "Some scripts simply will not work, without the repositories enabled." ) conf.restricted = 0 conf.restricted = 0 #self.splashArea = splash() extra_functions.update_ui()
def do_toggle_apps(self, signal): if (self.app_switch == 0): conf.desktop += [conf.other_desktop] self.app_switch = 1 self.main_window.toggle_icon.set_from_file(conf.toggle_icons[1]) self.main_window.toggle_apps.set_label("Select all") else: conf.desktop = conf.desktop[0:-1] self.main_window.toggle_icon.set_from_file(conf.toggle_icons[0]) self.main_window.toggle_apps.set_label("Deselect all") self.app_switch = 0 buildScripts() self.generate_menus() self.check_notebook() self.set_menu(self.menu_options[0]) try: self.set_menu(self.current_catagory) except: traceback.print_exc() extra_functions.update_ui()
def __init__(self,message=None,handler=None,window=None,width=None,height=None): self.handler = handler gladeUI = resin_config.gladeUI gladeUI.signal_autoconnect(self) self.window = gladeUI.get_widget('alert') if width and height: self.window.resize(width,height) label = gladeUI.get_widget('alert_label') label.set_text(message) label.set_use_markup(True) extra_functions.set_title(self.window, hyperlocale.getLocalisedString("alert")) self.window.connect("delete-event",extra_functions.no_delete) self.window.set_modal(True) self.window.show() if window: self.window.set_transient_for(window) self.up = 1 if self.handler == None: self.handler = self.window.hide while self.up: extra_functions.update_ui()
def checkEnviroment(self): resin_config.log( hyperlocale.getLocalisedString("logStarting").format(conf.version)) cur_user = getpass.getuser() if cur_user != "root": self.splashArea.window.hide() resin_ui.alert( hyperlocale.getLocalisedString("notRunningAsRootError"), sys.exit) conf.uName = distro_helpers.getDistName() self.splashArea.prog.set_text( hyperlocale.getLocalisedString("checkVersion").format(conf.uName)) self.splashArea.prog.set_fraction(0.2) extra_functions.update_ui() conf.uVersion = distro_helpers.getDistVersion() distro_helpers.getDesktop() self.splashArea.prog.set_text( hyperlocale.getLocalisedString("foundVersion").format( conf.uVersion)) extra_functions.update_ui() if conf.uName not in conf.supported_linux_dists: self.splashArea.window.hide() resin_ui.alert( hyperlocale.getLocalisedString("incorrectSystemError").format( conf.uName), sys.exit) #check enviroment for synaptic ect... self.splashArea.prog.set_text( hyperlocale.getLocalisedString("checkEnvironment")) self.splashArea.prog.set_fraction(0.4) extra_functions.update_ui() conflicts = distro_helpers.checkConflicts() #locker = exclusive_lock(); #report conflicts if any if conflicts: self.splashArea.window.hide() resin_ui.alert(conflicts[1], sys.exit) self.splashArea.prog.set_text( hyperlocale.getLocalisedString("checkConnection")) self.splashArea.prog.set_fraction(0.5) extra_functions.update_ui() #check for an internerd connection... if not distro_helpers.checkConnection(): self.splashArea.window.destroy() resin_ui.alert(hyperlocale.getLocalisedString("notConnectedError"), sys.exit) #FIXME #self.splashArea.prog.set_text("Setting Up Repositories...") #self.splashArea.prog.set_fraction(0.7) #extra_functions.update_ui() #repoUpdate = setupRepos() ###update splash... #self.splashArea.prog.set_text("Updating Repositories...") #self.splashArea.prog.set_fraction(0.8) #extra_functions.update_ui() #if repoUpdate or conf.update_my_repos == 1: #self.splashArea.window.hide() #axUser.update_apt() #self.splashArea.window.show() #update_ui() #conf.update_my_repos = 0; self.splashArea.prog.set_text("Building Scripts List...") self.splashArea.prog.set_fraction(0.9) extra_functions.update_ui() extra_functions.buildScripts() self.splashArea.prog.set_fraction(1) extra_functions.update_ui() self.splashArea.window.hide() extra_functions.update_ui()
def __init__(self): print(hyperlocale.getLocalisedString("starting")) conf.restricted = 0 self.splashArea = resin_ui.splash() extra_functions.update_ui() self.checkEnviroment()
def ask_question(in_question, window=None): q = resin_ui.question(in_question, window) while q.wait: extra_functions.update_ui() return (q.input, q)
def run(self): self.alert = alert self.watch = True while self.watch == True: check = open(resin_config.ax_in, "r") check = check.read() if "QUESTION::" in check: check = check[len("QUESTION::"):len(check)] self.new_winder("<b>%s</b>" % check) self.answer = True while self.answer: extra_functions.update_ui() test = self.quest_answer open(resin_config.ax_out, "w").write("%s" % test) if "ALERT::" in check: check = check[len("ALERT::"):len(check)] alert("<b>%s</b>" % check) open(resin_config.ax_out, "w").write("Finished") if "WARNING::" in check: print "%s reported the warning: %s" % ( conf.current_executing, check[len("WARNING::"):len(check)]) conf.script_errors += [[ 0, conf.current_executing, check[len("WARNING::"):len(check)] ]] open(resin_config.ax_out, "w").write("received \n") if "INFORMATION::" in check: print "%s reported the info: %s" % ( conf.current_executing, check[len("INFORMATION::"):len(check)]) conf.script_errors += [[ 2, conf.current_executing, check[len("INFORMATION::"):len(check)] ]] open(resin_config.ax_out, "w").write("received \n") if "FATAL::" in check: print "%s encountered a fatal error: %s" % ( conf.current_executing, check[len("FATAL::"):len(check)]) conf.failed += [conf.current_executing] conf.failmessages[ conf.current_executing] = check[len("FATAL::"):len(check)] conf.script_errors += [[ 1, conf.current_executing, check[len("FATAL::"):len(check)] ]] open(resin_config.ax_out, "w").write("received \n") #this part still needs work... if "ADDREPO::" in check: repo = check[len("ADDREPO::"):len(check)] if ("\n" in repo): r = repo.split("\n") repo = r[0] current = repo_proc("/etc/apt/sources.list") if repo.strip() not in open("/etc/apt/sources.list").read(): current.add_repo(repo.strip()) open(resin_config.ax_out, "w").write("received \n") if "INSTALLED::" in check: info = check[len("INSTALLED::"):len(check)].strip() print "%s reported the install of script: %s" % ( conf.current_executing, check[len("INSTALLED::"):len(check)]) if "," in info: info = info.split(",") conf.dep_installed += info conf.deselector += info for i in info: resin_config.add_installed(info) else: conf.dep_installed += [info] conf.deselector += [info] resin_config.add_installed(info) open(resin_config.ax_out, "w").write("received \n") if "REMOVE::" in check: info = check[len("REMOVE::"):len(check)].strip() print "%s reported the uninstall of script: %s" % ( conf.current_executing, check[len("REMOVE::"):len(check)]) if "," in info: info = info.split(",") conf.dep_uninstalled += info conf.deselector = info for i in info: resin_config.remove_installed(i) else: conf.dep_uninstalled += [info] conf.deselector += [info] resin_config.remove_installed(info) open(resin_config.ax_out, "w").write("received \n") if "DROPDOWN::" in check: print check title = check[len("DROPDOWN::"):check.find("OPTIONS::")] options = check[check.find("OPTIONS::") + len("OPTIONS::"):] options = options.split(",") drop = dropdown_window() drop.set_options(options) drop.label.set_markup("<b>%s</b>" % title) drop.window.show_all() while drop.up: extra_functions.update_ui() drop.window.hide() if (drop.leaf): active = drop.menu.get_active() val = drop.model[active][0] open(resin_config.ax_out, "w").write(val) else: open(resin_config.ax_out, "w").write("AX:FALSE")
def start_exec(self, button): #check for conflicts before running installs... conflicts = checkConflicts() #report conflicts if any... #Unlock apt - will cease to exist in -7 if conflicts: alert( "<b>Hypermatix64 cannot continue because %s is running.</b> \nPlease shut down %s and try again." % (conflicts[0], conflicts[0])) return False self.stop = False if len(conf.selected_scripts) == 0: alert("<b>No scripts have been selected</b>", None, self.main_window.window) return False ############################################################################## #create a terminal window to run in... try: if not self.term: self.term = activity_terminal() self.term.terminal.cancel.connect("clicked", self.cancel_term) except: alert("<b>EXCEPTION: </b>" + traceback.format_exc()) return False #self.term = activity_terminal() #self.term.terminal.cancel.connect("clicked",self.cancel_term) #conf.trayIcon.set_window(self.term.terminal.window) #create some pipes to read and write to... resin_config.create_pipes() #hide the main window... self.main_window.window.hide() #show the terminal window... self.term.terminal.window.show() pre = self.term.terminal.label.get_label() c = 1.0000000 #clear deselectors... conf.deselector = [] deselect = [] #gather selected... selected = conf.selected_scripts uninstall = [] install = [] #divide up selected scripts... for sc in selected: if sc in resin_config.get_installed(): uninstall += [sc] else: install += [sc] s_data = get_script(sc) if s_data.depends: if not s_data.depends in resin_config.get_installed(): if not s_data.depends in install: install = [s_data.depends ] + install # put dependencies first if s_data.depends in uninstall: uninstall.remove( s_data.depends) # don't uninstall something you need selected = uninstall + install #okay now we run them... #lock apt #exclusive = apt_unlock(), depriciates in -7 try: apt_pkg.pkgsystem_unlock() except apt_pkg.Error: traceback.print_exc( ) # Silent exception handling is the spawn of Satan. except Exception as Argument: alert("<b>EXCEPTION: </b>" + traceback.format_exc()) return False for sc in selected: if sc not in conf.deselector: #get the information on the script s_data = get_script(sc) #set what script is being run in conf conf.current_executing = sc #setup watch man... watchman = watch_pipe() watchman.function = alert watchman.window = self.main_window.window watchman.start() #create percent done info for info area... curr = c / len(conf.selected_scripts) self.term.terminal.progress.set_fraction(curr) c += 1 #okay now determine what exec script should be run (install or uninstall) if sc in uninstall and sc not in conf.dep_uninstalled: state = "Uninstalling " if s_data.uninstall: exe = s_data.uninstall else: exe = "echo 'Does not have an uninstall routine'\nAX_warning 'Does not have an uninstall routine, please remove manually'\n " elif sc in install and sc not in conf.dep_installed: state = "Installing " exe = s_data.exe extra_functions.update_ui() self.term.terminal.progress.set_text(state + s_data.title) #conf.trayIcon.set_label(state+s_data.title) #now we put it all together and send it to bash... send = "#!/bin/bash\n%s\n%s\necho 'Finished'\nsleep 1\n" % ( resin_config.masterInit, exe) auto = resin_config.conf_folder + "/ax.autoscript" open(resin_config.conf_folder + "/ax.autoscript", "w").write(send) os.chmod(auto, 777) self.term.connect_pipe(auto) #finished now we cancel the watchman watchman.watch = False open(resin_config.ax_in, "w").write("die") #and delete the script we made os.unlink(auto) del watchman #log the output of that script resin_config.log( "!!SCRIPT OUTPUT START!!\n%s\n!!SCRIPT OUTPUT END!!" % self.term.logged) #determine if the install failed... fail = 0 for fi in conf.failed: if fi == sc: fail = 1 break #do stuff if we didn't fail if fail != 1: deselect += [sc] curscript = get_script(sc) if sc in uninstall: resin_config.remove_installed(sc) if curscript.post_info: conf.script_errors += [[ 2, curscript.id, curscript.post_info ]] else: resin_config.add_installed(sc) if curscript.pre_info: conf.script_errors += [[ 2, curscript.id, curscript.pre_info ]] #I think this part is deprecated... """ if curscript.depends: depends = [] if "," in curscript.depends: tmp = curscript.depends.split(",") for t in tmp: depends += [t.strip()] else: depends += [curscript.depends.strip()] for d in depends: if d not in resin_config.get_installed(): resin_config.add_installed(d) dep = get_script(d) if dep.pre_info: conf.script_errors += [[2,dep.id,dep.pre_info]] """ if conf.dep_installed: for d in conf.dep_installed: if d not in resin_config.get_installed(): resin_config.add_installed(d) dep = get_script(d) if dep.pre_info: conf.script_errors += [[2, dep.id, dep.pre_info]] conf.dep_installed = [] if conf.dep_uninstalled: for d in conf.dep_uninstalled: if d in resin_config.get_installed(): resin_config.remove_installed(d) dep = get_script(d) if dep.post_info: conf.script_errors += [[2, dep.id, dep.pre_info]] conf.dep_uninstalled = [] if self.stop == True: break else: deselect += [sc] for d in deselect: k = 0 for select in conf.selected_scripts: if d == select: del conf.selected_scripts[k] k += 1 conf.need_generate = 1 if resin_config.get_installed() == []: self.type_state = 0 for failedScript in conf.failed: alert("<b>" + failedScript + " encountered a fatal error:</b> " + conf.failmessages[failedScript]) conf.failed = [] self.generate_menus() self.check_notebook() self.term.terminal.window.hide() self.set_menu(self.menu_options[0]) self.main_window.window.show() conf.trayIcon.set_window(self.main_window.window) conf.trayIcon.set_label("Ultamatix") extra_functions.update_ui() # now do some error roeporting if conf.script_errors: print "ERRORS OR WARNINGS WHERE REPORTED" resin_config.log("ERRORS OR WARNINGS WHERE REPORTED") print "-" * 50 print "-" * 50 for e in conf.script_errors: print "%s - %s" % (e[0], e[2]) print "-" * 35 es = get_script(e[1]) sc_name = es.title errors = ('WARNING', 'FATAL', 'INFO') resin_config.log("%s - %s - %s" % (errors[int(e[0])], sc_name, e[2].strip())) self.error_box.generate_model(conf.script_errors) self.error_box.window.show() conf.script_errors = [] resin_config.delete_pipes()