def init(*args, **kwargs): cfg_jobs, cfg_files = [], [] if kwargs["jobs"]: cfg_jobs = kwargs["jobs"].split(" ") if kwargs["files"]: cfg_files = kwargs["files"].split(" ") for file in cfg_files: s = Parser(file=file) s.run(position=kwargs["position"]) for it in cfg_jobs: job = Job.objects.get(uid=it) recipes = Recipe.objects.filter(job=job) for it in recipes: distro, status = DistroTemplate.objects.get_or_create( name=it.distro.name) distro.save() recipe = RecipeTemplate( jobtemplate=job.template, name=it.whiteboard, distro=distro ) recipe.save() for task in Task.objects.filter(recipe=it): new_task = TaskTemplate( test=task.test, recipe=recipe, ) new_task.save()
def init(*args, **kwargs): cfg_jobs, cfg_files = [], [] if kwargs["jobs"]: cfg_jobs = kwargs["jobs"].split(" ") if kwargs["files"]: cfg_files = kwargs["files"].split(" ") for file in cfg_files: s = Parser(file=file) s.run(position=kwargs["position"]) for it in cfg_jobs: job = Job.objects.get(uid=it) recipes = Recipe.objects.filter(job=job) for it in recipes: distro, status = DistroTemplate.objects.get_or_create( name=it.distro.name) distro.save() recipe = RecipeTemplate(jobtemplate=job.template, name=it.whiteboard, distro=distro) recipe.save() for task in Task.objects.filter(recipe=it): new_task = TaskTemplate( test=task.test, recipe=recipe, ) new_task.save()
def import_xml(request): # TODO: rewrite to standard View Class data = {} if request.POST and "textxml" in request.POST: xml = request.POST["textxml"].strip() s = Parser(content=xml) if not s.status: data["error"] = s.error else: s.run() data["xml"] = xml data["job"] = s.job data["recipes"] = RecipeTemplate.objects.filter(jobtemplate=s.job) return render(request, 'import_xml.html', data)
def xmlimport(self, filename, num_recipes=1): """ Tests importing beaker xml and crete templates """ s = Parser(file=filename) s.run(position=100) recipes = RecipeTemplate.objects.filter(jobtemplate=s.job) self.assertEqual( len(recipes), num_recipes, msg="Number recipes is bad") self.assertEqual(s.job.position, 100, msg="job position is same") # workaround: ignore default packages settings.BEAKER_DEFAULT_PACKAGES = [] job = JobGen() xml = job.getXML(s.job) xml_old = get_content_from_file(filename) xml = u"%s" % "".join(xml.splitlines(True)) xml_old = u"%s" % "".join(xml_old.splitlines(True)) bs1 = BeautifulSoup(xml_old, "lxml") bs2 = BeautifulSoup("".join(xml), "lxml") d = difflib.unified_diff( bs1.prettify().split("\n"), bs2.prettify().split("\n")) diff = "\n".join(d) print "-----------" print "'%s'" % diff print "-----------" self.assertEqual(len(diff), 0, msg="XML '%s' is different" % filename)
def xmlimport(self, filename, num_recipes=1): """ Tests importing beaker xml and crete templates """ s = Parser(file=filename) s.run(position=100) recipes = RecipeTemplate.objects.filter(jobtemplate=s.job) self.assertEqual(len(recipes), num_recipes, msg="Number recipes is bad") self.assertEqual(s.job.position, 100, msg="job position is same") # workaround: ignore default packages settings.BEAKER_DEFAULT_PACKAGES = [] job = JobGen() xml = job.getXML(s.job) xml_old = get_content_from_file(filename) xml = u"%s" % "".join(xml.splitlines(True)) xml_old = u"%s" % "".join(xml_old.splitlines(True)) bs1 = BeautifulSoup(xml_old, "lxml") bs2 = BeautifulSoup("".join(xml), "lxml") d = difflib.unified_diff(bs1.prettify().split("\n"), bs2.prettify().split("\n")) diff = "\n".join(d) print "-----------" print "'%s'" % diff print "-----------" self.assertEqual(len(diff), 0, msg="XML '%s' is different" % filename)