forked from cromer/pamac-classic
work in progress
This commit is contained in:
parent
5b50e92cc8
commit
a9d1c0ed93
@ -5,4 +5,3 @@ Description=Pamac
|
|||||||
Type=dbus
|
Type=dbus
|
||||||
BusName=org.manjaro.pamac
|
BusName=org.manjaro.pamac
|
||||||
ExecStart=/usr/bin/start-pamac-daemon
|
ExecStart=/usr/bin/start-pamac-daemon
|
||||||
RemainAfterExit=Yes
|
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
<object class="GtkImage" id="action_icon">
|
<object class="GtkImage" id="action_icon">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="pixbuf">/usr/share/icons/hicolor/24x24/status/setup.png</property>
|
<property name="pixbuf">/usr/share/pamac/icons/24x24/status/setup.png</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -210,7 +210,7 @@
|
|||||||
<object class="GtkImage" id="image1">
|
<object class="GtkImage" id="image1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="pixbuf">/usr/share/icons/hicolor/48x48/status/package-update.png</property>
|
<property name="pixbuf">/usr/share/pamac/icons/48x48/status/package-update.png</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
0
pamac-updater
Executable file → Normal file
0
pamac-updater
Executable file → Normal file
@ -1,121 +0,0 @@
|
|||||||
#! /usr/bin/python
|
|
||||||
# -*-coding:utf-8-*-
|
|
||||||
|
|
||||||
from gi.repository import Gtk
|
|
||||||
import pyalpm
|
|
||||||
from pamac import config
|
|
||||||
|
|
||||||
handle = config.handle
|
|
||||||
|
|
||||||
# Callbacks
|
|
||||||
interface = Gtk.Builder()
|
|
||||||
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
|
||||||
|
|
||||||
ProgressWindow = interface.get_object('ProgressWindow')
|
|
||||||
progress_bar = interface.get_object('progressbar2')
|
|
||||||
progress_label = interface.get_object('progresslabel2')
|
|
||||||
action_icon = interface.get_object('action_icon')
|
|
||||||
|
|
||||||
event_text = ' '
|
|
||||||
def cb_event(ID, event, tupel):
|
|
||||||
global event_text
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
if ID is 1:
|
|
||||||
progress_label.set_text('Checking dependencies')
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
|
||||||
elif ID is 3:
|
|
||||||
progress_label.set_text('Checking file conflicts')
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
|
||||||
elif ID is 5:
|
|
||||||
progress_label.set_text('Resolving dependencies')
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
|
||||||
elif ID is 7:
|
|
||||||
progress_label.set_text('Checking inter conflicts')
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
|
||||||
elif ID is 9:
|
|
||||||
progress_label.set_text('Installing packages')
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-add.png')
|
|
||||||
elif ID is 11:
|
|
||||||
progress_label.set_text('Removing packages')
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-delete.png')
|
|
||||||
elif ID is 13:
|
|
||||||
progress_label.set_text('Upgrading packages')
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-update.png')
|
|
||||||
elif ID is 15:
|
|
||||||
progress_label.set_text('Checking integrity')
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
|
||||||
elif ID is 17:
|
|
||||||
progress_label.set_text('Checking signatures')
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
|
||||||
print('Checking signatures')
|
|
||||||
elif ID is 27:
|
|
||||||
print('Downloading a file')
|
|
||||||
else :
|
|
||||||
progress_label.set_text('')
|
|
||||||
progress_bar.set_fraction(0.0)
|
|
||||||
progress_bar.set_text('')
|
|
||||||
print(ID,event)
|
|
||||||
|
|
||||||
def cb_conv(*args):
|
|
||||||
print("conversation", args)
|
|
||||||
|
|
||||||
_logmask = pyalpm.LOG_ERROR | pyalpm.LOG_WARNING
|
|
||||||
|
|
||||||
def cb_log(level, line):
|
|
||||||
#global t
|
|
||||||
if not (level & _logmask):
|
|
||||||
return
|
|
||||||
if level & pyalpm.LOG_ERROR:
|
|
||||||
ErrorDialog.format_secondary_text("ERROR: "+line)
|
|
||||||
response = ErrorDialog.run()
|
|
||||||
if response:
|
|
||||||
ErrorDialog.hide()
|
|
||||||
#t.release()
|
|
||||||
elif level & pyalpm.LOG_WARNING:
|
|
||||||
WarningDialog.format_secondary_text("WARNING: "+line)
|
|
||||||
response = WarningDialog.run()
|
|
||||||
if response:
|
|
||||||
WarningDialog.hide()
|
|
||||||
elif level & pyalpm.LOG_DEBUG:
|
|
||||||
line = "DEBUG: " + line
|
|
||||||
print(line)
|
|
||||||
elif level & pyalpm.LOG_FUNCTION:
|
|
||||||
line = "FUNC: " + line
|
|
||||||
print(line)
|
|
||||||
|
|
||||||
total_size = 0
|
|
||||||
def totaldlcb(_total_size):
|
|
||||||
global total_size
|
|
||||||
total_size = _total_size
|
|
||||||
|
|
||||||
already_transferred = 0
|
|
||||||
def cb_dl(_target, _transferred, total):
|
|
||||||
global already_transferred
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
if total_size > 0:
|
|
||||||
fraction = (_transferred+already_transferred)/total_size
|
|
||||||
size = 0
|
|
||||||
if (to_remove or to_add):
|
|
||||||
for pkg in to_remove+to_add:
|
|
||||||
if pkg.name+'-'+pkg.version in _target:
|
|
||||||
size = pkg.size
|
|
||||||
if _transferred == size:
|
|
||||||
already_transferred += size
|
|
||||||
progress_label.set_text('Downloading '+format_size(total_size))
|
|
||||||
progress_bar.set_text(_target)
|
|
||||||
progress_bar.set_fraction(fraction)
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-download.png')
|
|
||||||
else:
|
|
||||||
progress_label.set_text('Refreshing...')
|
|
||||||
progress_bar.set_text(_target)
|
|
||||||
progress_bar.pulse()
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
|
|
||||||
|
|
||||||
def cb_progress(_target, _percent, n, i):
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
target = _target+' ('+str(i)+'/'+str(n)+')'
|
|
||||||
progress_bar.set_fraction(_percent/100)
|
|
||||||
progress_bar.set_text(target)
|
|
23
pamac/common.py
Normal file
23
pamac/common.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#! /usr/bin/python
|
||||||
|
# -*-coding:utf-8-*-
|
||||||
|
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
interface = Gtk.Builder()
|
||||||
|
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
||||||
|
|
||||||
|
ErrorDialog = interface.get_object('ErrorDialog')
|
||||||
|
WarningDialog = interface.get_object('WarningDialog')
|
||||||
|
|
||||||
|
to_remove = []
|
||||||
|
to_add = []
|
||||||
|
to_update = []
|
||||||
|
|
||||||
|
def format_size(size):
|
||||||
|
KiB_size = size / 1024
|
||||||
|
if KiB_size < 1000:
|
||||||
|
size_string = '%.1f KiB' % (KiB_size)
|
||||||
|
return size_string
|
||||||
|
else:
|
||||||
|
size_string = '%.2f MiB' % (KiB_size / 1024)
|
||||||
|
return size_string
|
0
pamac/config.py
Executable file → Normal file
0
pamac/config.py
Executable file → Normal file
114
pamac/manager.py
Executable file → Normal file
114
pamac/manager.py
Executable file → Normal file
@ -1,7 +1,7 @@
|
|||||||
#! /usr/bin/python
|
#! /usr/bin/python
|
||||||
# -*-coding:utf-8 -*-
|
# -*-coding:utf-8 -*-
|
||||||
|
|
||||||
from gi.repository import Gtk, GdkPixbuf, Gdk, GObject
|
from gi.repository import Gtk
|
||||||
|
|
||||||
import pyalpm
|
import pyalpm
|
||||||
import math
|
import math
|
||||||
@ -10,7 +10,7 @@ from time import strftime, localtime
|
|||||||
from os import geteuid
|
from os import geteuid
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from pamac import transaction, config, callbacks
|
from pamac import config, common, transaction
|
||||||
|
|
||||||
interface = Gtk.Builder()
|
interface = Gtk.Builder()
|
||||||
interface.add_from_file('/usr/share/pamac/gui/manager.glade')
|
interface.add_from_file('/usr/share/pamac/gui/manager.glade')
|
||||||
@ -66,7 +66,6 @@ def set_list_dict_search(*patterns):
|
|||||||
pkg_object_dict[pkg_object.name] = pkg_object
|
pkg_object_dict[pkg_object.name] = pkg_object
|
||||||
pkg_installed_dict[pkg_object.name] = False
|
pkg_installed_dict[pkg_object.name] = False
|
||||||
for pkg_object in config.pacman_conf.initialize_alpm().get_localdb().search(*patterns):
|
for pkg_object in config.pacman_conf.initialize_alpm().get_localdb().search(*patterns):
|
||||||
print(pkg_object)
|
|
||||||
if not pkg_object.name in pkg_name_list:
|
if not pkg_object.name in pkg_name_list:
|
||||||
pkg_name_list.append(pkg_object.name)
|
pkg_name_list.append(pkg_object.name)
|
||||||
pkg_installed_dict[pkg_object.name] = True
|
pkg_installed_dict[pkg_object.name] = True
|
||||||
@ -126,7 +125,6 @@ def refresh_packages_list():
|
|||||||
packages_list.append([name, pkg_installed_dict[name], True])
|
packages_list.append([name, pkg_installed_dict[name], True])
|
||||||
else:
|
else:
|
||||||
packages_list.append([name, pkg_installed_dict[name], True])
|
packages_list.append([name, pkg_installed_dict[name], True])
|
||||||
print(name,pkg_installed_dict[name])
|
|
||||||
|
|
||||||
def set_packages_list():
|
def set_packages_list():
|
||||||
global list_dict
|
global list_dict
|
||||||
@ -165,10 +163,10 @@ def set_desc(pkg, style):
|
|||||||
package_desc.append(['Conflicts With:', ' '.join(pkg.conflicts)])
|
package_desc.append(['Conflicts With:', ' '.join(pkg.conflicts)])
|
||||||
package_desc.append(['Replaces:', ' '.join(pkg.replaces)])
|
package_desc.append(['Replaces:', ' '.join(pkg.replaces)])
|
||||||
if style == 'sync':
|
if style == 'sync':
|
||||||
package_desc.append(['Download Size:', transaction.format_size(pkg.size)])
|
package_desc.append(['Download Size:', common.format_size(pkg.size)])
|
||||||
if style == 'file':
|
if style == 'file':
|
||||||
package_desc.append(['Compressed Size:', transaction.format_size(pkg.size)])
|
package_desc.append(['Compressed Size:', common.format_size(pkg.size)])
|
||||||
package_desc.append(['Installed Size:', transaction.format_size(pkg.isize)])
|
package_desc.append(['Installed Size:', common.format_size(pkg.isize)])
|
||||||
package_desc.append(['Packager:', pkg.packager])
|
package_desc.append(['Packager:', pkg.packager])
|
||||||
package_desc.append(['Architecture:', pkg.arch])
|
package_desc.append(['Architecture:', pkg.arch])
|
||||||
package_desc.append(['Build Date:', strftime("%a %d %b %Y %X %Z", localtime(pkg.builddate))])
|
package_desc.append(['Build Date:', strftime("%a %d %b %Y %X %Z", localtime(pkg.builddate))])
|
||||||
@ -197,35 +195,35 @@ def set_desc(pkg, style):
|
|||||||
|
|
||||||
def set_transaction_sum():
|
def set_transaction_sum():
|
||||||
transaction_sum.clear()
|
transaction_sum.clear()
|
||||||
if transaction.to_remove:
|
if common.to_remove:
|
||||||
transaction_sum.append(['To remove:', transaction.to_remove[0]])
|
transaction_sum.append(['To remove:', common.to_remove[0]])
|
||||||
i = 1
|
i = 1
|
||||||
while i < len(transaction.to_remove):
|
while i < len(common.to_remove):
|
||||||
transaction_sum.append([' ', transaction.to_remove[i]])
|
transaction_sum.append([' ', common.to_remove[i]])
|
||||||
i += 1
|
i += 1
|
||||||
bottom_label.set_markup('')
|
bottom_label.set_markup('')
|
||||||
if transaction.to_add:
|
if common.to_add:
|
||||||
installed = []
|
installed = []
|
||||||
for pkg_object in callbacks.handle.get_localdb().pkgcache:
|
for pkg_object in config.pacman_conf.initialize_alpm().get_localdb().pkgcache:
|
||||||
installed.append(pkg_object.name)
|
installed.append(pkg_object.name)
|
||||||
transaction.to_update = sorted(set(installed).intersection(transaction.to_add))
|
common.to_update = sorted(set(installed).intersection(common.to_add))
|
||||||
to_remove_from_add = sorted(set(transaction.to_update).intersection(transaction.to_add))
|
to_remove_from_add = sorted(set(common.to_update).intersection(common.to_add))
|
||||||
for name in to_remove_from_add:
|
for name in to_remove_from_add:
|
||||||
transaction.to_add.remove(name)
|
common.to_add.remove(name)
|
||||||
if transaction.to_add:
|
if common.to_add:
|
||||||
transaction_sum.append(['To install:', transaction.to_add[0]])
|
transaction_sum.append(['To install:', common.to_add[0]])
|
||||||
i = 1
|
i = 1
|
||||||
while i < len(transaction.to_add):
|
while i < len(common.to_add):
|
||||||
transaction_sum.append([' ', transaction.to_add[i]])
|
transaction_sum.append([' ', common.to_add[i]])
|
||||||
i += 1
|
i += 1
|
||||||
if transaction.to_update:
|
if common.to_update:
|
||||||
transaction_sum.append(['To update:', transaction.to_update[0]])
|
transaction_sum.append(['To update:', common.to_update[0]])
|
||||||
i = 1
|
i = 1
|
||||||
while i < len(transaction.to_update):
|
while i < len(common.to_update):
|
||||||
transaction_sum.append([' ', transaction.to_update[i]])
|
transaction_sum.append([' ', common.to_update[i]])
|
||||||
i += 1
|
i += 1
|
||||||
bottom_label.set_markup('')
|
bottom_label.set_markup('')
|
||||||
#bottom_label.set_markup('<b>Total Download size: </b>'+format_size(totaldlcb))
|
#bottom_label.set_markup('<b>Total Download size: </b>'+common.format_size(totaldlcb))
|
||||||
top_label.set_markup('<big><b>Transaction Summary</b></big>')
|
top_label.set_markup('<big><b>Transaction Summary</b></big>')
|
||||||
|
|
||||||
class Handler:
|
class Handler:
|
||||||
@ -261,33 +259,33 @@ class Handler:
|
|||||||
print('Transaction locked')
|
print('Transaction locked')
|
||||||
else:
|
else:
|
||||||
if transaction_type is "remove":
|
if transaction_type is "remove":
|
||||||
transaction.init_transaction(cascade = True)
|
if transaction.init_transaction(cascade = True):
|
||||||
for pkgname in transaction_dict.keys():
|
for pkgname in transaction_dict.keys():
|
||||||
transaction.Remove(pkgname)
|
transaction.Remove(pkgname)
|
||||||
error = transaction.Prepare()
|
error = transaction.Prepare()
|
||||||
if error:
|
if error:
|
||||||
transaction.ErrorDialog.format_secondary_text(error)
|
transaction.ErrorDialog.format_secondary_text(error)
|
||||||
response = transaction.ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
transaction.ErrorDialog.hide()
|
transaction.ErrorDialog.hide()
|
||||||
transaction.Release()
|
transaction.Release()
|
||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
transaction.get_to_remove()
|
transaction.get_to_remove()
|
||||||
transaction.get_to_add()
|
transaction.get_to_add()
|
||||||
set_transaction_sum()
|
set_transaction_sum()
|
||||||
ConfDialog.show_all()
|
ConfDialog.show_all()
|
||||||
if transaction_type is "install":
|
if transaction_type is "install":
|
||||||
transaction.init_transaction(noconflicts = True)
|
if transaction.init_transaction(noconflicts = True):
|
||||||
for pkgname in transaction_dict.keys():
|
for pkgname in transaction_dict.keys():
|
||||||
transaction.Add(pkgname)
|
transaction.Add(pkgname)
|
||||||
error = transaction.Prepare()
|
error = transaction.Prepare()
|
||||||
if error:
|
if error:
|
||||||
transaction.ErrorDialog.format_secondary_text(error)
|
transaction.ErrorDialog.format_secondary_text(error)
|
||||||
response = transaction.ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
transaction.ErrorDialog.hide()
|
transaction.ErrorDialog.hide()
|
||||||
transaction.Release()
|
transaction.Release()
|
||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
transaction.get_to_remove()
|
transaction.get_to_remove()
|
||||||
transaction.get_to_add()
|
transaction.get_to_add()
|
||||||
transaction.check_conflicts()
|
transaction.check_conflicts()
|
||||||
@ -324,13 +322,15 @@ class Handler:
|
|||||||
if response:
|
if response:
|
||||||
transaction.ErrorDialog.hide()
|
transaction.ErrorDialog.hide()
|
||||||
transaction.Release()
|
transaction.Release()
|
||||||
|
common.to_add = []
|
||||||
|
common.to_remove = []
|
||||||
if transaction_type is "install":
|
if transaction_type is "install":
|
||||||
transaction.init_transaction(noconflicts = True, nodeps = True)
|
if transaction.init_transaction(noconflicts = True, nodeps = True):
|
||||||
for pkgname in transaction.to_add:
|
for pkgname in common.to_add:
|
||||||
transaction.Add(pkgname)
|
transaction.Add(pkgname)
|
||||||
for pkgname in transaction.to_remove:
|
for pkgname in common.to_remove:
|
||||||
transaction.Remove(pkgname)
|
transaction.Remove(pkgname)
|
||||||
transaction.finalize()
|
transaction.finalize()
|
||||||
transaction_dict.clear()
|
transaction_dict.clear()
|
||||||
transaction_type = None
|
transaction_type = None
|
||||||
set_packages_list()
|
set_packages_list()
|
||||||
|
143
pamac/pamac-daemon.py
Executable file → Normal file
143
pamac/pamac-daemon.py
Executable file → Normal file
@ -8,13 +8,124 @@ from gi.repository import GObject, Gtk
|
|||||||
|
|
||||||
import pyalpm
|
import pyalpm
|
||||||
import traceback
|
import traceback
|
||||||
from pamac import config, callbacks
|
from pamac import config, common
|
||||||
|
|
||||||
loop = GObject.MainLoop()
|
loop = GObject.MainLoop()
|
||||||
|
|
||||||
t = None
|
t = None
|
||||||
error = ''
|
error = ''
|
||||||
|
|
||||||
|
interface = Gtk.Builder()
|
||||||
|
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
||||||
|
|
||||||
|
ProgressWindow = interface.get_object('ProgressWindow')
|
||||||
|
progress_bar = interface.get_object('progressbar2')
|
||||||
|
progress_label = interface.get_object('progresslabel2')
|
||||||
|
action_icon = interface.get_object('action_icon')
|
||||||
|
|
||||||
|
def cb_event(ID, event, tupel):
|
||||||
|
while Gtk.events_pending():
|
||||||
|
Gtk.main_iteration()
|
||||||
|
if ID is 1:
|
||||||
|
progress_label.set_text('Checking dependencies')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
||||||
|
elif ID is 3:
|
||||||
|
progress_label.set_text('Checking file conflicts')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
||||||
|
elif ID is 5:
|
||||||
|
progress_label.set_text('Resolving dependencies')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
||||||
|
elif ID is 7:
|
||||||
|
progress_label.set_text('Checking inter conflicts')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
||||||
|
elif ID is 9:
|
||||||
|
progress_label.set_text('Installing packages')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-add.png')
|
||||||
|
elif ID is 11:
|
||||||
|
progress_label.set_text('Removing packages')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-delete.png')
|
||||||
|
elif ID is 13:
|
||||||
|
progress_label.set_text('Upgrading packages')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-update.png')
|
||||||
|
elif ID is 15:
|
||||||
|
progress_label.set_text('Checking integrity')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
||||||
|
elif ID is 17:
|
||||||
|
progress_label.set_text('Checking signatures')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-search.png')
|
||||||
|
print('Checking signatures')
|
||||||
|
elif ID is 27:
|
||||||
|
print('Downloading a file')
|
||||||
|
else :
|
||||||
|
progress_label.set_text('')
|
||||||
|
progress_bar.set_fraction(0.0)
|
||||||
|
progress_bar.set_text('')
|
||||||
|
print(ID,event)
|
||||||
|
|
||||||
|
def cb_conv(*args):
|
||||||
|
print("conversation", args)
|
||||||
|
|
||||||
|
_logmask = pyalpm.LOG_ERROR | pyalpm.LOG_WARNING
|
||||||
|
|
||||||
|
def cb_log(level, line):
|
||||||
|
#global t
|
||||||
|
if not (level & _logmask):
|
||||||
|
return
|
||||||
|
if level & pyalpm.LOG_ERROR:
|
||||||
|
common.ErrorDialog.format_secondary_text("ERROR: "+line)
|
||||||
|
response = common.ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
common.ErrorDialog.hide()
|
||||||
|
#t.release()
|
||||||
|
elif level & pyalpm.LOG_WARNING:
|
||||||
|
common.WarningDialog.format_secondary_text("WARNING: "+line)
|
||||||
|
response = common.WarningDialog.run()
|
||||||
|
if response:
|
||||||
|
common.WarningDialog.hide()
|
||||||
|
elif level & pyalpm.LOG_DEBUG:
|
||||||
|
line = "DEBUG: " + line
|
||||||
|
print(line)
|
||||||
|
elif level & pyalpm.LOG_FUNCTION:
|
||||||
|
line = "FUNC: " + line
|
||||||
|
print(line)
|
||||||
|
|
||||||
|
total_size = 0
|
||||||
|
def totaldlcb(_total_size):
|
||||||
|
global total_size
|
||||||
|
total_size = _total_size
|
||||||
|
|
||||||
|
already_transferred = 0
|
||||||
|
def cb_dl(_target, _transferred, total):
|
||||||
|
global already_transferred
|
||||||
|
while Gtk.events_pending():
|
||||||
|
Gtk.main_iteration()
|
||||||
|
if total_size > 0:
|
||||||
|
fraction = (_transferred+already_transferred)/total_size
|
||||||
|
size = 0
|
||||||
|
if (t.to_remove or t.to_add):
|
||||||
|
for pkg in t.to_remove+t.to_add:
|
||||||
|
if pkg.name+'-'+pkg.version in _target:
|
||||||
|
size = pkg.size
|
||||||
|
if _transferred == size:
|
||||||
|
already_transferred += size
|
||||||
|
progress_label.set_text('Downloading '+common.format_size(total_size))
|
||||||
|
progress_bar.set_text(_target)
|
||||||
|
progress_bar.set_fraction(fraction)
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/package-download.png')
|
||||||
|
else:
|
||||||
|
progress_label.set_text('Refreshing...')
|
||||||
|
progress_bar.set_text(_target)
|
||||||
|
progress_bar.pulse()
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
|
||||||
|
|
||||||
|
def cb_progress(_target, _percent, n, i):
|
||||||
|
while Gtk.events_pending():
|
||||||
|
Gtk.main_iteration()
|
||||||
|
target = _target+' ('+str(i)+'/'+str(n)+')'
|
||||||
|
progress_bar.set_fraction(_percent/100)
|
||||||
|
progress_bar.set_text(target)
|
||||||
|
|
||||||
|
|
||||||
class PamacDBusService(dbus.service.Object):
|
class PamacDBusService(dbus.service.Object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
bus=dbus.SystemBus()
|
bus=dbus.SystemBus()
|
||||||
@ -40,14 +151,14 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
global error
|
global error
|
||||||
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
||||||
error = ''
|
error = ''
|
||||||
|
config.handle.dlcb = cb_dl
|
||||||
|
config.handle.totaldlcb = totaldlcb
|
||||||
|
config.handle.eventcb = cb_event
|
||||||
|
config.handle.questioncb = cb_conv
|
||||||
|
config.handle.progresscb = cb_progress
|
||||||
|
config.handle.logcb = cb_log
|
||||||
try:
|
try:
|
||||||
callbacks.handle.dlcb = callbacks.cb_dl
|
t = config.handle.init_transaction(**options)
|
||||||
callbacks.handle.totaldlcb = callbacks.totaldlcb
|
|
||||||
callbacks.handle.eventcb = callbacks.cb_event
|
|
||||||
callbacks.handle.questioncb = callbacks.cb_conv
|
|
||||||
callbacks.handle.progresscb = callbacks.cb_progress
|
|
||||||
callbacks.handle.logcb = callbacks.cb_log
|
|
||||||
t = callbacks.handle.init_transaction(**options)
|
|
||||||
print('Init:',t.flags)
|
print('Init:',t.flags)
|
||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
error = traceback.format_exc()
|
error = traceback.format_exc()
|
||||||
@ -62,7 +173,7 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
global error
|
global error
|
||||||
error = ''
|
error = ''
|
||||||
try:
|
try:
|
||||||
pkg = callbacks.handle.get_localdb().get_pkg(pkgname)
|
pkg = config.handle.get_localdb().get_pkg(pkgname)
|
||||||
if pkg is not None:
|
if pkg is not None:
|
||||||
t.remove_pkg(pkg)
|
t.remove_pkg(pkg)
|
||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
@ -76,7 +187,7 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
global error
|
global error
|
||||||
error = ''
|
error = ''
|
||||||
try:
|
try:
|
||||||
for repo in callbacks.handle.get_syncdbs():
|
for repo in config.handle.get_syncdbs():
|
||||||
pkg = repo.get_pkg(pkgname)
|
pkg = repo.get_pkg(pkgname)
|
||||||
if pkg:
|
if pkg:
|
||||||
t.add_pkg(pkg)
|
t.add_pkg(pkg)
|
||||||
@ -93,11 +204,11 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
error = ''
|
error = ''
|
||||||
try:
|
try:
|
||||||
t.prepare()
|
t.prepare()
|
||||||
|
print('to_add:',t.to_add)
|
||||||
|
print('to_remove:',t.to_remove)
|
||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
error = traceback.format_exc()
|
error = traceback.format_exc()
|
||||||
finally:
|
finally:
|
||||||
print('to_add:',t.to_add)
|
|
||||||
print('to_remove:',t.to_remove)
|
|
||||||
return error
|
return error
|
||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', '', 'as')
|
@dbus.service.method('org.manjaro.pamac', '', 'as')
|
||||||
@ -121,10 +232,10 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
global t
|
global t
|
||||||
global error
|
global error
|
||||||
if self.policykit_test(sender,connexion,'org.manjaro.pamac.commit'):
|
if self.policykit_test(sender,connexion,'org.manjaro.pamac.commit'):
|
||||||
|
ProgressWindow.show_all()
|
||||||
|
while Gtk.events_pending():
|
||||||
|
Gtk.main_iteration()
|
||||||
try:
|
try:
|
||||||
callbacks.ProgressWindow.show_all()
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
t.commit()
|
t.commit()
|
||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
error = traceback.format_exc()
|
error = traceback.format_exc()
|
||||||
@ -139,8 +250,8 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
global error
|
global error
|
||||||
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
||||||
error = ''
|
error = ''
|
||||||
|
ProgressWindow.hide()
|
||||||
try:
|
try:
|
||||||
callbacks.ProgressWindow.hide()
|
|
||||||
t.release()
|
t.release()
|
||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
error = traceback.format_exc()
|
error = traceback.format_exc()
|
||||||
|
102
pamac/transaction.py
Executable file → Normal file
102
pamac/transaction.py
Executable file → Normal file
@ -7,20 +7,9 @@ import pyalpm
|
|||||||
import traceback
|
import traceback
|
||||||
import dbus
|
import dbus
|
||||||
|
|
||||||
from pamac import config, callbacks
|
from pamac import config, common
|
||||||
|
|
||||||
interface = Gtk.Builder()
|
|
||||||
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
|
||||||
|
|
||||||
ErrorDialog = interface.get_object('ErrorDialog')
|
|
||||||
WarningDialog = interface.get_object('WarningDialog')
|
|
||||||
|
|
||||||
t = None
|
|
||||||
t_lock = False
|
t_lock = False
|
||||||
conflict_to_remove = None
|
|
||||||
to_remove = None
|
|
||||||
to_add = None
|
|
||||||
to_update = None
|
|
||||||
do_syncfirst = False
|
do_syncfirst = False
|
||||||
list_first = []
|
list_first = []
|
||||||
|
|
||||||
@ -37,28 +26,22 @@ Release = proxy.get_dbus_method('Release','org.manjaro.pamac')
|
|||||||
def init_transaction(**options):
|
def init_transaction(**options):
|
||||||
"Transaction initialization"
|
"Transaction initialization"
|
||||||
global t_lock
|
global t_lock
|
||||||
global proxy
|
|
||||||
error = Init(options)
|
error = Init(options)
|
||||||
print(error)
|
|
||||||
if not error:
|
if not error:
|
||||||
t_lock = True
|
t_lock = True
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
ErrorDialog.format_secondary_text(error)
|
common.ErrorDialog.format_secondary_text(error)
|
||||||
response = ErrorDialog.run()
|
response = common.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
ErrorDialog.hide()
|
common.ErrorDialog.hide()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_conflicts():
|
def check_conflicts():
|
||||||
global conflict_to_remove
|
|
||||||
global to_add
|
|
||||||
global to_remove
|
|
||||||
conflict_to_remove = {}
|
|
||||||
to_check = []
|
to_check = []
|
||||||
warning = ''
|
warning = ''
|
||||||
for pkgname in to_add:
|
for pkgname in common.to_add:
|
||||||
for repo in callbacks.handle.get_syncdbs():
|
for repo in config.pacman_conf.initialize_alpm().get_syncdbs():
|
||||||
pkg = repo.get_pkg(pkgname)
|
pkg = repo.get_pkg(pkgname)
|
||||||
if pkg:
|
if pkg:
|
||||||
to_check.append(pkg)
|
to_check.append(pkg)
|
||||||
@ -66,38 +49,36 @@ def check_conflicts():
|
|||||||
for target in to_check:
|
for target in to_check:
|
||||||
if target.replaces:
|
if target.replaces:
|
||||||
for name in target.replaces:
|
for name in target.replaces:
|
||||||
pkg = callbacks.handle.get_localdb().get_pkg(name)
|
pkg = config.pacman_conf.initialize_alpm().get_localdb().get_pkg(name)
|
||||||
if pkg:
|
if pkg:
|
||||||
if not pkg.name in to_remove:
|
if not pkg.name in common.to_remove:
|
||||||
to_remove.append(pkg.name)
|
common.to_remove.append(pkg.name)
|
||||||
if warning:
|
if warning:
|
||||||
warning = warning+'\n'
|
warning = warning+'\n'
|
||||||
warning = warning+pkg.name+' will be replaced by '+target.name
|
warning = warning+pkg.name+' will be replaced by '+target.name
|
||||||
if target.conflicts:
|
if target.conflicts:
|
||||||
for name in target.conflicts:
|
for name in target.conflicts:
|
||||||
pkg = callbacks.handle.get_localdb().get_pkg(name)
|
pkg = config.pacman_conf.initialize_alpm().get_localdb().get_pkg(name)
|
||||||
if pkg:
|
if pkg:
|
||||||
if not pkg.name in to_remove:
|
if not pkg.name in common.to_remove:
|
||||||
to_remove.append(pkg.name)
|
common.to_remove.append(pkg.name)
|
||||||
for installed_pkg in callbacks.handle.get_localdb().pkgcache:
|
for installed_pkg in config.pacman_conf.initialize_alpm().get_localdb().pkgcache:
|
||||||
if installed_pkg.conflicts:
|
if installed_pkg.conflicts:
|
||||||
for name in installed_pkg.conflicts:
|
for name in installed_pkg.conflicts:
|
||||||
if name == target.name:
|
if name == target.name:
|
||||||
if not name in to_remove:
|
if not name in common.to_remove:
|
||||||
to_remove.append(installed_pkg.name)
|
common.to_remove.append(installed_pkg.name)
|
||||||
if warning:
|
if warning:
|
||||||
WarningDialog.format_secondary_text(warning)
|
common.WarningDialog.format_secondary_text(warning)
|
||||||
response = WarningDialog.run()
|
response = common.WarningDialog.run()
|
||||||
if response:
|
if response:
|
||||||
WarningDialog.hide()
|
common.WarningDialog.hide()
|
||||||
|
|
||||||
def get_to_remove():
|
def get_to_remove():
|
||||||
global to_remove
|
common.to_remove = To_Remove()
|
||||||
to_remove = To_Remove()
|
|
||||||
|
|
||||||
def get_to_add():
|
def get_to_add():
|
||||||
global to_add
|
common.to_add = To_Add()
|
||||||
to_add = To_Add()
|
|
||||||
|
|
||||||
def finalize():
|
def finalize():
|
||||||
global t_lock
|
global t_lock
|
||||||
@ -105,24 +86,26 @@ def finalize():
|
|||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
error = Prepare()
|
error = Prepare()
|
||||||
if error:
|
if error:
|
||||||
ErrorDialog.format_secondary_text(error)
|
common.ErrorDialog.format_secondary_text(error)
|
||||||
response = ErrorDialog.run()
|
response = common.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
transaction.ErrorDialog.hide()
|
common.ErrorDialog.hide()
|
||||||
error = Commit()
|
error = Commit()
|
||||||
if error:
|
if error:
|
||||||
ErrorDialog.format_secondary_text(error)
|
common.ErrorDialog.format_secondary_text(error)
|
||||||
response = ErrorDialog.run()
|
response = common.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
transaction.ErrorDialog.hide()
|
common.ErrorDialog.hide()
|
||||||
t_lock = False
|
t_lock = False
|
||||||
Release()
|
Release()
|
||||||
|
common.to_add = []
|
||||||
|
common.to_remove = []
|
||||||
|
|
||||||
def do_refresh():
|
def do_refresh():
|
||||||
"""Sync databases like pacman -Sy"""
|
"""Sync databases like pacman -Sy"""
|
||||||
global t
|
global t
|
||||||
global t_lock
|
global t_lock
|
||||||
for db in callbacks.handle.get_syncdbs():
|
for db in config.pacman_conf.initialize_alpm().get_syncdbs():
|
||||||
if t_lock is False:
|
if t_lock is False:
|
||||||
t = init_transaction()
|
t = init_transaction()
|
||||||
try:
|
try:
|
||||||
@ -130,15 +113,13 @@ def do_refresh():
|
|||||||
t.release()
|
t.release()
|
||||||
t_lock = False
|
t_lock = False
|
||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
ErrorDialog.format_secondary_text(traceback.format_exc())
|
common.ErrorDialog.format_secondary_text(traceback.format_exc())
|
||||||
response = ErrorDialog.run()
|
response = common.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
ErrorDialog.hide()
|
common.ErrorDialog.hide()
|
||||||
t_lock = False
|
t_lock = False
|
||||||
break
|
break
|
||||||
t_lock = False
|
t_lock = False
|
||||||
progress_label.set_text('')
|
|
||||||
progress_bar.set_text('')
|
|
||||||
|
|
||||||
def get_updates():
|
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"""
|
||||||
@ -146,33 +127,24 @@ def get_updates():
|
|||||||
global list_first
|
global list_first
|
||||||
if config.syncfirst:
|
if config.syncfirst:
|
||||||
for name in config.syncfirst:
|
for name in config.syncfirst:
|
||||||
pkg = callbacks.handle.get_localdb().get_pkg(name)
|
pkg = config.pacman_conf.initialize_alpm().get_localdb().get_pkg(name)
|
||||||
candidate = pyalpm.sync_newversion(pkg, callbacks.handle.get_syncdbs())
|
candidate = pyalpm.sync_newversion(pkg, config.pacman_conf.initialize_alpm().get_syncdbs())
|
||||||
if candidate:
|
if candidate:
|
||||||
list_first.append(candidate)
|
list_first.append(candidate)
|
||||||
if list_first:
|
if list_first:
|
||||||
do_syncfirst = True
|
do_syncfirst = True
|
||||||
return list_first
|
return list_first
|
||||||
result = []
|
result = []
|
||||||
installed_pkglist = callbacks.handle.get_localdb().pkgcache
|
installed_pkglist = config.pacman_conf.initialize_alpm().get_localdb().pkgcache
|
||||||
for pkg in installed_pkglist:
|
for pkg in installed_pkglist:
|
||||||
candidate = pyalpm.sync_newversion(pkg, callbacks.handle.get_syncdbs())
|
candidate = pyalpm.sync_newversion(pkg, config.pacman_conf.initialize_alpm().get_syncdbs())
|
||||||
if candidate:
|
if candidate:
|
||||||
result.append(candidate)
|
result.append(candidate)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_new_version_available(pkgname):
|
def get_new_version_available(pkgname):
|
||||||
for repo in callbacks.handle.get_syncdbs():
|
for repo in config.pacman_conf.initialize_alpm().get_syncdbs():
|
||||||
pkg = repo.get_pkg(pkgname)
|
pkg = repo.get_pkg(pkgname)
|
||||||
if pkg is not None:
|
if pkg is not None:
|
||||||
return pkg.version
|
return pkg.version
|
||||||
break
|
break
|
||||||
|
|
||||||
def format_size(size):
|
|
||||||
KiB_size = size / 1024
|
|
||||||
if KiB_size < 1000:
|
|
||||||
size_string = '%.1f KiB' % (KiB_size)
|
|
||||||
return size_string
|
|
||||||
else:
|
|
||||||
size_string = '%.2f MiB' % (KiB_size / 1024)
|
|
||||||
return size_string
|
|
||||||
|
0
pamac/tray.py
Executable file → Normal file
0
pamac/tray.py
Executable file → Normal file
0
pamac/updater.py
Executable file → Normal file
0
pamac/updater.py
Executable file → Normal file
@ -1,3 +1,3 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
DISPLAY=:0.0 pamac-daemon.py &
|
DISPLAY=:0.0 /usr/lib/python3.3/site-packages/pamac/pamac-daemon.py
|
||||||
|
Loading…
Reference in New Issue
Block a user