* Allow non-module project in modules folder

* Fix py27 unicode issue 

* Remove language property for module
This commit is contained in:
Chaoyi Yuan 2019-07-11 15:15:27 +08:00 коммит произвёл GitHub
Родитель 322ba869e2
Коммит dc86e2816d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -13,7 +13,6 @@ class Module(object):
self.utility = utility self.utility = utility
self.module_dir = module_dir self.module_dir = module_dir
self.module_json_file = os.path.join(self.module_dir, "module.json") self.module_json_file = os.path.join(self.module_dir, "module.json")
self.module_language = "csharp"
self.file_json_content = None self.file_json_content = None
self.load_module_json() self.load_module_json()
@ -21,7 +20,6 @@ class Module(object):
if os.path.exists(self.module_json_file): if os.path.exists(self.module_json_file):
try: try:
self.file_json_content = json.loads(Utility.get_file_contents(self.module_json_file, expandvars=True)) 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: except KeyError as e:
raise KeyError("Error parsing {0} from module.json file : {1}".format(str(e), self.module_json_file)) raise KeyError("Error parsing {0} from module.json file : {1}".format(str(e), self.module_json_file))
except IOError: except IOError:
@ -29,10 +27,6 @@ class Module(object):
else: else:
raise FileNotFoundError("No module.json file found. module.json file is required in the root of your module folder") 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 @property
def platforms(self): def platforms(self):
return self.file_json_content.get("image", {}).get("tag", {}).get("platforms", "") return self.file_json_content.get("image", {}).get("tag", {}).get("platforms", "")

Просмотреть файл

@ -5,6 +5,7 @@ import sys
from zipfile import ZipFile from zipfile import ZipFile
import commentjson import commentjson
import six
from six import BytesIO from six import BytesIO
from six.moves.urllib.request import urlopen 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) modules_path = os.path.join(template_file_folder, self.envvars.MODULES_PATH)
if os.path.isdir(modules_path): if os.path.isdir(modules_path):
for folder_name in os.listdir(modules_path): for folder_name in os.listdir(modules_path):
module = Module(self.envvars, self.utility, os.path.join(modules_path, folder_name)) project_folder = 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) 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 # get image tags for ${MODULEDIR<relative path>.xxx} placeholder
user_modules = deployment_manifest.get_user_modules() user_modules = deployment_manifest.get_user_modules()
@ -301,7 +304,10 @@ class Modules:
launch_json_content = Utility.get_file_contents(launch_json_file) launch_json_content = Utility.get_file_contents(launch_json_file)
for key, value in replacements.items(): for key, value in replacements.items():
launch_json_content = launch_json_content.replace(key, value) 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: 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 # 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"])) launch_json["configurations"] = list(filter(lambda x: x["request"] != "launch", launch_json["configurations"]))

Просмотреть файл