class CliDataFileClass(View): nav_obj = Navigator() app_directory = join_path(nav_obj.get_katana_dir(), "wapps", "cli_data") app_static_dir = join_path(app_directory, "static") def get(self, request): filepath = request.GET.get('path') # filepath = join_path(CliDataFileClass.app_static_dir, "base_templates", "test.xml") base_filepath = join_path(CliDataFileClass.app_static_dir, "base_templates", "empty.xml") if filepath == "false": filepath = base_filepath name = "Untitled" else: name, _ = os.path.splitext(get_dir_from_path(filepath)) vcdc_obj = VerifyCliDataClass(filepath, base_filepath) json_data = vcdc_obj.verify_contents() return JsonResponse({"contents": json_data, "name": name}) def post(self, request): json_data = json.loads(request.POST.get('json_data')) data = xmltodict.unparse(json_data) directory = request.POST.get('directory') filepath = os.path.join(directory, request.POST.get('filename') + ".xml") message = "" saved = True try: with open(filepath, 'w') as f: f.write(data) except Exception as e: saved = False message = e return JsonResponse({"saved": saved, "message": message})
def __init__(self, filepath): """ :param filepath: Path to the root directory of the app being installed self.navigator: Navigator() onject self.app_name: Name of the actual app directory. self.path_to_app: Path to the actual app directory self.wf_config_file: Path to the app's wf_config file self.urls_inclusions: List of ursl that need o be included in main urls.py self.mandatory_fields: Mandatory fields necessary in wf_config.json self.wapp_data: All data in the wf_config.json file self.django_based: True indicates that this app uses new Katana API. False indicates that app still uses the old Katana API """ self.navigator = Navigator() self.app_name = get_sub_folders( join_path(filepath, "warriorframework_py3", "katana", "katana.wapps"))[0] self.path_to_app = join_path(filepath, "warriorframework_py3", "katana", "katana.wapps", self.app_name) self.wf_config_file = join_path(self.path_to_app, "wf_config.json") self.urls_inclusions = [] self.mandatory_fields = [ "app", "version", "warrior-compatibility", "warrior-incompatibility" ] self.wapp_data = read_json_data(self.wf_config_file) self.django_based = False if "pure_django" not in self.wapp_data or not self.wapp_data[ "pure_django"] else True
def ready(self): """ The ready function is trigger only on events like server start up and server reload """ # print "***************You are in Core Katana App Config Class***************" nav_obj = Navigator() base_directory = nav_obj.get_katana_dir() warrior_dir = nav_obj.get_warrior_dir() config_file_name = "wf_config.json" config_json_file = join_path(base_directory, "config.json") settings_file_path = get_abs_path(join_path("wui", "settings.py"), base_directory) core_index_obj = CoreIndex(base_directory, settings_file_path=settings_file_path) available_apps = core_index_obj.get_available_apps() settings_apps = core_index_obj.get_apps_from_settings_file() AppInformation.information = Apps() AppInformation.information.set_apps({ 'base_directory': base_directory, 'config_file_name': config_file_name, 'available_apps': available_apps, 'settings_apps': settings_apps }) if os.environ["pipmode"] == "True": pythonsrcdir = read_json_data(config_json_file)['pythonsrcdir'] else: pythonsrcdir = warrior_dir ordered_json = validate_config_json(read_json_data(config_json_file), pythonsrcdir) with open(config_json_file, "w") as f: f.write(json.dumps(ordered_json, indent=4))
def after_prompt_install(request): app_path = request.POST.get("app_paths") app_name = get_dir_from_path(app_path) dot_data_dir = join_path(nav_obj.get_katana_dir(), "native", "wapp_management", ".data") temp_dir_path = join_path(dot_data_dir, "temp") output_data = {"status": True, "message": ""} if os.path.exists(temp_dir_path): shutil.rmtree(temp_dir_path) create_dir(temp_dir_path) if app_path.endswith(".git"): repo_name = get_repository_name(app_path) os.system("git clone {0} {1}".format( app_path, join_path(temp_dir_path, repo_name))) app_path = join_path(temp_dir_path, repo_name) elif app_path.endswith(".zip"): if os.path.exists(app_path): temp = app_path.split(os.sep) temp = temp[len(temp) - 1] shutil.copyfile(app_path, join_path(temp_dir_path, temp)) zip_ref = zipfile.ZipFile(join_path(temp_dir_path, temp), 'r') zip_ref.extractall(temp_dir_path) zip_ref.close() app_path = join_path(temp_dir_path, temp[:-4]) else: output_data["status"] = False output_data[ "message"] = "-- An Error Occurred -- {0} does not exist".format( app_path) print(output_data["message"]) else: if os.path.isdir(app_path): filename = get_dir_from_path(app_path) copy_dir(app_path, join_path(temp_dir_path, filename)) app_path = join_path(temp_dir_path, filename) else: output_data["status"] = False output_data[ "message"] = "-- An Error Occurred -- {0} does not exist".format( app_path) print(output_data["message"]) if os.path.exists( join_path(get_parent_directory(nav_obj.get_katana_dir()), "katana", "wapps", app_name)): output_data["status"] = True output_data["message"] = "{0} app installed succesfully.".format( app_name) remove_appurl_from_urls_custom(app_name, "wapps") remove_app_from_settings_custom(app_name, "wapps") remove_cust_app_source(app_name, "wapps") #ping thread install_custom_app(app_name, app_path) return JsonResponse(output_data)
def open_config(request): config_name = request.GET['config_name'] config_path = join_path(WappManagementView.dot_data_directory, "{0}.xml".format(config_name)) config_file_data_dir = join_path(WappManagementView.dot_data_directory, config_name) info = [] show_install_btn = True with open(config_path, 'r') as f: data = f.read() tree = ET.ElementTree(ET.fromstring(data)) apps = tree.findall('app') for app in apps: temp = {} if app.find('zip', None) is not None: node = app.find('zip', None) type_of_app = "zip" text = node.text if not os.path.exists(join_path(config_file_data_dir, text)): show_install_btn = False needs_update = True else: needs_update = False elif app.find('repository', None) is not None: node = app.find('repository', None) type_of_app = "repository" text = node.text needs_update = False else: node = app.find('filepath', None) type_of_app = "filepath" text = node.text if not os.path.exists(text): show_install_btn = False needs_update = True else: needs_update = False temp["name"] = text temp["type"] = type_of_app temp["needs_update"] = needs_update info.append(temp) output_data = { "config_name": config_name, "preference_details": info, "show_install_btn": show_install_btn } return render(request, 'wapp_management/config_details.html', output_data)
def __init__(self, base_directory, path_to_app): self.base_directory = base_directory self.app_directory = join_path(self.base_directory, "katana", "katana.wapps") self.plugin_directory = join_path(self.base_directory, "warrior", "plugins") self.settings_file = join_path(self.base_directory, "katana", "katana.wui", "settings.py") self.urls_file = join_path(self.base_directory, "katana", "katana.wui", "urls.py") self.app_name = get_sub_folders( join_path(path_to_app, "warriorframework_py3", "katana", "katana.wapps"))[0] self.path_to_app = join_path(path_to_app, "warriorframework_py3", "katana", "katana.wapps", self.app_name) self.path_to_plugin_dir = join_path(path_to_app, "warriorframework_py3", "warrior", "plugins") self.wf_config_file = join_path(self.path_to_app, "wf_config.json") self.plugins_paths = get_sub_folders(self.path_to_plugin_dir, abs_path=True) self.pkg_in_settings = "katana.wapps.{0}".format(self.app_name) self.urls_inclusions = [] self.settings_backup = [] self.urls_backup = [] self.delete_app_dir = [] self.delete_plugins_dir = [] self.config_data = None self.message = ""
def __add_app_directory(self): temp_app_path = join_path(self.app_directory, self.app_name) if os.path.exists(temp_app_path): wf_config_extng = os.path.join(temp_app_path, "wf_config.json") wf_config_new = os.path.join(self.path_to_app, "wf_config.json") data_extng = read_json_data(wf_config_extng) data_new = read_json_data(wf_config_new) existing_version = data_extng["version"] new_version = data_new["version"] if existing_version == new_version: app_status = "Reinstall" elif existing_version < new_version: app_status = "Upgrade" else: app_status = "Downgrade" output = "Prompt" if app_status == "Reinstall": message = "{0} app with the same version {1} already exists. Do you want to {2}?".format( self.app_name, new_version, app_status) else: message = "{0} app with the version {1} already exists. Do you want to {2} to {3}?".format( self.app_name, existing_version, app_status, new_version) print(message) self.message += message else: output = copy_dir(self.path_to_app, temp_app_path) self.delete_app_dir.append(self.path_to_app) return output
def save_file(request): """ This function saves the file in the given path. """ output = {"status": True, "message": ""} data = json.loads(request.POST.get("data"), object_pairs_hook=collections.OrderedDict) # check for medatory details if data['Project']['Details']['Engineer'] == '' or data['Project'][ 'Details']['Name'] == '' or data['Project']['Details'][ 'Title'] == '': output['status'] = False data["Project"]["Details"] = validate_details_data( data["Project"]["Details"]) data["Project"]["Testsuites"]["Testsuite"] = validate_suite_data( data["Project"]["Testsuites"]["Testsuite"]) xml_data = xmltodict.unparse(data, pretty=True) directory = request.POST.get("directory") filename = request.POST.get("filename") extension = request.POST.get("extension") if output['status']: try: with open(join_path(directory, filename + extension), 'w') as f: f.write(xml_data) except Exception as e: output["status"] = False output["message"] = e print("-- An Error Occurred -- {0}".format(e)) return JsonResponse(output)
def post(self, request): app_paths = request.POST.getlist("app_paths[]") filename = request.POST.get("filename") root = ET.Element("data") for app_path in app_paths: app = ET.SubElement(root, "app") if os.path.exists(app_path): ET.SubElement(app, "filepath").text = app_path else: ET.SubElement(app, "repository").text = app_path fpath = join_path(WappManagementView.dot_data_directory, "{0}.xml".format(filename)) xml_str = ET.tostring(root, encoding='utf-8', method='xml') with open(fpath, "w") as f: f.write(xml_str.decode('utf-8')) files = get_sub_files(WappManagementView.dot_data_directory) preferences = [] for subfile in files: filename, file_extension = os.path.splitext(subfile) if file_extension == ".xml": preferences.append(filename) output_data = {"data": {"preferences": preferences}} return render(request, 'wapp_management/saved_preferences.html', output_data)
def prerequisites_handler(self, request): ref_file = join_path(self.static_dir, "base_templates", "empty.xml") prereqs = read_xml_get_json(ref_file)["data"]["warhorn"]["dependency"] prereq_data = [] for prereq in prereqs: temp = {} for key, value in list(prereq.items()): temp[key.strip('@')] = value temp["status"] = "install" try: module_name = __import__(temp["name"]) some_var = module_name.__version__ except ImportError: temp["available_version"] = "--" temp["installBtnText"] = "Install" except Exception as e: print( "-- An Exception Occurred -- while getting details about {0}: {1}" .format(temp["name"], e)) temp["available_version"] = "--" temp["installBtnText"] = "Install" else: temp["available_version"] = some_var if LooseVersion(str(temp["version"])) <= LooseVersion( str(temp["available_version"])): temp["installBtnText"] = "Installed" temp["status"] = "installed" else: temp["installBtnText"] = "Upgrade" temp["status"] = "upgrade" prereq_data.append(copy.deepcopy(temp)) return prereq_data
class WappManagementView(View): template = 'wapp_management/wapp_management.html' dot_data_directory = join_path(nav_obj.get_katana_dir(), "katana.native", "wapp_management", ".data") def get(self, request): """ Get Request Method """ files = get_sub_files(WappManagementView.dot_data_directory) preferences = [] for subfile in files: filename, file_extension = os.path.splitext(subfile) if file_extension == ".xml": preferences.append(filename) output = { "data": { "app": AppInformation.information.apps, "preferences": preferences } } if self.request.user.groups.filter( name='can_access_wappmanagement').exists(): return render(request, WappManagementView.template, output) else: return render(request, 'wapp_management/error_page.html')
def __init__(self, json_data, path, base_directory): """Constructor of the App Class""" self.data = json_data self.path = get_relative_path(path, base_directory) self.static_file_dir = join_path("static", get_dir_from_path(path)) self.app_type = get_dir_from_path(get_parent_directory(path)) self.app_dir_name = get_dir_from_path(path)
def read_config_file(request): nav_obj = Navigator() config_file_path = join_path(nav_obj.get_katana_dir(), "config.json") data = read_json_data(config_file_path) if data is None: data = False return JsonResponse(data)
def install_an_app(request): app_path = request.POST.get("app_paths") dot_data_dir = join_path(nav_obj.get_katana_dir(), "native", "wapp_management", ".data") temp_dir_path = join_path(dot_data_dir, "temp") output_data = {"status": True, "message": ""} if os.path.exists(temp_dir_path): shutil.rmtree(temp_dir_path) create_dir(temp_dir_path) if app_path.endswith(".git"): repo_name = get_repository_name(app_path) os.system("git clone {0} {1}".format( app_path, join_path(temp_dir_path, repo_name))) app_path = join_path(temp_dir_path, repo_name) elif app_path.endswith(".zip"): if os.path.exists(app_path): temp = app_path.split(os.sep) temp = temp[len(temp) - 1] shutil.copyfile(app_path, join_path(temp_dir_path, temp)) zip_ref = zipfile.ZipFile(join_path(temp_dir_path, temp), 'r') zip_ref.extractall(temp_dir_path) zip_ref.close() app_path = join_path(temp_dir_path, temp[:-4]) else: output_data["status"] = False output_data[ "message"] = "-- An Error Occurred -- {0} does not exist".format( app_path) print(output_data["message"]) else: if os.path.isdir(app_path): filename = get_dir_from_path(app_path) copy_dir(app_path, join_path(temp_dir_path, filename)) app_path = join_path(temp_dir_path, filename) else: output_data["status"] = False output_data[ "message"] = "-- An Error Occurred -- {0} does not exist".format( app_path) print(output_data["message"]) installer_obj = Installer(get_parent_directory(nav_obj.get_katana_dir()), app_path) installer_output = installer_obj.install() if installer_obj.message != "" and installer_output != "Prompt": output_data["status"] = False output_data["message"] += "\n" + installer_obj.message elif installer_obj.message != "" and installer_output == "Prompt": output_data["status"] = "Prompt" output_data["message"] += "\n" + installer_obj.message return JsonResponse(output_data)
def validate_app_path(request): output = {"status": True, "message": ""} detail_type = request.POST.get("type", None) detail_info = request.POST.get("value", None) dot_data_dir = join_path(nav_obj.get_katana_dir(), "katana.native", "wapp_management", ".data") temp_dir_path = join_path(dot_data_dir, "temp") app_path = False if os.path.exists(temp_dir_path): shutil.rmtree(temp_dir_path) if create_dir(temp_dir_path): if detail_type == "repository": repo_name = get_repository_name(detail_info) os.system("git clone {0} {1}".format( detail_info, join_path(temp_dir_path, repo_name))) app_path = join_path(temp_dir_path, repo_name) elif detail_type == "zip": if os.path.exists(detail_info): temp = detail_info.split(os.sep) temp = temp[len(temp) - 1] shutil.copyfile(detail_info, join_path(temp_dir_path, temp)) zip_ref = zipfile.ZipFile(join_path(temp_dir_path, temp), 'r') zip_ref.extractall(temp_dir_path) zip_ref.close() app_path = join_path(temp_dir_path, temp[:-4]) else: output["status"] = False output["message"] = "{0} does not exist".format(detail_info) print("-- An Error Occurred -- ".format(output["message"])) elif detail_type == "filepath": if os.path.isdir(detail_info): filename = get_dir_from_path(detail_info) copy_dir(detail_info, join_path(temp_dir_path, filename)) app_path = join_path(temp_dir_path, filename) else: output["status"] = False output[ "message"] = "{0} does not exist or is not a directory".format( detail_info) print("-- An Error Occurred -- {0}".format(output["message"])) else: print("-- An Error Occurred -- Type of validation not given.") if app_path: app_validator_obj = AppValidator(app_path) output = app_validator_obj.is_valid() else: print("-- An Error Occurred -- Could not create temporary directory.") return JsonResponse(output)
def check_if_file_exists(request): filename = request.POST.get("filename") directory = request.POST.get("directory") extension = request.POST.get("extension") path = request.POST.get("path") if path is not None: output = {"exists": file_or_dir_exists(path)} else: output = {"exists": file_or_dir_exists(join_path(directory, filename + extension))} return JsonResponse(output)
def __init__(self, data_file, ref_data_file): self.data_file = data_file self.data = read_xml_get_json(data_file) self.ref_data_file = ref_data_file self.nav_obj = Navigator() self.dependency_template = join_path(self.nav_obj.get_katana_dir(), "native", "settings", "static", "settings", "base_templates", "empty.xml") self.ref_data = self._get_ref_data() self.dependency_dict = self.__get_dependency_dict()
def __add_app_directory(self): temp_app_path = join_path(self.app_directory, self.app_name) if os.path.exists(temp_app_path): output = False message = "-- An Error Occurred -- Directory already exists: {0}.".format( temp_app_path) print(message) self.message += message else: output = copy_dir(self.path_to_app, temp_app_path) self.delete_app_dir.append(self.path_to_app) return output
def get(self, request): filepath = request.GET.get('path') # filepath = join_path(CliDataFileClass.app_static_dir, "base_templates", "test.xml") base_filepath = join_path(CliDataFileClass.app_static_dir, "base_templates", "empty.xml") if filepath == "false": filepath = base_filepath name = "Untitled" else: name, _ = os.path.splitext(get_dir_from_path(filepath)) vcdc_obj = VerifyCliDataClass(filepath, base_filepath) json_data = vcdc_obj.verify_contents() return JsonResponse({"contents": json_data, "name": name})
def __validate_static_directory(self): output = {"status": True, "message": ""} if os.path.isdir(join_path(self.path_to_app, "static")): subs = get_sub_dirs_and_files(join_path(self.path_to_app, "static")) if len(subs["files"]) > 0: output["status"] = False output["message"] = "static directory does not follow the required " \ "directory structure." print("-- An Error Occurred -- {0}".format(output["message"])) else: if not os.path.isdir( join_path(self.path_to_app, "static", self.app_name)): output["status"] = False output["message"] = "static directory does not follow the required " \ "directory structure." print("-- An Error Occurred -- {0}".format( output["message"])) else: subs_files = get_paths_of_subfiles( join_path(self.path_to_app, "static", self.app_name), re.compile("\.js$")) path_to_js = join_path(self.path_to_app, "static", self.app_name, "js") if not self.django_based: # Validates JS structure only if app uses old Katana API list_of_files = ", ".join([ x for x in subs_files if not x.startswith(path_to_js) ]) if list_of_files: output["status"] = False output["message"] = "A .js file cannot be outside the 'js' folder. " \ "List of files in non-compliance: {0}".format(list_of_files) print("-- An Error Occurred -- {0}".format( output["message"])) return output
def __add_plugins(self): output = True for plugin in self.plugins_paths: if output: plugin_name = get_dir_from_path(plugin) temp_pl_path = join_path(self.plugin_directory, plugin_name) if os.path.exists(temp_pl_path): output = False message = "-- An Error Occurred -- Directory already exists: {0}.".format( temp_pl_path) print(message) self.message += message else: output = copy_dir(plugin, temp_pl_path) self.delete_plugins_dir.append(plugin) return output
def set_apps(self, data): """ call this to build Apps array and make app objects """ self.get_config_paths(data) for url in self.paths: json_data = read_json_data(url) if json_data is not None: app_path = get_parent_directory(url) app = App(json_data, app_path, data["base_directory"]) js_urls = get_paths_of_subfiles( join_path(app_path, app.static_file_dir, "js"), extension=compile_regex("^\.js$")) for i in range(0, len(js_urls)): js_urls[i] = get_relative_path(js_urls[i], app_path) app.data["js_urls"] = js_urls self.apps.append(app) return self.apps
def _get_package_list(self, driver_path): """ This function gets the list of packages included in each driver """ with open(driver_path, 'r') as f: data = f.readlines() list_of_pkgs = [] package_list = [] for line in data: if line.strip().startswith( 'package_list') and line.strip().endswith(']'): temp = line.split("[")[1].strip()[:-1] list_of_pkgs = [x.strip() for x in temp.split(",")] break elif not line.strip().startswith('package_list') and line.strip( ).endswith(']'): temp = line.strip()[:-1] list_of_pkgs = [x.strip() for x in temp.split(",")] break for pkg in list_of_pkgs: temp = pkg.split(".") path = self.warrior_dir for i in range(1, len(temp)): path = join_path(path, temp[i]) package_list.append(path) return package_list
def __verify_app_details(self, app_details): output = {"status": True, "message": ""} if "name" not in app_details or "url" not in app_details or "include" not in app_details: print( "-- An Error Occurred -- wf_config.json file is not in the correct format." ) output["status"] = False else: self.urls_inclusions.append("url(r'^" + app_details["url"] + "', include('" + app_details["include"] + "')),") path_dir = app_details["include"].split(".") path_urls = "" for d in range(2, len(path_dir)): path_urls += os.sep + path_dir[d] path_urls = path_urls.strip(os.sep) path_urls += ".py" path_to_urls_abs = join_path(self.path_to_app, path_urls) if not os.path.isfile(path_to_urls_abs): output["status"] = False output["message"] = "Package {0} does not exist.".format( app_details["include"]) print("-- An Error Occurred -- {0}".format(output["message"])) return output
def __init__(self, base_directory, app_path, app_type): self.app_name = get_dir_from_path(app_path) self.base_directory = base_directory self.plugin_dir = join_path(self.base_directory, "warrior", "plugins") self.app_dir = join_path(self.base_directory, "katana", app_type) self.settings_file = join_path(self.base_directory, "katana", "wui", "settings.py") self.urls_file = join_path(self.base_directory, "katana", "wui", "urls.py") self.app_path = get_abs_path(self.app_name, self.app_dir) self.app_type = app_type self.config_file = join_path(self.app_path, "wf_config.json") self.config_file_data = read_json_data(self.config_file) self.related_plugins = self.__extract_plugin_names() self.pkg_in_settings = self.__get_setting_file_info() self.include_urls = self.__get_urls_info() self.valid_app_types = {"katana.wapps"} self.cache_dir = create_dir( join_path(self.base_directory, "katana", ".data", self.app_name)) self.settings_backup = [] self.urls_backup = []
def __init__(self, warrior_dir): """Constructor for GetDriversActions Class""" self.warrior_dir = warrior_dir self.actions_dir = join_path(self.warrior_dir, "Actions") self.pd_dir = join_path(self.warrior_dir, "ProductDrivers") self.information = self._get_drivers()
def read_config_file_data(): nav_obj = Navigator() config_file_path = join_path(nav_obj.get_katana_dir(), "config.json") data = read_json_data(config_file_path) return data
def __init__(self): self.navigator = Navigator() self.static_dir = join_path(self.navigator.get_katana_dir(), "native", "settings", "static", "settings")
from django.views import View import collections import json import os import xmltodict from django.http import JsonResponse from django.template.loader import render_to_string from katana.utils.directory_traversal_utils import join_path, get_parent_dir_path, get_dir_from_path from katana.utils.json_utils import read_json_data, read_xml_get_json from katana.utils.navigator_util import Navigator from katana.wapps.projects.project_utils.defaults import on_errors, impacts, contexts, runmodes, \ executiontypes, runtypes from katana.wapps.projects.project_utils.verify_project_file import VerifyProjectFile navigator = Navigator() CONFIG_FILE = join_path(navigator.get_katana_dir(), "config.json") APP_DIR = join_path(navigator.get_katana_dir(), "wapps", "projects") STATIC_DIR = join_path(APP_DIR, "static", "projects") TEMPLATE = join_path(STATIC_DIR, "base_templates", "Project_Template.xml") DROPDOWN_DEFAULTS = read_json_data( join_path(STATIC_DIR, "base_templates", "dropdowns_data.json")) class projectsView(View): def get(self, request): """ Get Request Method """ return render(request, 'projects/projects.html')
def validate_config_json(json_data, warrior_dir): """ This function validates the config.json file and returns an ordered dictionary :param json_data: original unordered contents of config.json :param warrior_dir: path to warrior directory :return: Ordered Dictionary containing validated config.json data """ userobj = Navigator() if json_data["userreposdir"] == "": default_userrepo = "" else: default_userrepo = json_data["userreposdir"] ordered_json = OrderedDict() if "engineer" not in json_data: ordered_json["engineer"] = "" else: ordered_json["engineer"] = "" for key in json_data: pattern = r'userreposdir*[0-9a-zA-Z]*' result = re.match(pattern, str(key)) if result: path = json_data[key] reponame = key if reponame: if reponame == "userreposdir": if reponame not in json_data: ordered_json[reponame] = "" else: ordered_json[reponame] = warrior_dir[:-1] else: ordered_json[reponame] = json_data[reponame] ordered_json[reponame] = path else: ordered_json[reponame] = "" if os.environ["pipmode"] == 'True': ordered_json["pythonsrcdir"] = warrior_dir else: ordered_json["pythonsrcdir"] = warrior_dir[:-1] \ if "pythonsrcdir" not in json_data or json_data["pythonsrcdir"] == "" \ else json_data["pythonsrcdir"] warrior_dir = ordered_json["pythonsrcdir"] ref = OrderedDict([ ("xmldir", "Testcases"), ('testsuitedir', 'Suites'), ('projdir', 'Projects'), ('idfdir', 'Data'), ('testdata', 'Config_files'), ('testwrapper', 'wrapper_files'), ]) ref.update(ordered_json) if os.environ["pipmode"] == 'True': if warrior_dir == "": for key, value in list(ref.items()): ordered_json[key] = "" else: for key, value in list(ref.items()): ordered_json[key] = json_data[key] ordered_json['userreposdir'] = default_userrepo else: for key, value in list(ref.items()): if key not in json_data or json_data[key] == "": if key == "engineer" and value == "": pass else: path = get_abs_path(join_path("Warriorspace", value), warrior_dir) if path is not None: ordered_json[key] = path else: ordered_json[key] = "" print( "-- An Error Occurred -- Path to {0} directory could not be located" .format(value)) else: ordered_json[key] = json_data[key] if "pythonpath" not in json_data: ordered_json["pythonpath"] = "" else: ordered_json["pythonpath"] = json_data["pythonpath"] return ordered_json