Esempio n. 1
0
 def get_lastest_version_number(package_name):
     pkg, all_versions = CheeseShop().query_versions_pypi(package_name)
     if len(all_versions):
         return all_versions[0]
     return None
Esempio n. 2
0
def check_latest():
    """
    Problems:

      * we use several third-party packages that are not included in a
        normal plone release. We want to keep those up to date
      * we keep all packages pinned to avoid getting unstable releases
        and we need to know when newer releases are available

    The tool should do the following:

      * watch the egg repos we are using (pypi, eea eggrepo) and report
        when new versions of packages are available, especially for the
        third-party packages
      * parse the buildout files (including on-the-web cfgs) and report
        of conflicts between versions
      * this should be implemented as a buildout tool
      * this tool should be run in automatic by Jenkins and report when
        new versions are available
    """

    # we use the .installed.cfg file to try to find the longest line
    # of __buildout_signature__, which contains the eggs that we need.
    # this is (maybe) highly specific to EEA.

    v = {}
    with open('.installed.cfg', 'r') as f:
        lines = f.readlines()
        longest = ""
        for line in lines:
            if line.startswith("__buildout_signature__") \
                    and len(line) > len(longest):
                longest = line

        eggs = longest.split('=')[1].strip().split(' ')
        for egg in eggs:
            spec = egg.split('-')
            name = spec[0]
            version = spec[1]
            v[name.strip()] = version.strip()

    skipped = []
    if os.path.exists('.skipped_packages'):
        with open(".skipped_packages") as f:
            skipped = [x.strip() for x in f.readlines() if x.strip()]

    picked_versions = v
    # repos = [EEAEggRepo(), CheeseShop(), ] #order is important
    repos = [
        CheeseShop(),
    ]  # order is important
    flag = 0

    report = []
    for name, v in picked_versions.items():
        if name in skipped:
            continue

        print "Checking new version for", name
        for pypi in repos:
            new_name, versions = pypi.query_versions_pypi(name)
            if versions:
                break

        if versions:
            latest = versions[0]
        else:
            print "Could not find any version for this package"
            continue
        if latest != v:
            print "Package %s - %s" % (name, v), " has a new version: ", latest
            report.append((name, v, latest))
            flag = 1

    report.sort(lambda x, y: cmp(x[0], y[0]))
    print
    print "New versions report"
    print "==================="
    for l in report:
        name, old, new = l
        space1 = (40 - len(name)) * ' '
        space2 = (20 - len(old)) * ' '
        print name + space1 + old + space2 + new

    sys.exit(flag)
Esempio n. 3
0
    def run(self):
        """Perform actions based on CLI options.

        @returns: status code

        """
        parser = setup_parser()

        try:
            import argcomplete
            argcomplete.autocomplete(parser)
        except ImportError:
            pass

        self.options = parser.parse_args()

        pkg_spec = validate_pypi_opts(parser)
        if not pkg_spec:
            pkg_spec = self.options.pkg_spec
        self.pkg_spec = pkg_spec

        if self.options.fields:
            self.options.fields = [
                s.strip().lower() for s in self.options.fields.split(',')
            ]
        else:
            self.options.fields = []

        if (not self.options.pypi_search and len(sys.argv) == 1):
            parser.print_help()
            return 2

        # Options that depend on querying installed packages, not PyPI.
        # We find the proper case for package names if they are installed,
        # otherwise PyPI returns the correct case.
        if (self.options.show_deps or self.options.show_all
                or self.options.show_active or self.options.show_non_active
                or (self.options.show_updates and pkg_spec)
                or self.options.upgrade):
            want_installed = True
        else:
            want_installed = False
        # show_updates may or may not have a pkg_spec
        if (not want_installed or self.options.show_updates
                or self.options.upgrade):
            self.pypi = CheeseShop(self.options.debug)
            # XXX: We should return 2 here if we couldn't create xmlrpc server

        if pkg_spec:
            (self.project_name, self.version,
             self.all_versions) = self.parse_pkg_ver(want_installed)
            if want_installed and not self.project_name:
                print(u'{} is not installed'.format(pkg_spec), file=sys.stderr)
                return 1

        # I could prefix all these with 'cmd_' and the methods also
        # and then iterate over the `options` dictionary keys...
        commands = [
            'show_deps', 'query_metadata_pypi', 'fetch', 'versions_available',
            'show_updates', 'upgrade', 'browse_website', 'show_download_links',
            'pypi_search', 'show_pypi_changelog', 'show_pypi_releases',
            'yolk_version', 'show_all', 'show_active', 'show_non_active',
            'show_entry_map', 'show_entry_points'
        ]

        # Run first command it finds, and only the first command, then return
        # XXX: Check if more than one command was set in options and give
        # error?
        for action in commands:
            if getattr(self.options, action):
                return getattr(self, action)()
        parser.print_help()
Esempio n. 4
0
File: config.py Progetto: href/plock
ARG_PARSER.add_argument(
    "-e", "--extra", help="extra extends file")

ARG_PARSER.add_argument(
    "--no-venv", action="store_true", help="no virtualenv")

ARG_PARSER.add_argument(
    "--no-buildout", action="store_true", help="no pip install zc.buildout")

ARG_PARSER.add_argument(
    "--unified-only", action="store_true", help="get unified cache & quit")

BUILDOUT_CFG = """\
[buildout]
extends =
    %s
"""

CFG_PARSER = configparser.SafeConfigParser()

PYPI = CheeseShop()

EXTENDS = "https://raw.github.com/plock/pins/master/plone-4-3"

UNIFIEDINSTALLER_DIR = "Plone-4.3.3-UnifiedInstaller"
UNIFIEDINSTALLER_URL = "https://launchpad.net/plone/4.3/4.3.3/+download/"
UNIFIEDINSTALLER_URL += "Plone-4.3.3-UnifiedInstaller.tgz"

SEARCH_OPER = 'AND'
SEARCH_SPEC = {'description': 'plone', 'keyword': 'plone', 'summary': 'plone'}