forked from cromer/pamac-classic
working update manager
This commit is contained in:
parent
6aaa0494a1
commit
1a65d11a37
@ -10,6 +10,7 @@ import collections
|
|||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import pyalpm
|
import pyalpm
|
||||||
|
from transaction import ErrorDialog
|
||||||
|
|
||||||
class InvalidSyntax(Warning):
|
class InvalidSyntax(Warning):
|
||||||
def __init__(self, filename, problem, arg):
|
def __init__(self, filename, problem, arg):
|
||||||
@ -111,6 +112,10 @@ def cb_log(level, line):
|
|||||||
if not (level & _logmask):
|
if not (level & _logmask):
|
||||||
return
|
return
|
||||||
if level & pyalpm.LOG_ERROR:
|
if level & pyalpm.LOG_ERROR:
|
||||||
|
ErrorDialog.format_secondary_text(line)
|
||||||
|
response = ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
ErrorDialog.hide()
|
||||||
line = "ERROR: " + line
|
line = "ERROR: " + line
|
||||||
elif level & pyalpm.LOG_WARNING:
|
elif level & pyalpm.LOG_WARNING:
|
||||||
line = "WARNING: " + line
|
line = "WARNING: " + line
|
||||||
|
@ -1,6 +1,111 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<!-- interface-requires gtk+ 3.0 -->
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
|
<object class="GtkMessageDialog" id="ConfDialog">
|
||||||
|
<property name="width_request">250</property>
|
||||||
|
<property name="height_request">150</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<property name="border_width">5</property>
|
||||||
|
<property name="title" translatable="yes"> </property>
|
||||||
|
<property name="window_position">center-on-parent</property>
|
||||||
|
<property name="default_width">200</property>
|
||||||
|
<property name="default_height">100</property>
|
||||||
|
<property name="type_hint">dialog</property>
|
||||||
|
<property name="skip_taskbar_hint">True</property>
|
||||||
|
<property name="message_type">other</property>
|
||||||
|
<property name="buttons">ok-cancel</property>
|
||||||
|
<property name="text" translatable="yes"><b>Transaction summary</b></property>
|
||||||
|
<property name="use_markup">True</property>
|
||||||
|
<child internal-child="vbox">
|
||||||
|
<object class="GtkBox" id="messagedialog-vbox3">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child internal-child="action_area">
|
||||||
|
<object class="GtkButtonBox" id="messagedialog-action_area3">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkScrolledWindow" id="scrolledwindow4">
|
||||||
|
<property name="width_request">200</property>
|
||||||
|
<property name="height_request">120</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<property name="shadow_type">in</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeView" id="treeview4">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<property name="model">transaction_desc</property>
|
||||||
|
<property name="headers_visible">False</property>
|
||||||
|
<property name="headers_clickable">False</property>
|
||||||
|
<property name="enable_search">False</property>
|
||||||
|
<property name="search_column">0</property>
|
||||||
|
<child internal-child="selection">
|
||||||
|
<object class="GtkTreeSelection" id="treeview-selection"/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="_action">
|
||||||
|
<property name="title" translatable="yes">column</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererText" id="cellrenderertext5">
|
||||||
|
<property name="yalign">0</property>
|
||||||
|
<property name="weight">600</property>
|
||||||
|
</object>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">0</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="_packages">
|
||||||
|
<property name="title" translatable="yes">column</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererText" id="cellrenderertext6"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">1</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="down_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">label</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">4</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
<object class="GtkMessageDialog" id="ErrorDialog">
|
<object class="GtkMessageDialog" id="ErrorDialog">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="border_width">5</property>
|
<property name="border_width">5</property>
|
||||||
@ -81,4 +186,12 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkListStore" id="transaction_desc">
|
||||||
|
<columns>
|
||||||
|
<!-- column-name action -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name packages -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
</columns>
|
||||||
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
117
gui/pamac.glade
117
gui/pamac.glade
@ -1,115 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<!-- interface-requires gtk+ 3.0 -->
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
<object class="GtkMessageDialog" id="ConfDialog">
|
|
||||||
<property name="width_request">250</property>
|
|
||||||
<property name="height_request">150</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="border_width">5</property>
|
|
||||||
<property name="title" translatable="yes"> </property>
|
|
||||||
<property name="window_position">center-on-parent</property>
|
|
||||||
<property name="default_width">200</property>
|
|
||||||
<property name="default_height">100</property>
|
|
||||||
<property name="type_hint">dialog</property>
|
|
||||||
<property name="skip_taskbar_hint">True</property>
|
|
||||||
<property name="message_type">other</property>
|
|
||||||
<property name="buttons">ok-cancel</property>
|
|
||||||
<property name="text" translatable="yes"><b>Transaction summary</b></property>
|
|
||||||
<property name="use_markup">True</property>
|
|
||||||
<child internal-child="vbox">
|
|
||||||
<object class="GtkBox" id="messagedialog-vbox3">
|
|
||||||
<property name="width_request">240</property>
|
|
||||||
<property name="height_request">140</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child internal-child="action_area">
|
|
||||||
<object class="GtkButtonBox" id="messagedialog-action_area3">
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="has_focus">True</property>
|
|
||||||
<property name="is_focus">True</property>
|
|
||||||
<property name="layout_style">end</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkScrolledWindow" id="scrolledwindow4">
|
|
||||||
<property name="width_request">200</property>
|
|
||||||
<property name="height_request">120</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="shadow_type">in</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTreeView" id="treeview4">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="model">transaction_desc</property>
|
|
||||||
<property name="headers_visible">False</property>
|
|
||||||
<property name="headers_clickable">False</property>
|
|
||||||
<property name="enable_search">False</property>
|
|
||||||
<child internal-child="selection">
|
|
||||||
<object class="GtkTreeSelection" id="treeview-selection1"/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTreeViewColumn" id="_action">
|
|
||||||
<property name="title" translatable="yes">column</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext5">
|
|
||||||
<property name="yalign">0</property>
|
|
||||||
<property name="weight">600</property>
|
|
||||||
</object>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="text">0</attribute>
|
|
||||||
</attributes>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTreeViewColumn" id="_packages">
|
|
||||||
<property name="title" translatable="yes">column</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext6"/>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="text">1</attribute>
|
|
||||||
</attributes>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="down_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">label</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<object class="GtkListStore" id="groups_list">
|
<object class="GtkListStore" id="groups_list">
|
||||||
<columns>
|
<columns>
|
||||||
<!-- column-name name -->
|
<!-- column-name name -->
|
||||||
@ -504,12 +395,4 @@
|
|||||||
</row>
|
</row>
|
||||||
</data>
|
</data>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkListStore" id="transaction_desc">
|
|
||||||
<columns>
|
|
||||||
<!-- column-name action -->
|
|
||||||
<column type="gchararray"/>
|
|
||||||
<!-- column-name packages -->
|
|
||||||
<column type="gchararray"/>
|
|
||||||
</columns>
|
|
||||||
</object>
|
|
||||||
</interface>
|
</interface>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<!-- interface-requires gtk+ 3.0 -->
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
<object class="GtkWindow" id="MainWindow">
|
<object class="GtkWindow" id="UpdateWindow">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title" translatable="yes"> </property>
|
<property name="title" translatable="yes">Update Manager</property>
|
||||||
<property name="window_position">center</property>
|
<property name="window_position">center</property>
|
||||||
<signal name="delete-event" handler="on_MainWindow_delete_event" swapped="no"/>
|
<signal name="delete-event" handler="on_UpdateWindow_delete_event" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box1">
|
<object class="GtkBox" id="box1">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
@ -15,22 +15,23 @@
|
|||||||
<property name="spacing">2</property>
|
<property name="spacing">2</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButtonBox" id="buttonbox1">
|
<object class="GtkButtonBox" id="buttonbox1">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="has_focus">True</property>
|
||||||
<property name="spacing">5</property>
|
<property name="spacing">5</property>
|
||||||
<property name="layout_style">end</property>
|
<property name="layout_style">end</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="RefreshButton">
|
<object class="GtkButton" id="ApplyButton">
|
||||||
<property name="label">gtk-refresh</property>
|
<property name="label">gtk-apply</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<signal name="clicked" handler="on_RefreshButton_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_ApplyButton_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">0</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -42,21 +43,6 @@
|
|||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<signal name="clicked" handler="on_QuitButton_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_QuitButton_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="ApplyButton">
|
|
||||||
<property name="label">gtk-apply</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<signal name="clicked" handler="on_ApplyButton_clicked" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
@ -89,10 +75,9 @@
|
|||||||
<property name="width_request">390</property>
|
<property name="width_request">390</property>
|
||||||
<property name="height_request">490</property>
|
<property name="height_request">490</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="vexpand">True</property>
|
<property name="vexpand">True</property>
|
||||||
<property name="shadow_type">in</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeView" id="treeview1">
|
<object class="GtkTreeView" id="treeview1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
70
pamac.py
70
pamac.py
@ -18,19 +18,13 @@ interface.add_from_file('gui/dialogs.glade')
|
|||||||
|
|
||||||
packages_list = interface.get_object('packages_list')
|
packages_list = interface.get_object('packages_list')
|
||||||
groups_list = interface.get_object('groups_list')
|
groups_list = interface.get_object('groups_list')
|
||||||
transaction_desc = interface.get_object('transaction_desc')
|
|
||||||
package_desc = interface.get_object('package_desc')
|
package_desc = interface.get_object('package_desc')
|
||||||
conf_label = interface.get_object('conf_label')
|
|
||||||
toggle = interface.get_object('cellrenderertoggle1')
|
toggle = interface.get_object('cellrenderertoggle1')
|
||||||
search_entry = interface.get_object('search_entry')
|
search_entry = interface.get_object('search_entry')
|
||||||
tree2 = interface.get_object('treeview2_selection')
|
tree2 = interface.get_object('treeview2_selection')
|
||||||
tree1 = interface.get_object('treeview1_selection')
|
tree1 = interface.get_object('treeview1_selection')
|
||||||
installed_column = interface.get_object('installed_column')
|
installed_column = interface.get_object('installed_column')
|
||||||
name_column = interface.get_object('name_column')
|
name_column = interface.get_object('name_column')
|
||||||
ConfDialog = interface.get_object('ConfDialog')
|
|
||||||
ErrorDialog = interface.get_object('ErrorDialog')
|
|
||||||
down_label = interface.get_object('down_label')
|
|
||||||
|
|
||||||
installed_column.set_sort_column_id(1)
|
installed_column.set_sort_column_id(1)
|
||||||
name_column.set_sort_column_id(0)
|
name_column.set_sort_column_id(0)
|
||||||
|
|
||||||
@ -204,19 +198,17 @@ class Handler:
|
|||||||
global t
|
global t
|
||||||
global transaction_type
|
global transaction_type
|
||||||
global transaction_dict
|
global transaction_dict
|
||||||
global transaction_desc
|
|
||||||
if not geteuid() == 0:
|
if not geteuid() == 0:
|
||||||
ErrorDialog.format_secondary_text("You need to be root to run packages transactions")
|
transaction.ErrorDialog.format_secondary_text("You need to be root to run packages transactions")
|
||||||
response = ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
ErrorDialog.hide()
|
transaction.ErrorDialog.hide()
|
||||||
elif not transaction_dict:
|
elif not transaction_dict:
|
||||||
ErrorDialog.format_secondary_text("No package is selected")
|
transaction.ErrorDialog.format_secondary_text("No package is selected")
|
||||||
response = ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
ErrorDialog.hide()
|
transaction.ErrorDialog.hide()
|
||||||
else:
|
else:
|
||||||
transaction_desc.clear()
|
|
||||||
t = transaction.init_transaction(config.handle)
|
t = transaction.init_transaction(config.handle)
|
||||||
if transaction_type is "install":
|
if transaction_type is "install":
|
||||||
for pkg in transaction_dict.values():
|
for pkg in transaction_dict.values():
|
||||||
@ -227,47 +219,24 @@ class Handler:
|
|||||||
try:
|
try:
|
||||||
t.prepare()
|
t.prepare()
|
||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
ErrorDialog.format_secondary_text(traceback.format_exc())
|
transaction.ErrorDialog.format_secondary_text(traceback.format_exc())
|
||||||
response = ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
ErrorDialog.hide()
|
transaction.ErrorDialog.hide()
|
||||||
t.release()
|
t.release()
|
||||||
transaction.to_remove = t.to_remove
|
transaction.to_remove = t.to_remove
|
||||||
transaction.to_add = t.to_add
|
transaction.to_add = t.to_add
|
||||||
if transaction.to_remove:
|
transaction.set_transaction_desc('normal')
|
||||||
transaction_desc.append(['To remove:', transaction.to_remove[0].name])
|
response = transaction.ConfDialog.run()
|
||||||
i = 1
|
|
||||||
while i < len(transaction.to_remove):
|
|
||||||
transaction_desc.append([' ', transaction.to_remove[i].name])
|
|
||||||
i += 1
|
|
||||||
down_label.set_markup('')
|
|
||||||
if transaction.to_add:
|
|
||||||
transaction_desc.append(['To install:', transaction.to_add[0].name])
|
|
||||||
i = 1
|
|
||||||
dsize = transaction.to_add[0].size
|
|
||||||
while i < len(transaction.to_add):
|
|
||||||
transaction_desc.append([' ', transaction.to_add[i].name])
|
|
||||||
dsize += transaction.to_add[i].download_size
|
|
||||||
i += 1
|
|
||||||
down_label.set_markup('<b>Total Download size: </b>'+transaction.format_size(dsize))
|
|
||||||
response = ConfDialog.run()
|
|
||||||
if response == Gtk.ResponseType.OK:
|
if response == Gtk.ResponseType.OK:
|
||||||
ConfDialog.hide()
|
transaction.t_finalize(t)
|
||||||
try:
|
|
||||||
t.commit()
|
|
||||||
except pyalpm.error:
|
|
||||||
ErrorDialog.format_secondary_text(traceback.format_exc())
|
|
||||||
response = ErrorDialog.run()
|
|
||||||
if response:
|
|
||||||
ErrorDialog.hide()
|
|
||||||
t.release()
|
|
||||||
transaction_dict.clear()
|
transaction_dict.clear()
|
||||||
transaction_type = None
|
transaction_type = None
|
||||||
set_packages_list()
|
set_packages_list()
|
||||||
transaction.ProgressWindow.hide()
|
transaction.ProgressWindow.hide()
|
||||||
if response == Gtk.ResponseType.CANCEL or Gtk.ResponseType.CLOSE or Gtk.ResponseType.DELETE_EVENT:
|
if response == Gtk.ResponseType.CANCEL or Gtk.ResponseType.CLOSE or Gtk.ResponseType.DELETE_EVENT:
|
||||||
transaction.ProgressWindow.hide()
|
transaction.ProgressWindow.hide()
|
||||||
ConfDialog.hide()
|
transaction.ConfDialog.hide()
|
||||||
t.release()
|
t.release()
|
||||||
|
|
||||||
def on_EraseButton_clicked(self, *arg):
|
def on_EraseButton_clicked(self, *arg):
|
||||||
@ -360,9 +329,10 @@ class Handler:
|
|||||||
packages_list[line][1] = not packages_list[line][1]
|
packages_list[line][1] = not packages_list[line][1]
|
||||||
packages_list[line][2] = True
|
packages_list[line][2] = True
|
||||||
|
|
||||||
#if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
transaction.do_refresh()
|
if geteuid() == 0:
|
||||||
interface.connect_signals(Handler())
|
transaction.do_refresh()
|
||||||
MainWindow = interface.get_object("MainWindow")
|
interface.connect_signals(Handler())
|
||||||
MainWindow.show_all()
|
MainWindow = interface.get_object("MainWindow")
|
||||||
Gtk.main()
|
MainWindow.show_all()
|
||||||
|
Gtk.main()
|
||||||
|
@ -6,7 +6,6 @@ from gi.repository import Gtk, GdkPixbuf, Gdk
|
|||||||
import pyalpm
|
import pyalpm
|
||||||
from time import strftime, localtime
|
from time import strftime, localtime
|
||||||
from os import geteuid
|
from os import geteuid
|
||||||
import sys
|
|
||||||
import config
|
import config
|
||||||
import transaction
|
import transaction
|
||||||
|
|
||||||
@ -19,6 +18,7 @@ top_label = interface.get_object('top_label')
|
|||||||
|
|
||||||
def have_updates():
|
def have_updates():
|
||||||
available_updates = transaction.get_updates()
|
available_updates = transaction.get_updates()
|
||||||
|
update_listore.clear()
|
||||||
if not available_updates:
|
if not available_updates:
|
||||||
update_listore.append(["", ""])
|
update_listore.append(["", ""])
|
||||||
return False
|
return False
|
||||||
@ -31,14 +31,15 @@ def have_updates():
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
class Handler:
|
class Handler:
|
||||||
def on_MainWindow_delete_event(self, *arg):
|
def on_UpdateWindow_delete_event(self, *arg):
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
||||||
def on_QuitButton_clicked(self, *arg):
|
def on_QuitButton_clicked(self, *arg):
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
||||||
def on_ApplyButton_clicked(self, *arg):
|
def on_ApplyButton_clicked(self, *arg):
|
||||||
print("Apply")
|
transaction.do_sysupgrade()
|
||||||
|
have_updates()
|
||||||
|
|
||||||
def on_RefreshButton_clicked(self, *arg):
|
def on_RefreshButton_clicked(self, *arg):
|
||||||
transaction.do_refresh()
|
transaction.do_refresh()
|
||||||
@ -52,9 +53,11 @@ def main():
|
|||||||
else:
|
else:
|
||||||
top_label.set_markup("<big><b>Available updates</b></big>")
|
top_label.set_markup("<big><b>Available updates</b></big>")
|
||||||
interface.connect_signals(Handler())
|
interface.connect_signals(Handler())
|
||||||
MainWindow = interface.get_object("MainWindow")
|
UpdateWindow = interface.get_object("UpdateWindow")
|
||||||
MainWindow.show_all()
|
UpdateWindow.show_all()
|
||||||
Gtk.main()
|
Gtk.main()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
if geteuid() == 0:
|
||||||
|
transaction.do_refresh()
|
||||||
main()
|
main()
|
||||||
|
139
transaction.py
139
transaction.py
@ -4,8 +4,7 @@
|
|||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
import pyalpm
|
import pyalpm
|
||||||
import math
|
import traceback
|
||||||
import sys
|
|
||||||
import config
|
import config
|
||||||
|
|
||||||
interface = Gtk.Builder()
|
interface = Gtk.Builder()
|
||||||
@ -14,9 +13,16 @@ interface.add_from_file('gui/dialogs.glade')
|
|||||||
ProgressWindow = interface.get_object('ProgressWindow')
|
ProgressWindow = interface.get_object('ProgressWindow')
|
||||||
progress_bar = interface.get_object('progressbar2')
|
progress_bar = interface.get_object('progressbar2')
|
||||||
progress_label = interface.get_object('progresslabel2')
|
progress_label = interface.get_object('progresslabel2')
|
||||||
|
ErrorDialog = interface.get_object('ErrorDialog')
|
||||||
|
ConfDialog = interface.get_object('ConfDialog')
|
||||||
|
transaction_desc = interface.get_object('transaction_desc')
|
||||||
|
down_label = interface.get_object('down_label')
|
||||||
|
|
||||||
to_remove = None
|
to_remove = None
|
||||||
to_add = None
|
to_add = None
|
||||||
|
to_update = None
|
||||||
|
do_syncfirst = False
|
||||||
|
list_first = []
|
||||||
|
|
||||||
def init_transaction(handle):
|
def init_transaction(handle):
|
||||||
"Transaction initialization"
|
"Transaction initialization"
|
||||||
@ -54,23 +60,77 @@ def do_refresh():
|
|||||||
|
|
||||||
def do_sysupgrade():
|
def do_sysupgrade():
|
||||||
"""Upgrade a system like pacman -Su"""
|
"""Upgrade a system like pacman -Su"""
|
||||||
|
global to_remove
|
||||||
|
global to_add
|
||||||
|
global to_update
|
||||||
t = init_transaction(config.handle)
|
t = init_transaction(config.handle)
|
||||||
t.sysupgrade(downgrade=False)
|
if do_syncfirst is True:
|
||||||
if len(t.to_add) + len(t.to_remove) == 0:
|
for pkg in list_first:
|
||||||
print("Nothing to do")
|
t.add_pkg(pkg)
|
||||||
t.release()
|
|
||||||
return 0
|
|
||||||
else:
|
else:
|
||||||
ok = finalize(t)
|
try:
|
||||||
return (0 if ok else 1)
|
t.sysupgrade(downgrade=False)
|
||||||
|
except pyalpm.error:
|
||||||
|
ErrorDialog.format_secondary_text(traceback.format_exc())
|
||||||
|
response = ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
ErrorDialog.hide()
|
||||||
|
t.release()
|
||||||
|
try:
|
||||||
|
t.prepare()
|
||||||
|
except pyalpm.error:
|
||||||
|
ErrorDialog.format_secondary_text(traceback.format_exc())
|
||||||
|
response = ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
ErrorDialog.hide()
|
||||||
|
t.release()
|
||||||
|
to_remove = t.to_remove
|
||||||
|
to_add = t.to_add
|
||||||
|
if len(to_add) + len(to_remove) == 0:
|
||||||
|
t.release()
|
||||||
|
else:
|
||||||
|
set_transaction_desc('update')
|
||||||
|
if len(transaction_desc) != 0:
|
||||||
|
response = ConfDialog.run()
|
||||||
|
if response == Gtk.ResponseType.OK:
|
||||||
|
t_finalize(t)
|
||||||
|
if response == Gtk.ResponseType.CANCEL or Gtk.ResponseType.CLOSE or Gtk.ResponseType.DELETE_EVENT:
|
||||||
|
ProgressWindow.hide()
|
||||||
|
ConfDialog.hide()
|
||||||
|
t.release()
|
||||||
|
else:
|
||||||
|
t_finalize(t)
|
||||||
|
t.release()
|
||||||
|
|
||||||
|
def t_finalize(t):
|
||||||
|
ConfDialog.hide()
|
||||||
|
try:
|
||||||
|
t.commit()
|
||||||
|
except pyalpm.error:
|
||||||
|
ErrorDialog.format_secondary_text(traceback.format_exc())
|
||||||
|
response = ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
ErrorDialog.hide()
|
||||||
|
ProgressWindow.hide()
|
||||||
|
|
||||||
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"""
|
||||||
installed_pkglist = config.handle.get_localdb().pkgcache
|
global do_syncfirst
|
||||||
|
global list_first
|
||||||
|
if config.syncfirst:
|
||||||
|
for name in config.syncfirst:
|
||||||
|
pkg = config.handle.get_localdb().get_pkg(name)
|
||||||
|
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
|
||||||
|
if candidate:
|
||||||
|
list_first.append(candidate)
|
||||||
|
if list_first:
|
||||||
|
do_syncfirst = True
|
||||||
|
return list_first
|
||||||
result = []
|
result = []
|
||||||
|
installed_pkglist = config.handle.get_localdb().pkgcache
|
||||||
for pkg in installed_pkglist:
|
for pkg in installed_pkglist:
|
||||||
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
|
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
|
||||||
if candidate is not None:
|
if candidate:
|
||||||
result.append(candidate)
|
result.append(candidate)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -90,6 +150,48 @@ def format_size(size):
|
|||||||
size_string = '%.2f MiB' % (KiB_size / 1024)
|
size_string = '%.2f MiB' % (KiB_size / 1024)
|
||||||
return size_string
|
return size_string
|
||||||
|
|
||||||
|
def set_transaction_desc(mode):
|
||||||
|
global transaction_desc
|
||||||
|
global down_label
|
||||||
|
global to_add
|
||||||
|
global to_remove
|
||||||
|
global to_update
|
||||||
|
transaction_desc.clear()
|
||||||
|
if to_remove:
|
||||||
|
transaction_desc.append(['To remove:', to_remove[0].name])
|
||||||
|
i = 1
|
||||||
|
while i < len(to_remove):
|
||||||
|
transaction_desc.append([' ', to_remove[i].name])
|
||||||
|
i += 1
|
||||||
|
down_label.set_markup('')
|
||||||
|
if to_add:
|
||||||
|
if mode == 'update':
|
||||||
|
installed_name = []
|
||||||
|
for pkg_object in config.handle.get_localdb().pkgcache:
|
||||||
|
installed_name.append(pkg_object.name)
|
||||||
|
to_add_name = []
|
||||||
|
for pkg_object in to_add:
|
||||||
|
to_add_name.append(pkg_object.name)
|
||||||
|
to_update = sorted(set(installed_name).intersection(to_add_name))
|
||||||
|
to_remove_from_add_name = sorted(set(to_update).intersection(to_add_name))
|
||||||
|
for name in to_remove_from_add_name:
|
||||||
|
to_add_name.remove(name)
|
||||||
|
if to_add_name:
|
||||||
|
transaction_desc.append(['To install:', to_add_name[0]])
|
||||||
|
i = 1
|
||||||
|
while i < len(to_add_name):
|
||||||
|
transaction_desc.append([' ', to_add_name[i]])
|
||||||
|
i += 1
|
||||||
|
if mode == 'normal':
|
||||||
|
if to_update:
|
||||||
|
transaction_desc.append(['To update:', to_update[0]])
|
||||||
|
i = 1
|
||||||
|
while i < len(to_update):
|
||||||
|
transaction_desc.append([' ', to_update[i]])
|
||||||
|
i += 1
|
||||||
|
down_label.set_markup('')
|
||||||
|
#down_label.set_markup('<b>Total Download size: </b>'+format_size(total_size))
|
||||||
|
|
||||||
# Callbacks
|
# Callbacks
|
||||||
event_text = ' '
|
event_text = ' '
|
||||||
def cb_event(ID, event, tupel):
|
def cb_event(ID, event, tupel):
|
||||||
@ -136,11 +238,10 @@ def cb_dl(_target, _transferred, total):
|
|||||||
progress_bar.set_text(_target)
|
progress_bar.set_text(_target)
|
||||||
progress_bar.set_fraction(fraction)
|
progress_bar.set_fraction(fraction)
|
||||||
else:
|
else:
|
||||||
progress_label.set_text('Downloading...')
|
progress_label.set_text('Refreshing...')
|
||||||
progress_bar.set_text(_target)
|
progress_bar.set_text(_target)
|
||||||
progress_bar.pulse()
|
progress_bar.pulse()
|
||||||
|
|
||||||
|
|
||||||
def cb_progress(_target, _percent, n, i):
|
def cb_progress(_target, _percent, n, i):
|
||||||
while Gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
@ -148,14 +249,6 @@ def cb_progress(_target, _percent, n, i):
|
|||||||
progress_bar.set_fraction(_percent/100)
|
progress_bar.set_fraction(_percent/100)
|
||||||
progress_bar.set_text(target)
|
progress_bar.set_text(target)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
do_refresh()
|
True
|
||||||
available_updates = get_updates()
|
|
||||||
if not available_updates:
|
|
||||||
print("\nNo update available")
|
|
||||||
else:
|
|
||||||
for pkg in available_updates:
|
|
||||||
pkgname = pkg.name
|
|
||||||
oldversion = pkg.version
|
|
||||||
newversion = get_new_version_available(pkgname)
|
|
||||||
print("\n{} {} can be updated to {}".format(pkgname, oldversion, newversion))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user