Beispiel #1
0
    def __init__(self, parent=None):
        QAbstractTableModel.__init__(self, parent)
        self.iface = backend.pm.Iface()
        self._flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable
        self.initPhase()

        self.state = parent.state

        self.appinfo = AppInfoClient()
        self.appinfo.setServer('http://appinfo.pardus.org.tr')
        if not self.appinfo.initializeLocalDB()[0]:
            self.appinfo.checkOutDB()
Beispiel #2
0
    def updateRepoAction(self, silence = False):

        if not self.iface.updateRepositories():
            if not silence:
                self.showFailMessage()
            return False

        if network_available():
            if not AppInfoClient().checkOutDB()[0]:
                AppInfoClient().setServer('http://appinfo.pardus.org.tr')
                AppInfoClient().checkOutDB()

        return True
Beispiel #3
0
    def __init__(self, parent=None):
        QAbstractTableModel.__init__(self, parent)
        self.iface = backend.pm.Iface()
        self._flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable
        self.initPhase()

        self.state = parent.state

        self.appinfo = AppInfoClient()
        self.appinfo.setServer('http://appinfo.pisilinux.org.tr')
        if not self.appinfo.initializeLocalDB()[0]:
            self.appinfo.checkOutDB()
Beispiel #4
0
class PackageModel(QAbstractTableModel):

    def __init__(self, parent=None):
        QAbstractTableModel.__init__(self, parent)
        self.iface = backend.pm.Iface()
        self._flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable
        self.initPhase()

        self.state = parent.state

        self.appinfo = AppInfoClient()
        self.appinfo.setServer('http://appinfo.pisilinux.org.tr')
        if not self.appinfo.initializeLocalDB()[0]:
            self.appinfo.checkOutDB()

    def initPhase(self):
        self.resetCachedInfos()
        self.packages = []

    def rowCount(self, index=QModelIndex()):
        return len(self.packages)

    def columnCount(self, index=QModelIndex()):
        if self._flags & Qt.ItemIsUserCheckable:
            return 2
        return 1

    def data(self, index, role=Qt.DisplayRole):
        if not index.isValid():
            return _variant

        if role == Qt.DisplayRole:
            return QVariant(self.packages[index.row()])
        elif role == Qt.CheckStateRole and index.column() == 0:
            return QVariant(self.package_selections[index.row()])

        if role >= Qt.UserRole:
            try:
                package = self.package(index)
            except Exception, e:
                logger.warning(e)
                return _variant

        if role == SummaryRole:
            return QVariant(unicode(package.summary))
        elif role == DescriptionRole:
            return QVariant(unicode(package.description))
        elif role == TypeRole:
            return QVariant(unicode(package._type))
        elif role == SizeRole:
            return QVariant(unicode(humanReadableSize(self.iface.getPackageSize(package))))
        elif role == VersionRole:
            return QVariant(unicode(package.version))
        elif role == InstalledVersionRole:
            if self.state.inUpgrade():
                return QVariant(unicode(self.iface.getInstalledVersion(package.name)))
            return _variant
        elif role == RepositoryRole:
            if not self.state.inRemove():
                return QVariant(unicode(self.iface.getPackageRepository(package.name)))
            return _variant
        elif role == HomepageRole:
            return QVariant(unicode(package.source.homepage))
        elif role == InstalledRole:
            return QVariant(unicode(package.installed))
        elif role == ComponentRole:
            return QVariant(unicode(package.partOf))
        elif role == IsaRole:
            isa = '' if not len(package.isA) > 0 else package.isA[0]
            return QVariant(unicode(isa))
        elif role == RateRole:
            return QVariant(self.appinfo.getPackageScore(package.name))
        elif role == NameRole:
            return QVariant(package.name)
        elif role == Qt.DecorationRole:
            package = self.package(index)
            if package.icon:
                return QVariant(package.icon)
        return _variant
Beispiel #5
0
class PackageModel(QAbstractTableModel):

    def __init__(self, parent=None):
        QAbstractTableModel.__init__(self, parent)
        self.iface = backend.pm.Iface()
        self._flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable
        self.initPhase()

        self.state = parent.state

        self.appinfo = AppInfoClient()
        self.appinfo.setServer('http://appinfo.pardus.org.tr')
        if not self.appinfo.initializeLocalDB()[0]:
            self.appinfo.checkOutDB()

    def initPhase(self):
        self.resetCachedInfos()
        self.packages = []

    def rowCount(self, index=QModelIndex()):
        return len(self.packages)

    def columnCount(self, index=QModelIndex()):
        if self._flags & Qt.ItemIsUserCheckable:
            return 2
        return 1

    def data(self, index, role=Qt.DisplayRole):
        if not index.isValid():
            return _variant

        if role == Qt.DisplayRole:
            return QVariant(self.packages[index.row()])
        elif role == Qt.CheckStateRole and index.column() == 0:
            return QVariant(self.package_selections[index.row()])

        if role >= Qt.UserRole:
            try:
                package = self.package(index)
            except Exception, e:
                logger.warning(e)
                return _variant

        if role == SummaryRole:
            return QVariant(unicode(package.summary))
        elif role == DescriptionRole:
            return QVariant(unicode(package.description))
        elif role == TypeRole:
            return QVariant(unicode(package._type))
        elif role == SizeRole:
            return QVariant(unicode(humanReadableSize(self.iface.getPackageSize(package))))
        elif role == VersionRole:
            return QVariant(unicode(package.version))
        elif role == InstalledVersionRole:
            if self.state.inUpgrade():
                return QVariant(unicode(self.iface.getInstalledVersion(package.name)))
            return _variant
        elif role == RepositoryRole:
            if not self.state.inRemove():
                return QVariant(unicode(self.iface.getPackageRepository(package.name)))
            return _variant
        elif role == HomepageRole:
            return QVariant(unicode(package.source.homepage))
        elif role == InstalledRole:
            return QVariant(unicode(package.installed))
        elif role == ComponentRole:
            return QVariant(unicode(package.partOf))
        elif role == IsaRole:
            isa = '' if not len(package.isA) > 0 else package.isA[0]
            return QVariant(unicode(isa))
        elif role == RateRole:
            return QVariant(self.appinfo.getPackageScore(package.name))
        elif role == NameRole:
            return QVariant(package.name)
        elif role == Qt.DecorationRole:
            package = self.package(index)
            if package.icon:
                return QVariant(package.icon)
        return _variant
