Esempio n. 1
0
 def _import_bundles(self, directory):
   for example_directory_name in os.listdir(directory):
     if os.path.isdir(os.path.join(directory, example_directory_name)):
       with open(os.path.join(directory, example_directory_name, 'bundle.zip')) as fp:
         bundle_xml, metadata = Bundle.decompress(fp)
       bundle_root = etree.fromstring(bundle_xml)
       try:
         Bundle.objects.get(name=bundle_root.get('name'))
       except Bundle.DoesNotExist:
         LOG.info(_("Installing bundle %s") % bundle_root.get('name'))
         LOG.debug("Bundle definition:\n%s" % bundle_xml)
         bundle = Bundle(owner=self.user, is_shared=True)
         bundle.name = bundle_root.get('name')
         bundle.save()
         import_bundle_root(bundle=bundle, bundle_definition_root=bundle_root, metadata=metadata)
Esempio n. 2
0
 def _import_bundles(self, directory):
   for example_directory_name in os.listdir(directory):
     if os.path.isdir(os.path.join(directory, example_directory_name)):
       with open(os.path.join(directory, example_directory_name, 'bundle.zip')) as fp:
         bundle_xml, metadata = Bundle.decompress(fp)
       bundle_root = etree.fromstring(bundle_xml)
       try:
         Bundle.objects.get(name=bundle_root.get('name'))
       except Bundle.DoesNotExist:
         LOG.info(_("Installing bundle %s") % bundle_root.get('name'))
         LOG.debug("Bundle definition:\n%s" % bundle_xml)
         bundle = Bundle(owner=self.user, is_shared=True)
         bundle.name = bundle_root.get('name')
         bundle.save()
         import_bundle_root(bundle=bundle, bundle_definition_root=bundle_root, metadata=metadata)