try:
bconf = get_elem(btarget, "buildconf")
- target["buildconf"]={
+ target["buildconf"] = {
"location":
get_elem(bconf, "location").getAttribute("href"),
"checksum":
target = self.targets[name]
content += '<buildtarget name="%s">' % name
- if 'buildconf' in target.keys():
+ if 'buildconf' in target:
# buildconf
content += '<buildconf>'
buildconf = target['buildconf']
import os
import shutil
from hashlib import sha256
-from subprocess import check_output, CalledProcessError
from common.builddata import BuildData, BuildDataError
-from common.imagedata import ImageData, ImageDataError
+from common.imagedata import ImageData
class RepoMakerError(Exception):
"""Custom RepoMaker exception."""
# Helper functions
def find_files(topdir, prefix='', suffix='.rpm'):
"""Find files in the tree."""
- for root, dirs, files in os.walk(topdir):
+ for root, _dirs, files in os.walk(topdir):
for item in files:
if item.startswith(prefix) and item.endswith(suffix):
yield os.path.join(root, item)
self.imagedata = ImageData()
self.imagedata.extract_image_conf(rpm)
- def gen_image_info(self, updated_ks = None):
+ def gen_image_info(self, updated_ks=None):
"""
Generate images.xml and save a copy of ks file under builddata dir
"""
if not repomaker.imagedata:
raise LocalError("Image configuration not found")
- # Update ks files
+ # Update ks files
images_ks = update_ks(repomaker.imagedata, backenddb)
# Generate image info to builddata/ dir
repomaker.gen_image_info(images_ks)
project = content.get("project")
build = BuildService(obs_api, obs_user, obs_passwd)
- # Init backend database
+ # Init backend database
redis_host = os.getenv("REDIS_HOST")
redis_port = os.getenv("REDIS_PORT")
backenddb = BackendDB(redis_host, redis_port)
return key in self._dict
def keys(self, pattern):
- return [key for key in self._dict.keys() \
+ """Get list of keys from db."""
+ return [key for key in self._dict \
if re.match("^%s" % pattern, str(key))]
def hmset(self, key, value):
return 'string'
def set(self, key, value):
- self._dict[key]=value
+ """Set value for the key."""
+ self._dict[key] = value
def get(self, key):
+ """Get value for the key."""
return self._dict[key]
@patch('redis.Redis', RedisMock) # pylint: disable=R0904
'''Tests for BuildData functionality.'''
def test_load(self):
+ """Test loading of build data from xml string."""
bdata = BuildData(build_id='test.id')
bdata.load(TEST_XML)
self.assertEqual(bdata.targets, OrderedDict(
def test_save(self):
+ """Test saving build data to file."""
bdata = BuildData(build_id='test.id')
bdata.load(TEST_XML)
fname = 'test_save.tmp'