import lttng_ivc.settings as Settings
from lttng_ivc.utils.utils import sha256_checksum
-from lttng_ivc.utils.utils import find_dir
+from lttng_ivc.utils.utils import find_dir, find_file
_logger = logging.getLogger('project')
self.add_special_env_variable("LTTNG_SESSION_CONFIG_XSD_PATH",
os.path.join(self.installation_path, "share/xml/lttng/"))
+ # Find the mi xsd
+ for xsd in Settings.mi_xsd_file_name:
+ mi = find_file(self.source_path, xsd)
+ if mi:
+ break
+ if not mi:
+ raise Exception("MI xsd not found")
+ self.mi_xsd = mi
+
class Babeltrace(Project):
pass
return abs_path
+def find_file(root, name):
+ """
+ Returns the absolute path or None.
+ """
+ print(root)
+ print(name)
+ abs_path = None
+ for base, dirs, files in os.walk(root):
+ for tmp in files:
+ if tmp.endswith(name):
+ abs_path = os.path.abspath(os.path.join(base, tmp))
+ print(abs_path)
+ return abs_path
+
+
+def validate(xml_path, xsd_path):
+
+ xmlschema_doc = etree.parse(xsd_path)
+ xmlschema = etree.XMLSchema(xmlschema_doc)
+
+ xml_doc = etree.parse(xml_path)
+ result = xmlschema.validate(xml_doc)
+
+ return result
+
def xpath_query(xml_file, xpath):
"""
Return a list of xml node corresponding to the xpath. The list can be of lenght