author Julien Cristau <julien.cristau@logilab.fr>
Wed, 18 Jun 2014 17:24:26 +0200
changeset 1533 b0d9c98a09de
parent 1530 050d0a67b616
child 1600 4ea25b8608b3
child 1869 0b25baa0a13d
child 1870 1cfb1d186397
child 1871 980e20892562
permissions -rw-r--r--
[narval] fix pypi.upload checker harder Thanks, pylint. Related to #4002584

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from os.path import exists, join, abspath

import apycotlib

from checkers.apycot import BaseChecker
from preprocessors.apycot.distutils import pyversions

class PypiUploader(BaseChecker):
    id = 'pypi.upload'

    options_def = {
        'verbose': {
            'type': 'int', 'default': False,
            'help': 'set verbose mode'

    def do_check(self, test):
        """run the distutils 'setup.py register sdist upload' command

        The user running the narval bot must have a properly filled
        .pypirc file
        path = test.project_path()
        if not exists(join(path, 'setup.py')):
            raise apycotlib.SetupException('No file %s' % abspath(join(path, 'setup.py')))
        python = pyversions(test)[0]
        cmdargs = [python, 'setup.py', 'register', 'sdist', 'upload']
        if not self.options.get('verbose'):
        cmd = apycotlib.Command(self.writer, cmdargs, raises=True, cwd=path)
        cmdstatus = cmd.run()
        if cmdstatus == apycotlib.SUCCESS:
            self.writer.info('uploaded tarball to pypi')
        return cmdstatus

apycotlib.register('checker', PypiUploader)