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