5.23 KB
#!/usr/bin/env python

from PyQt4 import QtCore
from PyQt4 import QtGui
from PyQt4.QtCore import pyqtProperty
from gi.repository import PackageKitGlib as packagekit

from mambabase_ui import *
import subprocess

PackageGroups = [ \
{ 'name':'inst_base', 'group': 'BASE', 'description': 'System base packages (recommended)'}, \
{ 'name':'inst_office', 'group': 'OFFICE', 'description': 'Office packages (OpenOffice, Groupware, PDA Syncronization, ...)'}, \
{ 'name':'inst_players', 'group': 'MULTIMEDIA_PLAYERS', 'description': 'Audio and Video players (amarok, xmms, vlc, kaffeine, miro, ...)'}, \
{ 'name':'inst_multimedia_editing', 'group': 'MULTIMEDIA_EDITING', 'description': 'Multimedia editing and production (kino, audacity, rosegarden, mixxx, ...)'}, \
{ 'name':'inst_internet', 'group': 'INTERNET', 'description': 'Internet communication and p2p (kopete, pidgin, ekiga, aMule, ...)'}, \
{ 'name':'inst_graphics', 'group': 'GRAPHICS', 'description': 'Graphics software (gimp, digikam, blender, sodipodi, ...)'}, \
{ 'name':'inst_games', 'group': 'GAMES', 'description': 'Games (turacer, pingus, ksudoku, ...)'}, \
{ 'name':'inst_virtualization', 'group': 'VIRTUALIZATION', 'description': 'Emulation and virtuali&zation (VirtualBox, kvm, QtEmu, wine, ...)'}, \
{ 'name':'inst_server', 'group': 'SERVER', 'description': 'Base server packages (apache, postfix, vsftpd, php, mysql, ...)'}, \
{ 'name':'inst_devel', 'group': 'DEVEL', 'description': 'Base development packages (gcc, glibc-devel, kernel sources, ...)'}, \

ProprietaryPackages = [ \
{ 'name':'inst_nvidia', 'pkg': 'xorg-drv-video-nvidia', 'description': 'NVIDIA proprietary video driver from'}, \
{ 'name':'inst_nvidia_legacy', 'pkg': 'xorg-drv-video-nvidia_304', 'description': 'NVIDIA proprietary video driver (legacy) from'}, \
{ 'name':'inst_fglrx', 'pkg': 'xorg-drv-video-fglrx', 'description': 'AMD/ATI proprietary video driver from'}, \
{ 'name':'inst_fglrx_legacy', 'pkg': 'xorg-drv-video-fglrx-legacy', 'description': 'AMD/ATI proprietary video driver (legacy) from'}, \
{ 'name':'inst_broadcom_sta', 'pkg': 'broadcom-sta', 'description': 'Broadcom-sta proprietary wireless driver from'}, \
{ 'name':'inst_b43', 'pkg': 'b43-firmware', 'description': 'Broadcom B43 proprietary firmware from'}, \
{ 'name':'inst_flash', 'pkg': 'flashplugin', 'description': 'Flash plugin from'}, \
{ 'name':'inst_msttcf', 'pkg': 'msttcorefonts', 'description': 'MS TrueType core fonts from sourceforge'}, \
{ 'name':'inst_codecs', 'pkg': 'win32codecs', 'description': 'Win32 codecs from'}, \
{ 'name':'inst_java', 'pkg': 'sun-java7', 'description': 'Oracle Java 7 from'}, \
{ 'name':'inst_skype', 'pkg': 'skype', 'description': 'Skype from'}, \
{ 'name':'inst_spotify', 'pkg': 'spotify', 'description': 'Spotify from'}, \
{ 'name':'inst_virtualbox', 'pkg': 'virtualbox-extension-pack', 'description': 'Virtualbox extension pack from'}, \

def progress_cb(status, typ, data=None):
    if status.get_property('package'):
        print "Pachet ", status.get_property('package'), status.get_property('package-id')
        if status.get_property('package'):
            print status.get_property('package').get_name()
#    print typ, status.get_property('package')

class MyWizard(QtGui.QWizard):
    def __init__(self, parent=None):
        QtGui.QWizard.__init__(self, parent)

def resolve_group(group):
    p = subprocess.check_output("/bin/bash -c \"source /usr/share/openmamba/pkggroups.db;echo \$"+group+"_PKGS\"",\
    shell=True, stderr=subprocess.PIPE)
    return p

if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    Wizard = MyWizard()
    ui = Ui_Wizard()

    pkclient = packagekit.Client()
    for p in PackageGroups:
        item_0 = QtGui.QTreeWidgetItem(ui.treeWidget)
        item_0.setText(0, p['description'])
        item_0.setCheckState(0, QtCore.Qt.Unchecked)
        gpkgs = resolve_group(p['group'])
        for d in gpkgs.split(" "):
            print d
            item_1 = QtGui.QTreeWidgetItem(item_0)
            item_1.setText(0, d)
            result = pkclient.resolve(packagekit.FilterEnum.INSTALLED, d, None, progress_cb, None)
            pkgs = result.get_package_array()
            if len(pkgs) > 0:
                item_1.setCheckState(0, QtCore.Qt.Checked)
                item_1.setCheckState(0, QtCore.Qt.Unchecked)

    for p in ProprietaryPackages:
        item_0 = QtGui.QTreeWidgetItem(ui.treeWidget_2)
        item_0.setText(0, p['description'])
        result = pkclient.resolve(packagekit.FilterEnum.INSTALLED, [p['pkg'],], None, progress_cb, None)
        pkgs = result.get_package_array()
        if len(pkgs) > 0:
            item_0.setCheckState(0, QtCore.Qt.Checked)
            item_0.setCheckState(0, QtCore.Qt.Unchecked)