Beispiel #6
0
    parser.add_option("-p", "--pkgupdate", default = False, dest="updatepkgdb",
                      help="update package db", action="store_true")
    parser.add_option("-c", "--create", default = False, dest="createdb",
                      help="creates a score db", action="store_true")
    parser.add_option("-s", "--setserver", dest="server", default="",
                      help="set remote appinfo server", action="store", type="string")
    parser.add_option("-u", "--update", default = False, dest="updatedb",
                      help="updates score db", action="store_true")
    (options, args) = parser.parse_args()

    if len(args) > 2:# or (not options.resetdb and len(args) < 2):
        parser.print_usage()
        sys.exit(0)

    clientonly = True
    client = AppInfoClient()

    if any([options.createdb, options.updatepkgdb, options.resetdb, len(args) > 1]):
        clientonly = False
        server = AppInfoServer()
        print ' - Trying to initialize Server DB:', server.initializeDB(options.filename)[1]

    if options.createdb:
        print ' - Trying to create db:' , server.createDB(options.filename or 'appinfo.db')[1]
    if options.updatepkgdb:
        print ' - Trying to update packagelist:', server.updatePackageList()[1]
    if options.resetdb:
        print ' - Trying to reset scores:', server.resetPackageScores()
    if not options.resetdb and len(args) > 1:
        print ' - Trying to update package "%s" score:' % args[0], server.updatePackageScore(args[0], float(args[1]))[1]
Beispiel #7
0
#
# 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.
#
# Please read the COPYING file.
#

from appinfo.server import AppInfoServer
from appinfo.client import AppInfoClient

if __name__ == '__main__':

    server = AppInfoServer()
    client = AppInfoClient()

    print
    print ' - Trying to create db:'
    print '   ', server.createDB()[1]
    print
    print ' - Trying to update packagelist:'
    print '   ', server.updatePackageList()[1]
    print
    print ' - Trying to initialize Client DB:'
    print '   ', client.initializeDB()[1]
    print
    print ' - Trying to get score for package "yali":'
    print '   ', client.getPackageScore('yali')
    print
    print ' - Trying to update package "yali" score:'
Beispiel #8
0
    parser.add_option("-p", "--pkgupdate", default = False, dest="updatepkgdb",
                      help="update package db", action="store_true")
    parser.add_option("-c", "--create", default = False, dest="createdb",
                      help="creates a score db", action="store_true")
    parser.add_option("-s", "--setserver", dest="server", default="",
                      help="set remote appinfo server", action="store", type="string")
    parser.add_option("-u", "--update", default = False, dest="updatedb",
                      help="updates score db", action="store_true")
    (options, args) = parser.parse_args()

    if len(args) > 2:# or (not options.resetdb and len(args) < 2):
        parser.print_usage()
        sys.exit(0)

    clientonly = True
    client = AppInfoClient()

    if any([options.createdb, options.updatepkgdb, options.resetdb, len(args) > 1]):
        clientonly = False
        server = AppInfoServer()
        print ' - Trying to initialize Server DB:', server.initializeDB(options.filename)[1]

    if options.createdb:
        print ' - Trying to create db:' , server.createDB(options.filename or 'appinfo.db')[1]
    if options.updatepkgdb:
        print ' - Trying to update packagelist:', server.updatePackageList()[1]
    if options.resetdb:
        print ' - Trying to reset scores:', server.resetPackageScores()
    if not options.resetdb and len(args) > 1:
        print ' - Trying to update package "%s" score:' % args[0], server.updatePackageScore(args[0], float(args[1]))[1]
Beispiel #9
0
#
# 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.
#
# Please read the COPYING file.
#

from appinfo.server import AppInfoServer
from appinfo.client import AppInfoClient

if __name__ == '__main__':

    server = AppInfoServer()
    client = AppInfoClient()

    print
    print ' - Trying to create db:'
    print '   ',server.createDB()[1]
    print
    print ' - Trying to update packagelist:'
    print '   ', server.updatePackageList()[1]
    print
    print ' - Trying to initialize Client DB:'
    print '   ', client.initializeDB()[1]
    print
    print ' - Trying to get score for package "yali":'
    print '   ', client.getPackageScore('yali')
    print
    print ' - Trying to update package "yali" score:'