示例#1
0
    def _run(self, pkg):
        """ Clone a package from dist-git. """
        if os.path.exists(pkg):
            err = '%s already exists in current working directory.' % pkg
            raise SystemExit(err)
        configp = util.config()
        try:
            user = configp.get('rhcephpkg', 'user')
            gitbaseurl = configp.get('rhcephpkg', 'gitbaseurl')
        except configparser.Error as err:
            raise SystemExit('Problem parsing .rhcephpkg.conf: %s',
                             err.message)
        # If we were given an RPM pkg name, switch to the Debian one:
        if pkg.startswith('python-'):
            pkg = pkg[7:]
        # TODO: SafeConfigParser might make the "user" interpolation here
        # unnecessary? Need to test, particularly what it does to %(module).
        pkg_url = gitbaseurl % {'user': user, 'module': pkg}
        cmd = ['git', 'clone', pkg_url]
        subprocess.check_call(cmd)

        os.chdir(pkg)

        patches_url = find_patches_url(configp, user, pkg)
        if patches_url:
            cmd = ['git', 'remote', 'add', '-f', 'patches', patches_url]
            subprocess.check_call(cmd)

        util.setup_pristine_tar_branch()
示例#2
0
 def test_working_config_file(self):
     c = util.config()
     assert c.get('rhcephpkg', 'user') == 'kdreyer'
     assert c.get('rhcephpkg', 'gitbaseurl') == \
         'ssh://%(user)[email protected]/ubuntu/%(module)s'
     assert c.get('rhcephpkg.jenkins', 'token') == \
         '5d41402abc4b2a76b9719d911017c592'
     assert c.get('rhcephpkg.jenkins', 'url') == \
         'https://ceph-jenkins.example.com/'
     assert c.get('rhcephpkg.chacra', 'url') == \
         'https://chacra.example.com/'
示例#3
0
 def test_working_config_file(self):
     c = util.config()
     assert c.get('rhcephpkg', 'user') == 'kdreyer'
     assert c.get('rhcephpkg', 'gitbaseurl') == \
         'ssh://%(user)[email protected]/ubuntu/%(module)s'
     assert c.get('rhcephpkg.jenkins', 'token') == \
         '5d41402abc4b2a76b9719d911017c592'
     assert c.get('rhcephpkg.jenkins', 'url') == \
         'https://ceph-jenkins.example.com/'
     assert c.get('rhcephpkg.chacra', 'url') == \
         'https://chacra.example.com/'
示例#4
0
 def _run(self, pkg):
     """ Clone a package from dist-git. """
     if os.path.exists(pkg):
         raise SystemExit('%s already exists in current working directory.',
                          pkg)
     configp = util.config()
     try:
         user = configp.get('rhcephpkg', 'user')
         gitbaseurl = configp.get('rhcephpkg', 'gitbaseurl')
     except configparser.Error as err:
         raise SystemExit('Problem parsing .rhcephpkg.conf: %s',
                          err.message)
     # TODO: SafeConfigParser might make the "user" interpolation here
     # unnecessary? Need to test, particularly what it does to %(module).
     pkg_url = gitbaseurl % {'user': user, 'module': pkg}
     cmd = ['git', 'clone', pkg_url]
     subprocess.check_call(cmd)
示例#5
0
 def _run(self, build):
     configp = util.config()
     try:
         base_url = configp.get('rhcephpkg.chacra', 'url')
     except configparser.Error as err:
         raise SystemExit('Problem parsing .rhcephpkg.conf: %s',
                          err.message)
     try:
         (pkg, version) = build.split('_')
     except ValueError:
         log.error('%s is not a valid package build N-V-R' % build)
         return self.parser.print_help()
     build_url = posixpath.join(base_url, 'binaries/', pkg, version,
                                'ubuntu', 'all')
     log.info('searching %s for builds' % build_url)
     build_response = urlopen(Request(build_url))
     headers = build_response.headers
     if six.PY2:
         encoding = headers.getparam('charset') or 'utf-8'
         # if encoding is None:
         #    encoding = 'utf-8'
     else:
         encoding = headers.get_content_charset(failobj='utf-8')
     payload = json.loads(build_response.read().decode(encoding))
     for arch, binaries in six.iteritems(payload):
         for binary in binaries:
             if os.path.isfile(binary):
                 # TODO: check the sha256sum of the already-downloaded file
                 # here?
                 log.info('skipping %s' % binary)
                 continue
             log.info('downloading %s' % binary)
             binary_url = posixpath.join(build_url, arch, binary) + '/'
             response = urlopen(Request(binary_url))
             with open(binary, 'wb') as fp:
                 shutil.copyfileobj(response, fp)
示例#6
0
 def test_missing_config_file(self, monkeypatch, tmpdir):
     # Set $HOME to a known-empty directory:
     monkeypatch.setenv('HOME', str(tmpdir))
     c = util.config()
     with pytest.raises(Exception):
         c.get('some.section', 'someoption')
示例#7
0
 def test_missing_config_file(self, monkeypatch, tmpdir):
     # Set $HOME to a known-empty directory:
     monkeypatch.setenv('HOME', str(tmpdir))
     c = util.config()
     with pytest.raises(Exception):
         c.get('some.section', 'someoption')