Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.command = self.get_default_command()
else:
self.command = cmd
# Check koji command
if not self.is_command_valid():
raise ValueError('Koji command "%s" is not valid' % self.command)
# Assuming command is valid, set configuration file and read it
self.config = self.CONFIG_MAP[self.command]
self.read_config()
# Setup koji session
server_url = self.config_options['server']
session_options = self.get_session_options()
self.session = koji.ClientSession(server_url,
session_options)
def test_server_principal_rdns(self, getfqdn):
opts = {'krb_rdns': True}
session = koji.ClientSession('http://koji.example.com:30/kojihub', opts)
cprinc = mock.MagicMock()
cprinc.realm = "REALM"
getfqdn.return_value = 'koji02.example.com'
princ = session._serverPrincipal(cprinc)
self.assertEqual(princ, 'host/koji02.example.com@REALM')
getfqdn.assert_called_with('koji.example.com')
from __future__ import absolute_import
import mock
import koji
from koji.xmlrpcplus import Fault
class BaseFakeClientSession(koji.ClientSession):
def __init__(self, *a, **kw):
super(BaseFakeClientSession, self).__init__(*a, **kw)
def multiCall(self, strict=False):
if not self.multicall:
raise Exception("not in multicall")
ret = []
self.multicall = False
calls = self._calls
self._calls = []
for call in calls:
method = call['methodName']
args, kwargs = koji.decode_args(call['params'])
try:
result = self._callMethod(method, args, kwargs)
def fetch_koji_build(build):
"""
build ==> buildID or NVR
"""
if build.isdigit():
build = int(build)
urls = [] # output
pathinfo = koji.PathInfo(topdir=topurl)
session = koji.ClientSession(server)
info = session.getBuild(build)
# print session.listArchives(build)
# rpms = session.listRPMs(buildID=info['id'])
# if not rpms:
# print ":-("
# for rpm in rpms:
# fname = pathinfo.rpm(rpm)
# url = pathinfo.build(info) + '/' + fname
# print url
if not info:
return
task_id = info["task_id"]
nvr = info.get("nvr", str(task_id))
package = info.get("name", str(task_id))
distmap = {'rhel6':'.el6',
'fedora18':'.fc18',
}
distsuffix = ''
tag = args[0]
disttag = distmap[tag.split('-')[-1]]
pkgstoignore = []
if config.has_section(tag) and config.has_option(tag, 'blacklist'):
pkgstoignore = config.get(tag, 'blacklist').split(' ')
if opts.brew:
mysession = koji.ClientSession("http://brewhub.devel.redhat.com/brewhub")
distsuffix = 'sat'
else:
mysession = koji.ClientSession("http://koji.katello.org/kojihub")
rpmlist = mysession.getLatestRPMS(tag)
nvrs = []
kojinames = []
pkglist = []
gitnames = []
notingit = []
for rpm in rpmlist[1]:
rpmname = rpm['nvr'].rstrip(distsuffix)
if isinstance(disttag, str):
rpmname = rpmname.replace(disttag, '')
else:
for d in disttag:
rpmname = rpmname.replace(d, '')
if rpm['name'] not in pkgstoignore:
nvrs.append(rpmname)
for b in builds:
if (b['package_name'] != build['package_name']):
continue
# print "remote[%d]=%s" % (cnt, b)
remote_evr = (str(b['epoch']), b['version'], b['release'])
newestRPM = _rpmvercmp(local_evr, remote_evr)
if newestRPM == 0 or newestRPM == 1:
break
cnt += 1
#if cnt > 5:
# break
return cnt
localkojisession = koji.ClientSession(LOCALKOJIHUB)
remotekojisession = koji.ClientSession(REMOTEKOJIHUB)
# package indexes
local = 0
remote = 0
cnt = {}
cnt['same'] = 0
cnt['newer'] = 0
cnt['older'] = 0
cnt['local_only'] = 0
cnt['remote_only'] = 0
cnt['total_missing_builds'] = 0
pkgs = {}
pkgs["same"] = []
pkgs["newer"] = []
def get_koji_session():
"""
Get a koji session for accessing kojihub functions.
"""
conf = koji.read_config("brew")
hub = conf["server"]
return koji.ClientSession(hub, {})
import time
import uuid
import argparse
import koji
from rpmUtils.miscutils import splitFilename
home_directory = os.path.expanduser('~')
opts = {
'cert': os.path.join(home_directory, '.katello.cert'),
'ca': os.path.join(home_directory, '.katello-ca.cert'),
'serverca': os.path.join(home_directory, '.katello-ca.cert')
}
mysession = koji.ClientSession("http://koji.katello.org/kojihub", opts)
mysession.ssl_login(opts['cert'], opts['ca'], opts['serverca'])
ARCH = 'arch'
REPO_NAME = 'repo_name'
DIST_KOJI_NAME = 'koji_name'
PULP_PACKAGES = 'pulp_packages'
REPO_CHECKSUM_TYPE = 'checksum'
# Mapping for the package keys in the DISTRIBUTION_INFO to the locations on disk
PULP_PACKAGE_LOCATIONS = {
'pulp': 'pulp',
'pulp-nodes': 'pulp/nodes',
'pulp-rpm': 'pulp_rpm',
'pulp-puppet': 'pulp_puppet'
}
def get_koji_session(self, login=True):
""" Return an authenticated koji session """
import koji
from iniparse.compat import ConfigParser
config = ConfigParser()
if os.path.exists(os.path.join(os.path.expanduser('~'), '.koji', 'config')):
config.readfp(open(os.path.join(os.path.expanduser('~'), '.koji', 'config')))
else:
config.readfp(open('/etc/koji.conf'))
cert = os.path.expanduser(config.get('koji', 'cert'))
ca = os.path.expanduser(config.get('koji', 'ca'))
serverca = os.path.expanduser(config.get('koji', 'serverca'))
session = koji.ClientSession(config.get('koji', 'server'))
if login:
session.ssl_login(cert=cert, ca=ca, serverca=serverca)
return session