Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-tweak.git;a=commitdiff;h=49e4b230f5a04967a9d9f1a484bf91329bceb2af
commit 49e4b230f5a04967a9d9f1a484bf91329bceb2af Author: bouleetbil <[email protected]> Date: Mon Jan 16 21:53:47 2012 +0100 pyfpm *rewrite pyfpminstall diff --git a/py-pacman/pyfpm/src/pyfpm.py b/py-pacman/pyfpm/src/pyfpm.py index bfaa106..019fa79 100755 --- a/py-pacman/pyfpm/src/pyfpm.py +++ b/py-pacman/pyfpm/src/pyfpm.py @@ -389,6 +389,8 @@ def main(): # [...] set splash up splash.show() draw() + import time + time.sleep(1) read_suxcommande() app = GUI() splash.destroy() diff --git a/py-pacman/pyfpm/src/pyfpminstall.py b/py-pacman/pyfpm/src/pyfpminstall.py index 5005a9a..3d7e229 100644 --- a/py-pacman/pyfpm/src/pyfpminstall.py +++ b/py-pacman/pyfpm/src/pyfpminstall.py @@ -18,9 +18,6 @@ from gi.repository import Gtk, GdkPixbuf, Gdk import os, sys -import time -import pacmang2.libpacman -from pacmang2.libpacman import * from pyfpmtools.tools import * bo_install = 0 @@ -29,8 +26,8 @@ bo_cleancache=0 bo_updatedb=0 bo_updatesys=0 tab_pkgs=[] -text_action="Download fpm..." bo_download=0 +bo_finish=0 pypacman = pypacmang2() main_window = Gtk.Window() @@ -38,137 +35,155 @@ builder = Gtk.Builder() def fpm_progress_install(*args): print_debug("fpm_progress_install") - global bo_download - bo_download=1 - label_what=builder.get_object("label_what") - progressbar_install=builder.get_object("progressbar_install") i=1 - packagename="" percent=0 event=0 count=0 + str_label="" + progress=0 for arg in args: if i==1: - event=arg - if i==2: - packagename = pointer_to_string(arg) + if arg!=None: + event=arg + #if i==2: + # packagename = pointer_to_string(arg) if i==3: - percent=arg - if i==4: - count = arg + if arg!=None: + percent=arg + elif i==4: + if arg!=None: + count = arg + else: + pass i=i+1 - str_label="" + try : + progress=float(float(percent)/100) + print_debug(progress) + except : + pass if event==PM_TRANS_PROGRESS_ADD_START: if count>1: str_label="Installing packages..." else: - str_label="Installing package..." - if event==PM_TRANS_PROGRESS_UPGRADE_START: + str_label="Installing package..." + updateGUI(str_label,progress) + elif event==PM_TRANS_PROGRESS_UPGRADE_START: if count>1: str_label="Upgrading packages..." else: str_label="Upgrading package..." - if event==PM_TRANS_PROGRESS_REMOVE_START: + updateGUI(str_label,progress) + elif event==PM_TRANS_PROGRESS_REMOVE_START: if count>1: str_label="Removing packages..." else: str_label="Removing package..." - if event==PM_TRANS_PROGRESS_CONFLICTS_START: + updateGUI(str_label,progress) + elif event==PM_TRANS_PROGRESS_CONFLICTS_START: if count>1: str_label="Checking packages for file conflicts..." else: str_label="Checking package for file conflicts..." - try: - if str_label<>"": - label_what.set_text(unicode(str_label)) - progress=0 - try : - progress=float(float(percent)/100) - except : - pass - progressbar_install.set_fraction(progress) - draw() - - except : - e = sys.exc_info()[1] - print e + updateGUI(str_label,progress) + else: + pass + if str_label<>"": + print_debug(str_label) + print_debug("fpm_progress_install finish") def fpm_progress_event(*args): print_debug("fpm_progress_event") - global bo_download - label_what=builder.get_object("label_what") - progressbar_install=builder.get_object("progressbar_install") - i=1 - data1=None - data2=None - for arg in args: - if i==1: - event=arg - if i==2: - data1=arg - if i==3: - data2=arg - i=i+1 + try: + i=1 + data1=None + data2=None + for arg in args: + if i==1: + if arg!=None: + event=arg + elif i==2: + if arg!=None: + data1=arg + elif i==3: + if arg!=None: + data2=arg + else: + pass + i=i+1 + print_debug(event) + print_debug(data1) + print_debug(data2) + except : + pass + if event!=PM_TRANS_EVT_RETRIEVE_START and event !=PM_TRANS_EVT_RESOLVEDEPS_START and event !=PM_TRANS_EVT_RESOLVEDEPS_DONE: bo_download=0 - str_data1="" - if data1<>None: - str_data1=pointer_to_string(pacman_pkg_getinfo(data1, PM_PKG_NAME)) str_label="" progress=0 if event==PM_TRANS_EVT_CHECKDEPS_START: - str_label="Checking dependencies" - progress = 1 - if event==PM_TRANS_EVT_FILECONFLICTS_START: - str_label="Checking for file conflicts" - progress = 1 - if event==PM_TRANS_EVT_RESOLVEDEPS_START: - str_label="Resolving dependencies" - if event==PM_TRANS_EVT_INTERCONFLICTS_START: - str_label="Looking for inter-conflicts" - progress = 1 - if event==PM_TRANS_EVT_INTERCONFLICTS_DONE: - str_label="Done" - if event==PM_TRANS_EVT_ADD_START: - str_label="Installing "+str_data1 - progress = 1 - if event==PM_TRANS_EVT_ADD_DONE: - str_label="Package installation finished : "+str_data1 - if event==PM_TRANS_EVT_UPGRADE_START: - str_label="Upgrading "+str_data1 - progress = 1 - if event==PM_TRANS_EVT_UPGRADE_DONE: - str_label="Package upgrade finished" - if event==PM_TRANS_EVT_REMOVE_START: - str_label="removing "+str_data1 - if event==PM_TRANS_EVT_REMOVE_DONE: - str_label="Package removal finished : "+str_data1 - if event==PM_TRANS_EVT_INTEGRITY_START: - str_label="Checking package integrity" - if event==PM_TRANS_EVT_INTEGRITY_DONE: - str_label="Done" - if event==PM_TRANS_EVT_SCRIPTLET_INFO: - str_label=str_data1 - if event==PM_TRANS_EVT_SCRIPTLET_START: - str_label=str_data1 - if event==PM_TRANS_EVT_SCRIPTLET_DONE: - str_label="Done" - if event==PM_TRANS_EVT_RETRIEVE_START: - str_label="Retrieving packages..." - import threading - a = threading.Thread(None, fpm_show_download, None) - a.start() - progress = 1 - try: - if str_label<>"": - label_what.set_text(str_label) - progressbar_install.set_fraction(progress) - #draw() - except : - print "window closed" + str_label="Checking dependencies" + progress = 1 + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_FILECONFLICTS_START: + str_label="Checking for file conflicts" + progress = 1 + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_RESOLVEDEPS_START: + str_label="Resolving dependencies" + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_INTERCONFLICTS_START: + str_label="Looking for inter-conflicts" + progress = 1 + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_INTERCONFLICTS_DONE: + str_label="Done" + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_ADD_START: + str_label="Installing" + progress = 1 + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_ADD_DONE: + str_label="Package installation finished" + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_UPGRADE_START: + str_label="Upgrading "#+pointer_to_string(pacman_pkg_getinfo(data1, PM_PKG_NAME)) + progress = 1 + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_UPGRADE_DONE: + str_label="Package upgrade finished" + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_REMOVE_START: + str_label="removing" + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_REMOVE_DONE: + str_label="Package removal finished" + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_INTEGRITY_START: + str_label="Checking package integrity" + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_INTEGRITY_DONE: + str_label="Done" + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_SCRIPTLET_INFO: + str_label=pointer_to_string(data1) + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_SCRIPTLET_START: + str_label=str_data1 + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_SCRIPTLET_DONE: + str_label="Done" + updateGUI(str_label,progress) + elif event==PM_TRANS_EVT_RETRIEVE_START: + str_label="Retrieving packages...\nPlease wait..." + bo_download=1 + progress = 1 + updateGUI(str_label,progress) + else : + pass + print_debug(str_label) + print_debug("fpm_progress_event finish") - def fpm_trans_conv(*args): print_debug("fpm_trans_conv") i=1 @@ -181,9 +196,7 @@ def fpm_trans_conv(*args): if i == 5: INTP = ctypes.POINTER(ctypes.c_int) response=ctypes.cast(arg, INTP) - i=i+1 - if event==PM_TRANS_CONV_LOCAL_UPTODATE: if print_question(pointer_to_string(pacman_pkg_getinfo(pkg, PM_PKG_NAME))+" local version is up to date. Upgrade anyway? [Y/n]" )==1 : response[0]=1 @@ -192,54 +205,52 @@ def fpm_trans_conv(*args): response[0]=1 if event==PM_TRANS_CONV_CORRUPTED_PKG: if print_question("Archive is corrupted. Do you want to delete it?")==1 : - response[0]=1 + response[0]=1 draw() - -def fpm_show_download(): - label_what=builder.get_object("label_what") - global text_action - label_what.set_text(text_action) - progressbar_install=builder.get_object("progressbar_install") - #FIXME I don't have any args - #globals()["fpm_progress_update"]() don't send arguments - #just change progress bar for user see that download - percent=0 - progress=float(float(percent)/100) - global bo_download - while bo_download==0: - import time - time.sleep(0.5) - percent=percent+10 - progress=float(float(percent)/100) - if percent==100: - percent=0 - progressbar_install.set_fraction(progress) - draw() - def fpm_progress_update(*args): print_debug("fpm_progress_update") - '''import threading - a = threading.Thread(None, fpm_show_download, None) - a.start()''' - ''' - for arg in args: - print arg''' - -def show_action(text): - import threading - global text_action - text_action=text - a = threading.Thread(None, fpm_show_download, None) - a.start() def quit(i): print "bye bye" - global bo_download - bo_download=1 pypacman.pacman_finally() + global bo_finish + bo_finish=1 sys.exit(i) +def updateGUI(str_label,progress): + label_what=builder.get_object("label_what") + progressbar_install=builder.get_object("progressbar_install") + if str_label=="": + return + if str_label==label_what.get_text() and progress == progressbar_install.get_fraction(): + return + print_debug("Update GUI") + label_what.set_text(str_label) + progressbar_install.set_fraction(progress) + draw() + +def hack4305(restore=False): + bo_comment=0 + curl_command="XferCommand = echo %o |sed -r 's/.(fpm|fdb).part$//'; curl -C - --progress-bar -o %o %u YOUR_OPTIONS; echo" + pacmanconf=CFG_FILE + localconf = open(pacmanconf,'r') + text="" + for line in localconf: + if line.find(curl_command)>-1: + if line.find("#")>-1 and restore==False: + text=text+curl_command+"\n" + bo_comment=1 #for know should be restore after installation + if restore: + text=text+"#"+curl_command+"\n" + else: + text=text+line + localconf.close() + #write pacman-g2.conf + localconf = open(pacmanconf,'w') + localconf.write(text) + localconf.close() + return bo_comment class GUIINST: def __init__(self): @@ -247,10 +258,10 @@ class GUIINST: builder.connect_signals(self) main_window = builder.get_object('window') self.label_what=builder.get_object("label_what") + self.progressbar_install=builder.get_object("progressbar_install") if(main_window): main_window.connect("destroy",Gtk.main_quit) main_window.show_all() - draw() self.init() def init(self): @@ -260,17 +271,19 @@ class GUIINST: for pkg in tab_pkgs: self.pacman_remove_pkg (pkg) if bo_install==1: + #4305 hack pacman-g2 the time to fix it + en_restore=hack4305() pypacman.initPacman() - self.pacman_install_pkgs() + self.pacman_install_pkgs() + if en_restore==1: + hack4305(True) if bo_cleancache==1: self.label_what.set_text("clean cache") - show_action("clean cache") draw() pypacman.initPacman() - pacman_sync_cleancache() + pacman_sync_cleancache() if bo_updatedb==1: self.label_what.set_text("update database") - show_action("update database") draw() pypacman.initPacman() pacman_update_db(1) @@ -279,41 +292,43 @@ class GUIINST: quit(0) draw() pypacman.initPacman() - show_action("update database") + self.label_what.set_text("update database") + draw() pacman_update_db(1) tab_pkgs=pacman_check_update() #TODO test if pacman-g2 should be updated and ask to update it in first self.pacman_install_pkgs() quit(0) - - + def destroy(window, self): Gtk.main_quit() - - def pacman_install_pkgs(self): + + def pacman_install_pkgs(self,bo_download=0): self.label_what.set_text("installation") - pacman_set_option (PM_OPT_DLCB, globals()["fpm_progress_update"]()) + #FIXME + #pacman_set_option (PM_OPT_DLCB, globals()["fpm_progress_update"]()) draw() for repo in repo_list : pacman_set_option(PM_OPT_DLFNM, repo) pm_trans=PM_TRANS_TYPE_SYNC - flags=PM_TRANS_FLAG_NOCONFLICTS - + if bo_download==1: + print_debug("Download packages") + flags=PM_TRANS_FLAG_DOWNLOADONLY + else: + flags=PM_TRANS_FLAG_NOCONFLICTS + if pacman_trans_init(pm_trans,flags,pacman_trans_cb_event(fpm_progress_event), pacman_trans_cb_conv(fpm_trans_conv), pacman_trans_cb_progress(fpm_progress_install))== -1 : print_info("pacman_trans_init failed\n"+pacman_get_error()) quit(-1) - for pkg in tab_pkgs: if pacman_trans_addtarget(pkg)==-1 : print_info("Can't add " +pkg+"\n"+pacman_get_error()) quit(-1) - - data=PM_LIST() + data=PM_LIST() if pacman_trans_prepare(data)==-1: print_info("pacman_trans_prepare failed\n"+pacman_get_error()) quit(-1) - if pacman_trans_commit(data)==-1: if pacman_get_pm_error()==pacman_c_long_to_int(PM_ERR_FILE_CONFLICTS): text="Conflicting Files\n" @@ -338,6 +353,7 @@ class GUIINST: else: print_info("pacman_trans_commit failed\n"+pacman_get_error()) quit(-1) + print_debug("Installation finish") pacman_trans_release() def pacman_remove_pkg(self,packagename,removedep=0): @@ -379,6 +395,7 @@ class GUIINST: if pacman_trans_commit(data)==-1: print_info("pacman_trans_commit failed\n"+pacman_get_error()) quit(-1) + print_debug("remove finish") pacman_trans_release() def main(*args): @@ -410,6 +427,6 @@ def main(*args): i=i+1 app = GUIINST() Gtk.main() - + if __name__ == "__main__": sys.exit(main()) diff --git a/py-pacman/pyfpm/src/pyfpminstall.ui b/py-pacman/pyfpm/src/pyfpminstall.ui index ed46323..94f9a99 100644 --- a/py-pacman/pyfpm/src/pyfpminstall.ui +++ b/py-pacman/pyfpm/src/pyfpminstall.ui @@ -5,8 +5,6 @@ <property name="can_focus">False</property> <property name="modal">True</property> <property name="window_position">center-always</property> - <property name="skip_taskbar_hint">True</property> - <property name="skip_pager_hint">True</property> <property name="has_resize_grip">False</property> <child> <object class="GtkBox" id="box1"> _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
