diff --git a/pamac-check_updates.py b/pamac-check_updates.py new file mode 100755 index 0000000..85e7780 --- /dev/null +++ b/pamac-check_updates.py @@ -0,0 +1,40 @@ +#! /usr/bin/python3 +# -*- coding:utf-8 -*- + +# pamac - A Python implementation of alpm +# Copyright (C) 2013 Guillaume Benoit +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +from gi.repository import GObject +from pamac import common, transaction +import dbus + +def handle_updates(updates): + transaction.StopDaemon() + loop.quit() + +loop = GObject.MainLoop() + +if not common.pid_file_exists(): + bus = dbus.SystemBus() + bus.add_signal_receiver(handle_updates, dbus_interface = "org.manjaro.pamac", signal_name = "EmitAvailableUpdates") + transaction.get_dbus_methods() + try: + transaction.CheckUpdates() + except: + pass + else: + loop.run() diff --git a/pamac-daemon.py b/pamac-daemon.py index 993be1d..bd03833 100755 --- a/pamac-daemon.py +++ b/pamac-daemon.py @@ -465,10 +465,10 @@ class PamacDBusService(dbus.service.Object): if self.local_packages: self.aur_updates_pkgs = aur.multiinfo(self.local_packages) self.aur_updates_checked = True - for aur_pkg in self.aur_updates_pkgs: - comp = pyalpm.vercmp(aur_pkg.version, self.localdb.get_pkg(aur_pkg.name).version) - if comp == 1: - updates.append((aur_pkg.name, aur_pkg.version, aur_pkg.db.name, aur_pkg.tarpath, aur_pkg.download_size)) + for aur_pkg in self.aur_updates_pkgs: + comp = pyalpm.vercmp(aur_pkg.version, self.localdb.get_pkg(aur_pkg.name).version) + if comp == 1: + updates.append((aur_pkg.name, aur_pkg.version, aur_pkg.db.name, aur_pkg.tarpath, aur_pkg.download_size)) self.EmitAvailableUpdates((syncfirst, updates)) @dbus.service.method('org.manjaro.pamac', 'b', '') diff --git a/pamac-refresh.py b/pamac-refresh.py index b1b3c4c..2f6fdfc 100755 --- a/pamac-refresh.py +++ b/pamac-refresh.py @@ -29,16 +29,19 @@ def handle_reply(reply): def handle_error(error): transaction.StopDaemon() + common.rm_pid_file() print('check updates failed') loop.quit() def handle_updates(updates): + common.rm_pid_file() transaction.StopDaemon() loop.quit() loop = GObject.MainLoop() if not common.pid_file_exists(): + common.write_pid_file() print('checking updates') bus = dbus.SystemBus() bus.add_signal_receiver(handle_reply, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionDone") diff --git a/pamac-tray.py b/pamac-tray.py old mode 100644 new mode 100755 index 2929ac5..e8f0b4f --- a/pamac-tray.py +++ b/pamac-tray.py @@ -23,6 +23,7 @@ from subprocess import call import dbus from dbus.mainloop.glib import DBusGMainLoop from threading import Thread +from time import sleep from pamac import common @@ -92,6 +93,24 @@ class Tray: def refresh(): Thread(target = call, args = (['/usr/bin/pamac-refresh'],)).start() + return True + +def check_updates(): + Thread(target = call, args = (['/usr/bin/pamac-check_updates'],)).start() + +locked = False +def check_pacman_running(): + global locked + if locked: + if not common.lock_file_exists(): + locked = False + check_updates() + else: + if common.lock_file_exists(): + if not common.pid_file_exists(): + locked = True + sleep(0.5) + return True def set_icon(update_data): global icon @@ -118,4 +137,5 @@ tray = Tray() Notify.init(_('Update Manager')) refresh() GObject.timeout_add(3*3600*1000, refresh) +GObject.idle_add(check_pacman_running) Gtk.main() diff --git a/pamac-updater.py b/pamac-updater.py old mode 100644 new mode 100755 diff --git a/pamac/common.py b/pamac/common.py index 2ae6335..00e3096 100644 --- a/pamac/common.py +++ b/pamac/common.py @@ -49,6 +49,9 @@ from pamac import config pid_file = '/tmp/pamac.pid' lock_file = join(config.pacman_conf.options['DBPath'], 'db.lck') +def lock_file_exists(): + return isfile(lock_file) + def pid_file_exists(): return isfile(pid_file) diff --git a/po/id.po b/po/id.po index 86b41d3..e9a6df2 100644 --- a/po/id.po +++ b/po/id.po @@ -343,7 +343,7 @@ msgstr "Beberapa pemutakhiran tersedia.\nHarap mutakhirkan sistem terlebih dahul msgid "" "{pkgname} is provided by {number} packages.\n" "Please choose those you would like to install:" -msgstr "{pkgname{ disediakan oleh {number} paket.\nHarap pilih yang ingin kamu instal:" +msgstr "{pkgname} disediakan oleh {number} paket.\nHarap pilih yang ingin kamu instal:" #: pamac/transaction.py:233 msgid "Refreshing"