forked from cromer/pamac-classic
good progress
This commit is contained in:
parent
79ce2f61c5
commit
fa9c44aec8
@ -1,10 +1,13 @@
|
||||
#! /usr/bin/python
|
||||
# -*-coding:utf-8-*-
|
||||
|
||||
from pamac import transaction
|
||||
from pamac import common, transaction
|
||||
|
||||
print('check_updates')
|
||||
transaction.get_handle()
|
||||
transaction.Refresh()
|
||||
transaction.CheckUpdates()
|
||||
transaction.StopDaemon()
|
||||
if not common.pid_file_exists():
|
||||
print('checking updates')
|
||||
common.write_pid_file()
|
||||
transaction.Refresh()
|
||||
transaction.TransactionDone()
|
||||
transaction.StopDaemon()
|
||||
common.rm_pid_file()
|
||||
print('check updates done')
|
||||
|
43
pamac-tray
43
pamac-tray
@ -1,12 +1,13 @@
|
||||
#! /usr/bin/python
|
||||
# -*-coding:utf-8-*-
|
||||
|
||||
from gi.repository import Gtk
|
||||
from subprocess import Popen
|
||||
from gi.repository import Gtk, GObject
|
||||
from subprocess import call
|
||||
from pamac import transaction
|
||||
import dbus
|
||||
import threading
|
||||
|
||||
GObject.threads_init()
|
||||
bus = dbus.SystemBus()
|
||||
|
||||
class Tray:
|
||||
@ -28,10 +29,10 @@ class Tray:
|
||||
self.statusIcon.connect('popup-menu', self.popup_menu_cb, self.menu)
|
||||
|
||||
def execute_update(self, widget, event, data = None):
|
||||
Popen(['/usr/bin/pamac-updater'])
|
||||
call(['/usr/bin/pamac-updater'])
|
||||
|
||||
def execute_manager(self, widget, event, data = None):
|
||||
Popen(['/usr/bin/pamac-manager'])
|
||||
call(['/usr/bin/pamac-manager'])
|
||||
|
||||
def quit_tray(self, widget, data = None):
|
||||
t.shutdown()
|
||||
@ -52,7 +53,7 @@ class PeriodicTask(threading.Thread):
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
self._finished = threading.Event()
|
||||
self._interval = 60
|
||||
self._interval = 30
|
||||
|
||||
def setInterval(self, interval):
|
||||
"""Set the number of seconds we sleep between executing our task"""
|
||||
@ -71,10 +72,11 @@ class PeriodicTask(threading.Thread):
|
||||
self._finished.wait(self._interval)
|
||||
|
||||
def task(self):
|
||||
Popen(['/usr/bin/pamac-check-updates'])
|
||||
call(['/usr/bin/pamac-check-updates'])
|
||||
|
||||
def set_icon(*arg):
|
||||
print('set-icon')
|
||||
transaction.get_handle()
|
||||
do_syncfirst, updates = transaction.get_updates()
|
||||
if updates:
|
||||
icon = '/usr/share/pamac/icons/24x24/status/update-normal.png'
|
||||
@ -82,32 +84,13 @@ def set_icon(*arg):
|
||||
else:
|
||||
icon = '/usr/share/pamac/icons/24x24/status/update-enhancement.png'
|
||||
info = ' No update available'
|
||||
print(info)
|
||||
tray.update_icon(icon, info)
|
||||
|
||||
def handle_error(error):
|
||||
global tray
|
||||
print('error',error)
|
||||
icon = '/usr/share/pamac/icons/24x24/status/update-enhancement.png'
|
||||
info = ' No update available'
|
||||
tray = Tray()
|
||||
tray.update_icon(icon, info)
|
||||
transaction.StopDaemon()
|
||||
bus.add_signal_receiver(set_icon, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionDone")
|
||||
|
||||
def handle_reply(reply):
|
||||
global tray
|
||||
tray = Tray()
|
||||
set_icon()
|
||||
transaction.StopDaemon()
|
||||
|
||||
def do_refresh():
|
||||
"""Sync databases like pacman -Sy"""
|
||||
transaction.get_handle()
|
||||
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||
|
||||
bus.add_signal_receiver(set_icon, dbus_interface = "org.manjaro.pamac", signal_name = "EmitAvailableUpdates")
|
||||
|
||||
tray = None
|
||||
do_refresh()
|
||||
tray = Tray()
|
||||
#set_icon()
|
||||
t = PeriodicTask()
|
||||
t.start()
|
||||
#Gtk.main()
|
||||
Gtk.main()
|
||||
|
@ -259,7 +259,7 @@ def handle_error(error):
|
||||
transaction.to_remove = []
|
||||
transaction_dict.clear()
|
||||
transaction_type = None
|
||||
transaction.get_handle()
|
||||
transaction.update_db()
|
||||
set_packages_list()
|
||||
if mode == 'updater':
|
||||
have_updates()
|
||||
@ -276,10 +276,11 @@ def handle_reply(reply):
|
||||
transaction.t_lock = False
|
||||
transaction.Release()
|
||||
transaction.ProgressWindow.hide()
|
||||
transaction.TransactionDone()
|
||||
transaction.to_add = []
|
||||
transaction.to_remove = []
|
||||
transaction_dict.clear()
|
||||
transaction.get_handle()
|
||||
transaction.update_db()
|
||||
if (transaction_type == "install") or (transaction_type == "remove"):
|
||||
transaction_type = None
|
||||
set_packages_list()
|
||||
@ -384,7 +385,6 @@ def finalize():
|
||||
def check_conflicts(pkg_list):
|
||||
depends = [pkg_list]
|
||||
warning = ''
|
||||
#transaction.get_handle()
|
||||
pkgs = transaction.handle.get_localdb().search('linux3')
|
||||
installed_linux = []
|
||||
for i in pkgs:
|
||||
@ -479,16 +479,17 @@ def check_conflicts(pkg_list):
|
||||
for replace in pkg.replaces:
|
||||
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), replace)
|
||||
if provide:
|
||||
if provide.name != pkg.name:
|
||||
if not pkg.name in transaction.localpkgs.keys():
|
||||
if common.format_pkg_name(replace) in transaction.localpkgs.keys():
|
||||
if not provide.name in transaction.to_remove:
|
||||
transaction.to_remove.append(provide.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+provide.name+' will be replaced by '+pkg.name
|
||||
if not pkg.name in transaction.to_add:
|
||||
transaction.to_add.append(pkg.name)
|
||||
if not common.format_pkg_name(replace) in transaction.syncpkgs.keys():
|
||||
if provide.name != pkg.name:
|
||||
if not pkg.name in transaction.localpkgs.keys():
|
||||
if common.format_pkg_name(replace) in transaction.localpkgs.keys():
|
||||
if not provide.name in transaction.to_remove:
|
||||
transaction.to_remove.append(provide.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+provide.name+' will be replaced by '+pkg.name
|
||||
if not pkg.name in transaction.to_add:
|
||||
transaction.to_add.append(pkg.name)
|
||||
print(transaction.to_add,transaction.to_remove)
|
||||
if warning:
|
||||
transaction.WarningDialog.format_secondary_text(warning)
|
||||
|
@ -176,16 +176,13 @@ class PamacDBusService(dbus.service.Object):
|
||||
return error
|
||||
|
||||
@dbus.service.signal('org.manjaro.pamac')
|
||||
def EmitAvailableUpdates(self, available_updates):
|
||||
def EmitTransactionDone(self, done):
|
||||
pass
|
||||
|
||||
@dbus.service.method('org.manjaro.pamac', '', '')
|
||||
def CheckUpdates(self):
|
||||
for pkg in config.handle.get_localdb().pkgcache:
|
||||
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
|
||||
if candidate:
|
||||
self.EmitAvailableUpdates(True)
|
||||
return
|
||||
def TransactionDone(self):
|
||||
self.EmitTransactionDone(True)
|
||||
return
|
||||
|
||||
@dbus.service.method('org.manjaro.pamac', 'a{sb}', 's', sender_keyword='sender', connection_keyword='connexion')
|
||||
def Init(self, options, sender=None, connexion=None):
|
||||
|
@ -33,11 +33,15 @@ ProgressCancelButton = interface.get_object('ProgressCancelButton')
|
||||
|
||||
def get_handle():
|
||||
global handle
|
||||
handle = config.pacman_conf.initialize_alpm()
|
||||
print('get handle')
|
||||
|
||||
def update_db():
|
||||
get_handle()
|
||||
global syncpkgs
|
||||
global localpkgs
|
||||
syncpkgs = OrderedDict()
|
||||
localpkgs = OrderedDict()
|
||||
handle = config.pacman_conf.initialize_alpm()
|
||||
for repo in handle.get_syncdbs():
|
||||
for pkg in repo.pkgcache:
|
||||
if not pkg.name in syncpkgs.keys():
|
||||
@ -45,13 +49,11 @@ def get_handle():
|
||||
for pkg in handle.get_localdb().pkgcache:
|
||||
if not pkg.name in localpkgs.keys():
|
||||
localpkgs[pkg.name] = pkg
|
||||
print('get handle')
|
||||
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
bus = dbus.SystemBus()
|
||||
proxy = bus.get_object('org.manjaro.pamac','/org/manjaro/pamac', introspect=False)
|
||||
Refresh = proxy.get_dbus_method('Refresh','org.manjaro.pamac')
|
||||
CheckUpdates = proxy.get_dbus_method('CheckUpdates','org.manjaro.pamac')
|
||||
Init = proxy.get_dbus_method('Init','org.manjaro.pamac')
|
||||
Sysupgrade = proxy.get_dbus_method('Sysupgrade','org.manjaro.pamac')
|
||||
Remove = proxy.get_dbus_method('Remove','org.manjaro.pamac')
|
||||
@ -61,6 +63,7 @@ To_Remove = proxy.get_dbus_method('To_Remove','org.manjaro.pamac')
|
||||
To_Add = proxy.get_dbus_method('To_Add','org.manjaro.pamac')
|
||||
Commit = proxy.get_dbus_method('Commit','org.manjaro.pamac')
|
||||
Release = proxy.get_dbus_method('Release','org.manjaro.pamac')
|
||||
TransactionDone = proxy.get_dbus_method('TransactionDone','org.manjaro.pamac')
|
||||
StopDaemon = proxy.get_dbus_method('StopDaemon','org.manjaro.pamac')
|
||||
|
||||
def action_signal_handler(action):
|
||||
@ -115,12 +118,11 @@ def get_updates():
|
||||
"""Return a list of package objects in local db which can be updated"""
|
||||
do_syncfirst = False
|
||||
list_first = []
|
||||
#get_handle()
|
||||
#update_db()
|
||||
if config.syncfirst:
|
||||
for name in config.syncfirst:
|
||||
pkg = handle.get_localdb().get_pkg(name)
|
||||
if pkg:
|
||||
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
||||
if name in localpkgs.keys():
|
||||
candidate = pyalpm.sync_newversion(localpkgs[name], handle.get_syncdbs())
|
||||
if candidate:
|
||||
for repo in handle.get_syncdbs():
|
||||
pkg = repo.get_pkg(candidate.name)
|
||||
|
Loading…
Reference in New Issue
Block a user