@ -3,9 +3,6 @@
from gi . repository import Gtk
import pyalpm
from os import geteuid
from pamac import config , common , transaction
interface = Gtk . Builder ( )
@ -65,45 +62,6 @@ def set_transaction_add():
#bottom_label.set_markup('<b>Total Download size: </b>'+format_size(totaldlcb))
top_label . set_markup ( ' <big><b>Additionnal Transaction(s)</b></big> ' )
def finalize ( ) :
error = transaction . Prepare ( )
if error :
ErrorDialog . format_secondary_text ( error )
response = ErrorDialog . run ( )
if response :
ErrorDialog . hide ( )
transaction . Release ( )
transaction . t_lock = False
else :
transaction . progress_label . set_text ( ' Preparing... ' )
transaction . action_icon . set_from_file ( ' /usr/share/pamac/icons/24x24/status/setup.png ' )
transaction . ProgressWindow . show_all ( )
while Gtk . events_pending ( ) :
Gtk . main_iteration ( )
transaction . Commit ( reply_handler = handle_reply , error_handler = handle_error , timeout = 2000 * 1000 )
def handle_error ( error ) :
if not ' DBus.Error.NoReply ' in str ( error ) :
transaction . ErrorDialog . format_secondary_text ( ' Commit Error: \n ' + str ( error ) )
response = transaction . ErrorDialog . run ( )
if response :
transaction . ErrorDialog . hide ( )
transaction . t_lock = False
transaction . Release ( )
transaction . ProgressWindow . hide ( )
have_updates ( )
def handle_reply ( reply ) :
if str ( reply ) :
transaction . ErrorDialog . format_secondary_text ( ' Commit Error: \n ' + str ( reply ) )
response = transaction . ErrorDialog . run ( )
if response :
transaction . ErrorDialog . hide ( )
transaction . t_lock = False
transaction . Release ( )
transaction . ProgressWindow . hide ( )
have_updates ( )
def do_sysupgrade ( ) :
""" Upgrade a system like pacman -Su """
if transaction . t_lock is False :
@ -114,12 +72,10 @@ def do_sysupgrade():
transaction . get_to_remove ( )
transaction . get_to_add ( )
set_transaction_add ( )
if len ( transaction . to_add ) != 0 :
if len ( transaction . to_add ) + len ( transaction . to_remove ) != 0 :
ConfDialog . show_all ( )
else :
finalize ( )
transaction . do_syncfirst = False
transaction . list_first = [ ]
else :
if transaction . init_transaction ( ) :
error = transaction . Sysupgrade ( )
@ -134,21 +90,65 @@ def do_sysupgrade():
transaction . get_to_add ( )
transaction . check_conflicts ( )
transaction . Release ( )
if len ( transaction . to_ add) + len ( transaction . to_remov e) == 0 :
if len ( transaction . to_ updat e) == 0 :
transaction . t_lock = False
print ( " Nothing to update " )
else :
if transaction . init_transaction ( noconflicts = True , nodeps = True ) :
for pkgname in transaction . to_update :
transaction . Add ( pkgname )
for pkgname in transaction . to_add :
transaction . Add ( pkgname )
for pkgname in transaction . to_remove :
transaction . Remove ( pkgname )
set_transaction_add ( )
if len ( transaction _add) != 0 :
if len ( transaction . to _add) + len ( transaction . to_remove ) != 0 :
ConfDialog . show_all ( )
else :
finalize ( )
def finalize ( ) :
error = transaction . Prepare ( )
if error :
transaction . ErrorDialog . format_secondary_text ( error )
response = transaction . ErrorDialog . run ( )
if response :
transaction . ErrorDialog . hide ( )
transaction . Release ( )
transaction . t_lock = False
else :
transaction . progress_label . set_text ( ' Preparing... ' )
transaction . action_icon . set_from_file ( ' /usr/share/pamac/icons/24x24/status/setup.png ' )
transaction . ProgressWindow . show_all ( )
while Gtk . events_pending ( ) :
Gtk . main_iteration ( )
transaction . Commit ( reply_handler = handle_reply , error_handler = handle_error , timeout = 2000 * 1000 )
def handle_error ( error ) :
if not ' DBus.Error.NoReply ' in str ( error ) :
transaction . ErrorDialog . format_secondary_text ( ' Commit Error: \n ' + str ( error ) )
response = transaction . ErrorDialog . run ( )
if response :
transaction . ErrorDialog . hide ( )
transaction . t_lock = False
transaction . Release ( )
transaction . ProgressWindow . hide ( )
have_updates ( )
def handle_reply ( reply ) :
if str ( reply ) :
transaction . ErrorDialog . format_secondary_text ( ' Commit Error: \n ' + str ( reply ) )
response = transaction . ErrorDialog . run ( )
if response :
transaction . ErrorDialog . hide ( )
if transaction . do_syncfirst is True :
transaction . do_syncfirst = False
transaction . list_first = [ ]
transaction . t_lock = False
transaction . Release ( )
transaction . ProgressWindow . hide ( )
have_updates ( )
class Handler :
def on_UpdateWindow_delete_event ( self , * arg ) :
transaction . StopDaemon ( )
@ -191,6 +191,8 @@ def main():
have_updates ( )
interface . connect_signals ( Handler ( ) )
UpdateWindow . show_all ( )
while Gtk . events_pending ( ) :
Gtk . main_iteration ( )
if __name__ == " __main__ " :
main ( )