from common.buildtrigger import trigger_info, trigger_next
from common.utils import sync, set_permissions, Workdir
-from common.prerelease import is_prerelease_project
+
def get_xml(image_dir, ks_name):
""" Get the xml the image, return the body as string """
- for root, subdir, files in os.walk(image_dir):
+ for root, _subdir, files in os.walk(image_dir):
for fname in files:
- if fname.endswith("%s.xml" %(ks_name)):
+ if fname.endswith("%s.xml" % (ks_name)):
return open(os.path.join(root,
fname)).read()
return ''
+
def convert_image_dir(image_dir, repo_name, image_name):
"""
Insert repo name into image directory hierarchy.
return
shutil.move(image_name, repo_name)
+
def run_inside_vm(vm_image, vm_memory, vm_cpus, basedir):
"""
Run mic inside VM
# processid from pid
# buildid from BUILD_NUMBER
mac_address = '52:%02x:%02x:%02x:%02x:%02x' % \
- (lastip, exeid, processid,
- buildid, randint(0x00, 0xff))
+ (lastip, exeid, processid,
+ buildid, randint(0x00, 0xff))
cmd = 'qemu-system-x86_64 -machine accel=kvm:xen:tcg -name '\
'opensuse -M pc -m %d -smp %d -vga none -drive file=%s,'\
'snapshot=on -nographic -virtfs local,id=test_dev,'\
subprocess.call(cmd, stdout=sys.stdout,
stderr=sys.stderr, shell=True)
- #read mic status from file
+ # read mic status from file
try:
with open(os.path.join(basedir, 'status')) as statusf:
status = statusf.read().strip()
return 0
else:
return -1
- except IOError, _err:
+ except IOError:
return -1
+
def main():
"""The main body"""
if int(os.getenv('USE_VM')):
vm_image = os.getenv("VM_IMAGE",
- os.path.join(os.getenv('JENKINS_HOME'), 'mic-appliance'))
+ os.path.join(os.getenv('JENKINS_HOME'),
+ 'mic-appliance'))
# check if tarball exists
if not vm_image or not os.access(vm_image, os.R_OK):
print 'VM image %s is not found' % vm_image
def fetch_image(url):
"""Tries to download locally the image that will be tested."""
- logging.info("Attempt retrieving flashable image from {0} ."\
+ logging.info("Attempt retrieving flashable image from {0} ."
.format(url))
try:
command = ["/usr/bin/wget", "-r", "-l1", "-np", "-nd", "-q", "-A",
- os.getenv("TESTABLE_IMAGE_DOWNLOADABLES"), url]
+ os.getenv("TESTABLE_IMAGE_DOWNLOADABLES"), url]
subprocess.check_output(command)
image = glob.glob(os.getenv("TESTABLE_IMAGE_FILTER"))[0]
logging.info("Image retrieved successfully.")
else:
logging.info("Completed packing test results.")
+
def xml_tree_to_dict(tree):
"""Converts junit xml file to a dictionary"""
- #pylint: disable=W0141
- dic = {tree.tag : map(xml_tree_to_dict, tree.iterchildren())}
- #pylint: enable=W0141
+ # pylint: disable=bad-builtin
+ dic = {tree.tag: map(xml_tree_to_dict, tree.iterchildren())}
+ # pylint: enable=bad-builtin
dic.update(('@' + k, v) for k, v in tree.attrib.iteritems())
dic['text'] = tree.text
return dic