~ubuntu-branches/ubuntu/raring/software-center/raring-proposed

« back to all changes in this revision

Viewing changes to softwarecenter/db/update.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2012-12-06 17:30:50 UTC
  • Revision ID: package-import@ubuntu.com-20121206173050-n7mxi5fzlsvtdh9l
Tags: 5.5.2
* lp:~mvo/software-center/fix-pygobject-deprecation-warnings:
  - fix deprecation warninings with the latest python-gi
* lp:~mvo/software-center/minor-logging-fixes:
  - drop some LOG.info() messages to LOG.debug() to spam the user
    less
* lp:~mvo/software-center/trivial-close-ui-tweak:
  - hide the main window immediately when closing down
* lp:~mvo/software-center/5.4-fix-save-person-to-config:
  - This branch ensures that the "username" is saved everytime
    that the ubuntu sso whoami call is done
* lp:~mvo/software-center/use-dpkg-builddeps:
  - use dpkg-checkbuilddeps to find test-dependencies
* lp:~mvo/software-center/update-sc-cmdline-flexibility:
  - update-software-center-agent: 
    + add --target-db-path commandline
  - update-software-center: 
    + add --app-install-desktop-dir and --target-db-path commandline
* lp:~mvo/software-center/raring-pep8:
  - fixes for new pep8

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import xapian
28
28
 
29
29
from aptsources.sourceslist import SourceEntry
30
 
from gi.repository import GObject
 
30
from gi.repository import GLib
31
31
from piston_mini_client import PistonResponseObject
32
32
 
33
33
from softwarecenter.backend.scagent import SoftwareCenterAgent
74
74
from softwarecenter.distro import (
75
75
    get_current_arch,
76
76
    get_foreign_architectures,
77
 
    )
 
77
)
78
78
from softwarecenter.region import (
79
79
    get_region_cached,
80
80
    REGION_BLACKLIST_TAG,
81
81
    REGION_WHITELIST_TAG,
82
 
    )
 
82
)
83
83
 
84
84
 
85
85
# weights for the different fields
412
412
                countrycode = region["countrycode"].lower()
413
413
                # blacklist
414
414
                if "%s%s" % (REGION_BLACKLIST_TAG, countrycode) in tags:
415
 
                    LOG.info("%r.make_doc: skipping region restricted app %r "
 
415
                    LOG.debug("%r.make_doc: skipping region restricted app %r "
416
416
                             "(blacklisted)", self.__class__.__name__, name)
417
417
                    return
418
418
                # whitelist
419
419
                for tag in tags:
420
420
                    if (tag.startswith(REGION_WHITELIST_TAG) and not
421
421
                        "%s%s" % (REGION_WHITELIST_TAG, countrycode) in tag):
422
 
                        LOG.info("%r.make_doc: skipping region restricted "
 
422
                        LOG.debug("%r.make_doc: skipping region restricted "
423
423
                                 "app %r (region not whitelisted)",
424
424
                                 self.__class__.__name__, name)
425
425
                        return
951
951
        return False
952
952
    if not listsdir:
953
953
        listsdir = apt_pkg.config.find_dir("Dir::State::lists")
954
 
    context = GObject.main_context_default()
 
954
    context = GLib.main_context_default()
955
955
    for appinfo in glob("%s/*AppInfo" % listsdir):
956
956
        LOG.debug("processing %r", appinfo)
957
957
        # process events
981
981
def update_from_appstream_xml(db, cache, xmldir=None):
982
982
    if not xmldir:
983
983
        xmldir = softwarecenter.paths.APPSTREAM_XML_PATH
984
 
    context = GObject.main_context_default()
 
984
    context = GLib.main_context_default()
985
985
 
986
986
    if os.path.isfile(xmldir):
987
987
        update_from_single_appstream_file(db, cache, xmldir)
1000
1000
    """ index the desktop files in $datadir/desktop/*.desktop """
1001
1001
    if not datadir:
1002
1002
        datadir = softwarecenter.paths.APP_INSTALL_DESKTOP_PATH
1003
 
    context = GObject.main_context_default()
 
1003
    context = GLib.main_context_default()
1004
1004
    for desktopf in glob(datadir + "/*.desktop"):
1005
1005
        LOG.debug("processing %r", desktopf)
1006
1006
        # process events
1044
1044
        sca.good_data = False
1045
1045
        loop.quit()
1046
1046
 
1047
 
    context = GObject.main_context_default()
1048
 
    loop = GObject.MainLoop(context)
 
1047
    context = GLib.main_context_default()
 
1048
    loop = GLib.MainLoop(context)
1049
1049
 
1050
1050
    sca = SoftwareCenterAgent(ignore_cache)
1051
1051
    sca.connect("available", _available_cb)
1103
1103
    return sca.good_data
1104
1104
 
1105
1105
 
1106
 
def rebuild_database(pathname, debian_sources=True, appstream_sources=False):
 
1106
def rebuild_database(pathname, debian_sources=True, appstream_sources=False,
 
1107
                     appinfo_dir=None):
1107
1108
    #cache = apt.Cache(memonly=True)
1108
1109
    cache = get_pkg_info()
1109
1110
    cache.open()
1140
1141
    db = xapian.WritableDatabase(rebuild_path, xapian.DB_CREATE_OR_OVERWRITE)
1141
1142
 
1142
1143
    if debian_sources:
1143
 
        update(db, cache)
 
1144
        update(db, cache, appinfo_dir)
1144
1145
    if appstream_sources:
1145
1146
        if os.path.exists('./data/app-stream/appdata.xml'):
1146
1147
            update_from_appstream_xml(db, cache,