зеркало из https://github.com/Azure/iotedgedev.git
allow non module project (#400)
* Allow non-module project in modules folder * Fix py27 unicode issue * Remove language property for module
This commit is contained in:
Родитель
322ba869e2
Коммит
dc86e2816d
|
@ -13,7 +13,6 @@ class Module(object):
|
|||
self.utility = utility
|
||||
self.module_dir = module_dir
|
||||
self.module_json_file = os.path.join(self.module_dir, "module.json")
|
||||
self.module_language = "csharp"
|
||||
self.file_json_content = None
|
||||
self.load_module_json()
|
||||
|
||||
|
@ -21,7 +20,6 @@ class Module(object):
|
|||
if os.path.exists(self.module_json_file):
|
||||
try:
|
||||
self.file_json_content = json.loads(Utility.get_file_contents(self.module_json_file, expandvars=True))
|
||||
self.module_language = self.file_json_content.get("language").lower()
|
||||
except KeyError as e:
|
||||
raise KeyError("Error parsing {0} from module.json file : {1}".format(str(e), self.module_json_file))
|
||||
except IOError:
|
||||
|
@ -29,10 +27,6 @@ class Module(object):
|
|||
else:
|
||||
raise FileNotFoundError("No module.json file found. module.json file is required in the root of your module folder")
|
||||
|
||||
@property
|
||||
def language(self):
|
||||
return self.module_language
|
||||
|
||||
@property
|
||||
def platforms(self):
|
||||
return self.file_json_content.get("image", {}).get("tag", {}).get("platforms", "")
|
||||
|
|
|
@ -5,6 +5,7 @@ import sys
|
|||
from zipfile import ZipFile
|
||||
|
||||
import commentjson
|
||||
import six
|
||||
from six import BytesIO
|
||||
from six.moves.urllib.request import urlopen
|
||||
|
||||
|
@ -145,8 +146,10 @@ class Modules:
|
|||
modules_path = os.path.join(template_file_folder, self.envvars.MODULES_PATH)
|
||||
if os.path.isdir(modules_path):
|
||||
for folder_name in os.listdir(modules_path):
|
||||
module = Module(self.envvars, self.utility, os.path.join(modules_path, folder_name))
|
||||
self._update_module_maps("MODULES.{0}".format(folder_name), module, placeholder_tag_map, tag_build_profile_map, default_platform)
|
||||
project_folder = os.path.join(modules_path, folder_name)
|
||||
if os.path.exists(os.path.join(project_folder, "module.json")):
|
||||
module = Module(self.envvars, self.utility, project_folder)
|
||||
self._update_module_maps("MODULES.{0}".format(folder_name), module, placeholder_tag_map, tag_build_profile_map, default_platform)
|
||||
|
||||
# get image tags for ${MODULEDIR<relative path>.xxx} placeholder
|
||||
user_modules = deployment_manifest.get_user_modules()
|
||||
|
@ -301,7 +304,10 @@ class Modules:
|
|||
launch_json_content = Utility.get_file_contents(launch_json_file)
|
||||
for key, value in replacements.items():
|
||||
launch_json_content = launch_json_content.replace(key, value)
|
||||
launch_json = commentjson.loads(launch_json_content)
|
||||
if PY2:
|
||||
launch_json = commentjson.loads(six.binary_type(launch_json_content))
|
||||
else:
|
||||
launch_json = commentjson.loads(launch_json_content)
|
||||
if is_function and launch_json is not None and "configurations" in launch_json:
|
||||
# for Function modules, there shouldn't be launch config for local debug
|
||||
launch_json["configurations"] = list(filter(lambda x: x["request"] != "launch", launch_json["configurations"]))
|
||||
|
|
Загрузка…
Ссылка в новой задаче