Example #1
0
    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
Example #2
0
    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))
Example #3
0
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)
Example #4
0
    def get(self, request):
        """
        This is a get request for getting the file explorer data. It internally calls the
        get_dir_tree_json() in navigator_utils.py to get a list of directories. THIS VIEW EXISTS
        ONLY BECAUSE JSTREE DOES NOT HAVE SUPPORT FOR POST IN LAZY LOADING.

        params sent via the request:

        start_dir: Absolute path to the start directory. If not given, defaulted to "Warriorspace".
        path: Absolute path to the current directory. Send a path via this argument indicates that
              information for current directory's parent needs to be obtained. If not False, it is
              prioritized over start_dir
        lazy_loading: Indicates that jsTree lazy_loading is being used and only direct
                      sub-children's information needs to be obtained.

        """
        nav_obj = Navigator()
        start_dir = "false"
        lazy_loading = True if "lazy_loading" in request.GET and request.GET["lazy_loading"].lower() == "true" else False
        config_data = read_config_file_data()

        get_children_only = False
        if "start_dir" in request.GET:
            get_children_only = True
            start_dir = request.GET["start_dir"]

        if os.environ["pipmode"] == 'True':
            if config_data["pythonsrcdir"] != "" and start_dir == "false":
                get_children_only = False
                if config_data["xmldir"].split("/")[-2] == "warriorspace" or config_data["xmldir"].split("/")[-2] == "Warriorspace":
                    start_dir = config_data["pythonsrcdir"] + "/" +config_data["xmldir"].split("/")[-2]
                elif config_data["xmldir"].split("/")[-3] == "warriorspace" or config_data["xmldir"].split("/")[-3] == "Warriorspace":
                    start_dir = config_data["pythonsrcdir"] + "/" +config_data["xmldir"].split("/")[-3]
                else:
                    start_dir = config_data["pythonsrcdir"]
            elif config_data["pythonsrcdir"] == "" and start_dir == "false":
                get_children_only = False
                start_dir = nav_obj.get_katana_dir()
        else:
            if config_data["pythonsrcdir"] != "" and start_dir == "false":
                get_children_only = False
                if config_data["xmldir"].split("/")[-2] == "warriorspace" or config_data["xmldir"].split("/")[-2] == "Warriorspace":
                    start_dir = config_data["pythonsrcdir"] + "/" +config_data["xmldir"].split("/")[-2]
                elif config_data["xmldir"].split("/")[-3] == "warriorspace" or config_data["xmldir"].split("/")[-3] == "Warriorspace":
                    start_dir = config_data["pythonsrcdir"] + "/" +config_data["xmldir"].split("/")[-3]
                else:
                    start_dir = config_data["pythonsrcdir"]
            elif config_data["pythonsrcdir"] == "" and start_dir == "false":
                get_children_only = False
                start_dir = nav_obj.get_katana_dir()

        if "path" in request.GET:
            get_children_only = False
            start_dir = request.GET["path"]

        output = nav_obj.get_dir_tree_json(start_dir_path=start_dir, lazy_loading=lazy_loading)
        if get_children_only:
            output = output["children"]
        return JsonResponse(output, safe=False)
Example #5
0
 def __init__(self, template, file_path):
     self.navigator = Navigator()
     self.template = template
     self.file_path = file_path
     self.template_data = read_xml_get_json(template, ordered_dict=True)
     self.data = read_xml_get_json(file_path, ordered_dict=True)
     self.output = {"status": True, "message": ""}
     self.root = "Project"
 def __init__(self, template, file_path):
     """ Constructor of the VerifyCaseFile class """
     self.navigator = Navigator()
     self.template = template
     self.file_path = file_path
     self.template_data = read_xml_get_json(template, ordered_dict=True)
     self.data = read_xml_get_json(file_path, ordered_dict=True)
     self.output = {"status": True, "message": ""}
     self.root = "TestWrapper"
     self.major = ("Details", "Requirements", "Steps")
 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()
Example #8
0
def save_warhorn_config_file(request):
    nav_obj = Navigator()
    directory = request.POST.get('directory')
    if directory == "default":
        directory = os.path.join(nav_obj.get_katana_dir(), "katana.wapps",
                                 "assembler", ".data")
    filepath = os.path.join(directory, request.POST.get('filename') + ".xml")
    json_data = json.loads(request.POST.get('json_data'))
    json_data["data"]["warriorframework"] = "Test"
    data = xmltodict.unparse(json_data)
    response = _save_file(filepath, data)

    return JsonResponse(response)
Example #9
0
 def __init__(self):
     """
     Constructor for execution app
     """
     self.nav = Navigator()
     self.config_data = ""
     self.katana_dir = os.path.dirname(katana.native.__path__[0])
     self.config_json = os.path.join(self.katana_dir, 'config.json')
     self.config_json_dict = ""
     self.warrior_dir = ""
     self.warrior = ""
     self.default_ws = ""
     self.templates_dir = os.path.join(templates_dir, 'execution')
     self.jira_settings_file = ""      
     self.execution_settings_json = os.path.join(templates_dir, 'execution', 'execution_settings.json')
Example #10
0
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})
Example #11
0
def get_jstree_dir(request):
    """
        Prepare the json for jstree to use
    """
    config = read_json_data(JSON_CONFIG)
    data = Navigator().get_dir_tree_json(config["idfdir"])
    data["text"] = config["idfdir"]
    # print json.dumps(data, indent=4)
    return JsonResponse(data)
Example #12
0
 def get_user_data(self):
     """
     function is still used for backward compatibility,
     can be deprecated once completely handled by client server model
     """
     userdata = {}
     json_file = Navigator().get_katana_dir() + '/user_profile.json'
     with open(json_file, 'r') as f:
         userdata = json.load(f)
         return userdata
Example #13
0
 def __init__(self):
     """
     Constructor for execution app
     """
     self.nav = Navigator()
     self.config_data = read_config_file_data()
     self.katana_dir = os.path.dirname(native.__path__[0])
     self.wf_dir = os.path.dirname(self.katana_dir)
     self.warrior = os.path.join(self.wf_dir, 'warrior', 'Warrior')
     if os.environ["pipmode"] == 'True':
         self.default_ws = self.config_data["pythonsrcdir"]
     else:
         self.default_ws = os.path.join(self.wf_dir, 'warrior',
                                        'Warriorspace')
     self.templates_dir = os.path.join(templates_dir, 'execution')
     self.jira_settings_file = os.path.join(self.wf_dir, 'warrior', 'Tools',
                                            'jira', 'jira_config.xml')
     self.execution_settings_json = os.path.join(templates_dir, 'execution',
                                                 'execution_settings.json')
     self.config_json = os.path.join(self.katana_dir, 'config.json')
Example #14
0
def get_jstree_dir(request):
    """
        Prepare the json for jstree to use
    """
    config = read_json_data(JSON_CONFIG)
    if os.path.exists(config["idfdir"]):
        data = Navigator().get_dir_tree_json(config["idfdir"])
        data["text"] = config["idfdir"]
    else:
        data="invalid_path"
    # print json.dumps(data, indent=4)
    return JsonResponse(data, safe=False)
Example #15
0
    def post(self, request):
        """
        This is a post request for getting the file explorer data. It internally calls the
        get_dir_tree_json() in navigator_utils.py to get a list of directories.

        params sent via the request:

        start_dir: Absolute path to the start directory. If not given, defaulted to "Warriorspace".
        path: Absolute path to the current directory. Send a path via this argument indicates that
              information for current directory's parent needs to be obtained. If not False, it is
              prioritized over start_dir
        lazy_loading: Indicates that jsTree lazy_loading is being used and only direct
                      sub-children's information needs to be obtained.

        """
        nav_obj = Navigator()
        lazy_loading = True if "data[lazy_loading]" in request.POST and request.POST["data[lazy_loading]"].lower() == "true" else False
        start_dir = "false"
        config_data = read_config_file_data()
        if "data[start_dir]" in request.POST:
            start_dir = request.POST["data[start_dir]"]
        if os.environ["pipmode"] == 'True':
            if config_data["pythonsrcdir"] != "" and start_dir == "false":
                start_dir = config_data["pythonsrcdir"]
            elif config_data["pythonsrcdir"] == "" and start_dir == "false":
                start_dir = nav_obj.get_katana_dir()
        else:
            if config_data["pythonsrcdir"] != "" and start_dir == "false":
                get_children_only = False
                start_dir = config_data["pythonsrcdir"]
            elif config_data["pythonsrcdir"] == "" and start_dir == "false":
                get_children_only = False
                start_dir = nav_obj.get_katana_dir()

        if "data[path]" in request.POST and request.POST["data[path]"] != "false":
            start_dir = get_parent_directory(request.POST["data[path]"])
        output = nav_obj.get_dir_tree_json(start_dir_path=start_dir, lazy_loading=lazy_loading)
        return JsonResponse(output)
Example #16
0
def save_and_run_warhorn_config_file(request):
    nav_obj = Navigator()
    directory = request.POST.get('directory')
    if directory == "default":
        directory = os.path.join(nav_obj.get_katana_dir(), "katana.wapps",
                                 "assembler", ".data")
    filepath = os.path.join(directory, request.POST.get('filename') + ".xml")
    json_data = json.loads(request.POST.get('json_data'))
    json_data["data"]["warriorframework"] = "Test"
    data = xmltodict.unparse(json_data)
    response = _save_file(filepath, data)
    nav_obj = Navigator()
    warhorn_dir = nav_obj.get_warhorn_dir()
    current_dir = os.getcwd()
    output = ""
    if response["saved"]:
        os.chdir(warhorn_dir)
        output = subprocess.Popen(["python", "warhorn.py", filepath],
                                  stdout=subprocess.PIPE).communicate()[0]
        os.chdir(current_dir)
        os.remove(filepath)
    return JsonResponse({"output": output})
Example #17
0
def get_data_directory(request):
    nav_obj = Navigator()
    directory = os.path.join(nav_obj.get_katana_dir(), "katana.wapps",
                             "assembler", ".data")
    return JsonResponse({"data_directory": directory})
class VerifyTestWrapperFile:

    def __init__(self, template, file_path):
        """ Constructor of the VerifyCaseFile class """
        self.navigator = Navigator()
        self.template = template
        self.file_path = file_path
        self.template_data = read_xml_get_json(template, ordered_dict=True)
        self.data = read_xml_get_json(file_path, ordered_dict=True)
        self.output = {"status": True, "message": ""}
        self.root = "TestWrapper"
        self.major = ("Details", "Requirements", "Steps")

    def verify_file(self):
        """ This function verifies the case file """
        self.output = self.__verify_root()

        if self.output["status"]:
            self.__verify_details()
            self.__verify_requirements()
            self.__verify_steps()

        return self.output, self.data

    def __verify_root(self):
        """ Verifies the root of the case file """
        output = self.output
        for key in self.data:
            if key != self.root:
                output["status"] = False
                output["message"] = "{0} is not is the correct format."
                print("-- An Error Occurred -- {0}".format(output["message"]))
            break
        return output

    def __verify_details(self):
        """ Verifies the details section of the case file """
        if self.major[0] not in self.data[self.root]:
            self.data[self.root][self.major[0]] = {}
        for key, value in self.template_data[self.root][self.major[0]].items():
            key, value = self.__verified_details_key_value(key, value)
            self.data[self.root][self.major[0]][key] = self.__verify_values(key, value, self.data[self.root][self.major[0]])

    def __verified_details_key_value(self, key, value):
        """ Verifies specific keys in details """
        if value is None:
            value = ""
        if value == "":
            if key == "Engineer":
                value = self.navigator.get_engineer_name()
            if key == "Date":
                now = datetime.now()
                value = "{0}-{1}-{2}".format(now.year, now.month, now.day)
            if key == "Time":
                now = datetime.now()
                value = "{0}:{1}".format(now.hour, now.minute)
        return key, value

    def __verify_requirements(self):
        """ Verifies the requirements section of the case file """
        if self.major[1] not in self.data[self.root] or self.data[self.root][self.major[1]] is None:
            self.data[self.root][self.major[1]] = {"Requirement": []}
        elif "Requirement" not in self.data[self.root][self.major[1]] or self.data[self.root][self.major[1]]["Requirement"] is None:
            self.data[self.root][self.major[1]]["Requirement"] = []
        elif not isinstance(self.data[self.root][self.major[1]]["Requirement"], list):
            self.data[self.root][self.major[1]]["Requirement"] = [self.data[self.root][self.major[1]]["Requirement"]]

    def __verify_steps(self):
        """ Verifies the steps section of the case file """
        if self.major[2] not in self.data[self.root]:
            self.data[self.root][self.major[2]] = {"step": []}
        elif not isinstance(self.data[self.root][self.major[2]]["step"], list):
            self.data[self.root][self.major[2]]["step"] = [self.data[self.root][self.major[2]]["step"]]

    @staticmethod
    def __verified_steps_key_value(key, value, verify_data):
        """ Verifies specific keys in each step """
        if value is None:
            value = ""

        if key == "Arguments":
            if key not in verify_data or verify_data[key] is None:
                verify_data[key] = {}
            if "argument" not in verify_data[key] or verify_data[key]["argument"] is None:
                verify_data[key]["argument"] = [{}]
            elif not isinstance(verify_data[key]["argument"], list):
                verify_data[key]["argument"] = [verify_data[key]["argument"]]

        if key == "Execute":
            if key not in verify_data or verify_data[key] is None:
                verify_data[key] = {}
            if "Rule" not in verify_data[key] or verify_data[key]["Rule"] is None:
                verify_data[key]["Rule"] = [{}]
            elif not isinstance(verify_data[key]["Rule"], list):
                verify_data[key]["Rule"] = [verify_data[key]["Rule"]]

        return key, value, verify_data

    def __verify_values(self, tmpl_key, tmpl_value, parent):
        """ Verifies key value in each step with the case emplate file """
        output = ""
        if tmpl_key not in parent:
            output = tmpl_value
        elif parent[tmpl_key] is None:
            output = tmpl_value
        else:
            if isinstance(parent[tmpl_key], list):
                for i in range(0, len(parent[tmpl_key])):
                    for k, v in tmpl_value.items():
                        parent[tmpl_key][i][k] = self.__verify_values(k, v, parent[tmpl_key][i])
                    output = parent[tmpl_key]
            elif isinstance(tmpl_value, OrderedDict):
                for k, v in list(tmpl_value.items()):
                    parent[tmpl_key][k] = self.__verify_values(k, v, parent[tmpl_key])
                output = parent[tmpl_key]
            else:
                output = parent[tmpl_key] if parent[tmpl_key].strip() != "" else tmpl_value
        return output
Example #19
0
 def __init__(self):
     self.navigator = Navigator()
     self.static_dir = join_path(self.navigator.get_katana_dir(), "native",
                                 "settings", "static", "settings")
Example #20
0
class Execution(object):
    """
    Execution app class
    """
    def __init__(self):
        """
        Constructor for execution app
        """
        self.nav = Navigator()
        self.config_data = read_config_file_data()
        self.katana_dir = os.path.dirname(native.__path__[0])
        self.wf_dir = os.path.dirname(self.katana_dir)
        self.warrior = os.path.join(self.wf_dir, 'warrior', 'Warrior')
        if os.environ["pipmode"] == 'True':
            self.default_ws = self.config_data["pythonsrcdir"]
        else:
            self.default_ws = os.path.join(self.wf_dir, 'warrior',
                                           'Warriorspace')
        self.templates_dir = os.path.join(templates_dir, 'execution')
        self.jira_settings_file = os.path.join(self.wf_dir, 'warrior', 'Tools',
                                               'jira', 'jira_config.xml')
        self.execution_settings_json = os.path.join(templates_dir, 'execution',
                                                    'execution_settings.json')
        self.config_json = os.path.join(self.katana_dir, 'config.json')

    def index(self, request):
        """
        Index page for exeution app
        """
        execution_settings_dict = update_jira_proj_list(
            self.jira_settings_file, self.execution_settings_json)
        #json.loads(open(self.execution_settings_json).read())
        start_dir = self.default_ws if execution_settings_dict['defaults']['start_dir'] == 'default' \
        else execution_settings_dict['defaults']['start_dir']
        execution_settings_dict['defaults']['start_dir'] = start_dir
        index_template = os.path.join(self.templates_dir, 'execution.html')

        return render(request, index_template, execution_settings_dict)

    def get_results_index(self, request):
        """
        Render the results index html to the client
        """
        fname = 'live_html_results'
        path = data_live_dir
        fpath = file_utils.get_new_filepath(fname, path, '.html')
        html_file = open(fpath, 'w')
        html_file.write('<div data-currentTable="1"> </div> ')
        html_file.close()

        result_setting = {'fpath': fpath}
        results_template = os.path.join(self.templates_dir,
                                        'execution_results.html')
        return render(request, results_template, result_setting)

    def get_html_results(self, request):
        """
        Update the html results by reading the live html results
        file sent in the request
        """
        data_dict = json.loads(request.GET.get('data'))
        fpath = data_dict['liveHtmlFpath']
        with open(fpath) as htmlfile:
            data = htmlfile.readlines()
        return HttpResponse(data)

    def delete_live_html_file(self, request):
        """
        delete the live html file created
        """
        status = 'success'
        try:
            data_dict = json.loads(request.GET.get('data'))
            fpath = data_dict['liveHtmlFpath']
            os.remove(fpath)
        except Exception as err:
            status = 'failure'

        return HttpResponse(status)

    def get_logfile_contents(self, request):
        """
        Update the html results by reading the live html results
        file sent in the request
        """
        data_dict = json.loads(request.GET.get('data'))
        logpath = data_dict['logpath']
        logtype = data_dict['logtype']
        op_data = {}
        logfile_name = logpath.split(os.sep)[-1]

        if str(logtype.lower()) == 'defects':
            contents = json.loads(open(logpath).read())

        if str(logtype.lower()) == 'console_logs':
            contents = open(logpath).read()
            contents = contents.replace('\n', '<br>')

        op_data['logfile_name'] = logfile_name
        op_data['contents'] = contents

        return JsonResponse(op_data)

    def cleanup_data_live_dir(self, request):
        """
        Update the html results by reading the live html results
        file sent in the request
        """
        status = 'success'
        try:
            for item in os.listdir(data_live_dir):
                path = os.path.join(data_live_dir, item)
                if os.path.isfile(
                        path) and not path.endswith('donotdeletethisfile.txt'):
                    os.remove(path)
                elif os.path.isdir(path):
                    shutil.rmtree(path, 'ignore_errors')
        except Exception as err:
            print("error ceaning up dir {0}".format(data_live_dir))
            print(err)
            status = 'failure'

        return HttpResponse(status)

    def get_ws(self, request):
        """
        return the dir tree json for warriorspace
        """
        data_dict = json.loads(request.GET.get('data'))
        ws_dir = data_dict['start_dir']
        layout = self.nav.get_dir_tree_json(ws_dir)
        return JsonResponse(layout)

    def execute_warrior(self, request):
        """
        Execute warrior command and send console logs to the client in a
        streaming fashion.
        """
        data_dict = json.loads(request.GET.get('data'))
        execution_file_list = data_dict['execution_file_list']
        cmd_string = data_dict['cmd_string']
        live_html_res_file = data_dict['liveHtmlFpath']
        config_json_dict = json.loads(open(self.config_json).read())
        python_path = config_json_dict['pythonpath']

        katana_dir = os.path.dirname(katana.native.__path__[0])
        config_json = os.path.join(katana_dir, 'config.json')
        config_json_dict = json.loads(open(config_json).read())
        pythonpaths = []
        for key in config_json_dict.keys():
            if key.startswith('userreposdir'):
                repo = config_json_dict[key].split('/')
                repo = "/".join(repo[:-1])
                pythonpaths.append(repo)
        pythonpath = ':'.join(pythonpaths)
        cmd_string = cmd_string + ' -pythonpath {0}'.format(pythonpath)
        return StreamingHttpResponse(
            stream_warrior_output(self.warrior, cmd_string,
                                  execution_file_list, live_html_res_file,
                                  python_path))
Example #21
0
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
Example #22
0
    WARRIORDIR = dirname(dirname(abspath(__file__)))
    sys.path.append(WARRIORDIR)
    try:
        import katana

        os.environ["pipmode"] = "False"
    except:
        raise
from katana.primary_process import __appmanager__, install_custom_app, install_default_apps, \
    remove_app_from_settings_custom, remove_appurl_from_urls_custom, remove_cust_app_source, \
    update_fname, update_logo, update_panel_color, create_log
from katana.utils.navigator_util import Navigator
from katana.utils.json_utils import read_json_data
from katana.utils.directory_traversal_utils import join_path

nav_obj = Navigator()
BASE_DIR = nav_obj.get_katana_dir()
wapps_dir_path = BASE_DIR + "/wapps/"
wapps_dir = BASE_DIR + "/wapps"
native_dir = BASE_DIR + "/native"
settings_file = BASE_DIR + "/wui/settings.py"

if os.environ["pipmode"] == "True":
    virtual_env = os.getenv('VIRTUAL_ENV')
    if virtual_env:
        app_config_file = virtual_env + os.sep + "katana_configs" + os.sep + "app_config.json"
    elif os.path.exists(site.getuserbase() + os.sep + "katana_configs"):
        app_config_file = site.getuserbase(
        ) + os.sep + "katana_configs" + os.sep + "app_config.json"
    elif os.path.exists("/usr/local/katana_configs"):
        app_config_file = "/usr/local/katana_configs/app_config.json"
Example #23
0
import shutil
import zipfile
from django.http import JsonResponse
from django.shortcuts import render
from django.views import View
import xml.etree.cElementTree as ET
from katana.native.wapp_management.wapp_management_utils.app_validator import AppValidator
from katana.native.wapp_management.wapp_management_utils.installer import Installer
from katana.native.wapp_management.wapp_management_utils.uninstaller import Uninstaller
from katana.utils.directory_traversal_utils import join_path, get_sub_files, get_parent_directory, \
    create_dir, get_dir_from_path
from katana.utils.file_utils import copy_dir
from katana.utils.navigator_util import Navigator
from katana.utils.string_utils import get_repository_name
from katana.wui.core.core_utils.app_info_class import AppInformation
nav_obj = Navigator()


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:
Example #24
0
class AppValidator:
    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 is_valid(self):
        output = {"status": True, "message": ""}
        if os.path.exists(self.wf_config_file):
            if self.wapp_data is not None:
                for field in self.mandatory_fields:
                    if output["status"] and field not in self.wapp_data:
                        output["status"] = False
                        output[
                            "message"] = "wf_config.json is not in the correct format."
                        print("-- An Error Occurred -- {0}".format(
                            output["message"]))

                if output["status"]:
                    output = self.__verify_app_details(self.wapp_data["app"])

                # validate version compatibility
                if output["status"]:
                    output = self.__is_compatible(self.wapp_data)

                # validate databases if any
                if output["status"] and "database" in self.wapp_data:
                    if isinstance(self.wapp_data["database"], list):
                        for db_details in self.wapp_data["database"]:
                            if output["status"]:
                                output = self.__verify_db_details(db_details)
                    else:
                        output = self.__verify_db_details(
                            self.wapp_data["database"])
            else:
                output["status"] = False
                output[
                    "message"] = "wf_config.json is not in the correct format."
                print("-- An Error Occurred -- {0}".format(output["message"]))

            if output["status"]:
                output = self.__validate_static_directory()
        else:
            output["status"] = False
            output["message"] = "wf_config.json does not exist."
            print("-- An Error Occurred -- {0}".format(output["message"]))
        return output

    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 __is_compatible(self, data):
        output = {"status": True, "message": ""}
        warrior_version = self.navigator.get_wf_version()
        all_warrior_versions = self.navigator.get_all_wf_versions()
        allowed, bounds, err_alwd = get_version_list(
            data[self.mandatory_fields[2]], all_warrior_versions)
        disallowed, excluded_bounds, err_disalwd = get_version_list(
            data[self.mandatory_fields[3]], all_warrior_versions)

        in_allowed = check_against_version_list(warrior_version, allowed,
                                                bounds)
        in_disallowed = check_against_version_list(warrior_version, disallowed,
                                                   excluded_bounds)

        if not in_allowed:
            output["status"] = False
            if not err_alwd:
                output["message"] = "-- An Error Occurred -- {0} (Version: {1}) incompatible with " \
                                    "the current WarriorFramework (Version: {2})."\
                    .format(self.app_name, data["version"], warrior_version)
            else:
                output[
                    "message"] = "-- An Error Occurred -- Compatible versions could not be verified."
        elif in_disallowed:
            output["status"] = False
            output["message"] = "-- An Error Occurred -- {0} (Version: {1}) incompatible with " \
                                "the current WarriorFramework (Version: {2})." \
                .format(self.app_name, data["version"], warrior_version)
        elif not in_disallowed and err_disalwd:
            output["status"] = False
            output[
                "message"] = "-- An Error Occurred -- Incompatible versions could not be verified."
        return output

    def __verify_db_details(self, db_details):
        output = {"status": True, "message": ""}
        for key in db_details:
            if not key.startswith(self.app_name):
                output["status"] = False
                output[
                    "message"] = "wf_config.json file is not formatted correctly"
                print("-- An Error Occurred -- {0}".format(output["message"]))
        return output

    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
class VerifyFileContents:
    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 _get_ref_data(self):
        data = read_xml_get_json(self.ref_data_file)
        dependency_data = read_xml_get_json(self.dependency_template)
        data["data"]["warhorn"] = copy.deepcopy(
            dependency_data["data"]["warhorn"])
        return data

    def __get_dependency_dict(self):
        output = {}
        for el in self.ref_data["data"]["warhorn"]["dependency"]:
            output[el["@name"]] = {
                "version": el["@version"],
                "description": el["@description"]
            }
        return output

    def verify_file(self):
        output = {"status": True, "message": ""}

        if self.data is None:
            output["status"] = False
            output[
                "message"] = "An error occurred while trying to read {0}".format(
                    self.data_file)
        elif "data" not in self.data:
            output["status"] = False
            output[
                "message"] = "{0} does not seem to be in correct format".format(
                    self.data_file)

        if output["status"]:
            self.verify_dependency_json()
            self.verify_tools_data()
            self.verify_drivers_json()
            self.verify_warriorspace_data()

        return output

    def verify_dependency_json(self, ):
        flag = True
        if "warhorn" not in self.data["data"]:
            self.data["data"]["warhorn"] = copy.deepcopy(
                self.ref_data["data"]["warhorn"])
            flag = False
        if "dependency" not in self.data["data"]["warhorn"]:
            self.data["data"]["warhorn"]["dependency"] = copy.deepcopy(
                self.ref_data["data"]["warhorn"]["dependency"])
            flag = False
        if not isinstance(self.data["data"]["warhorn"]["dependency"], list):
            self.data["data"]["warhorn"]["dependency"] = [
                self.data["data"]["warhorn"]["dependency"]
            ]

        if flag:
            data = copy.deepcopy(self.data["data"]["warhorn"]["dependency"])
            extra_dependencies = set()
            for i in range(0, len(data)):
                for key, value in data[i].items():
                    if key == "@name":
                        if value in self.dependency_dict:
                            data[i]["version"] = self.dependency_dict[value][
                                "version"]
                            data[i]["description"] = self.dependency_dict[
                                value]["description"]
                            try:
                                module_name = __import__(value)
                                some_var = module_name.__version__
                            except ImportError:
                                data[i]["installed"] = False
                                data[i]["matched"] = False
                            except Exception as e:
                                print("-- An Exception Occurred -- while getting details about " \
                                      "{0}: {1}".format(value, e))
                                data[i]["installed"] = False
                                data[i]["matched"] = False
                            else:
                                data[i]["installed"] = some_var
                                if self.dependency_dict[value] == some_var:
                                    data[i]["matched"] = True
                                elif self.dependency_dict[value] > some_var:
                                    data[i]["matched"] = "lower"
                                else:
                                    data[i]["matched"] = "higher"
                            break
                        else:
                            extra_dependencies.add(i)
            dependency_list = []
            for i in range(0, len(data)):
                if i not in extra_dependencies:
                    dependency_list.append(copy.deepcopy(data[i]))
            self.data["data"]["warhorn"]["dependency"] = copy.deepcopy(
                dependency_list)

    def verify_tools_data(self):
        if "tools" not in self.data["data"]:
            self.data["data"]["tools"] = copy.deepcopy(
                self.ref_data["data"]["tools"])
        else:
            for key, value in self.ref_data["data"]["tools"].items():
                if key not in self.data["data"]["tools"]:
                    self.data["data"]["tools"][key] = self.ref_data["data"][
                        "tools"][key]

            url = self.data["data"]["tools"]["@url"]
            if url != "":
                self.data["data"]["tools"]["name"] = get_repository_name(
                    url=url)
                self.data["data"]["tools"][
                    "available"] = check_url_is_a_valid_repo(url=url)
            else:
                self.data["data"]["tools"]["available"] = False

    def verify_drivers_json(self):
        flag = True
        if "drivers" not in self.data["data"]:
            self.data["data"]["drivers"] = copy.deepcopy(
                self.ref_data["data"]["drivers"])
            flag = False

        if "repository" not in self.data["data"]["drivers"]:
            self.data["data"]["drivers"]["repository"] = copy.deepcopy(
                self.ref_data["data"]["drivers"]["repository"])
            flag = False

        if not isinstance(self.data["data"]["drivers"]["repository"], list):
            self.data["data"]["drivers"]["repository"] = [
                self.data["data"]["drivers"]["repository"]
            ]

        if flag:
            for i in range(0, len(self.data["data"]["drivers"]["repository"])):
                for key, value in self.ref_data["data"]["drivers"][
                        "repository"].items():
                    if key not in self.data["data"]["drivers"]["repository"][
                            i]:
                        if key != "driver":
                            self.data["data"]["drivers"]["repository"][i][
                                key] = self.ref_data["data"]["drivers"][
                                    "repository"]["key"]
                        else:
                            self.data["data"]["drivers"]["repository"][i][
                                key] = copy.deepcopy(
                                    self.ref_data["data"]["drivers"]
                                    ["repository"][key])

                            if not isinstance(
                                    self.data["data"]["drivers"]["repository"]
                                [i][key], list):
                                self.data["data"]["drivers"]["repository"][i][
                                    key] = [
                                        self.data["data"]["drivers"]
                                        ["repository"][i][key]
                                    ]

                url = self.data["data"]["drivers"]["repository"][i]["@url"]
                if url != "":
                    self.data["data"]["drivers"]["repository"][i][
                        "name"] = get_repository_name(url=url)
                    available = check_url_is_a_valid_repo(url=url)
                    self.data["data"]["drivers"]["repository"][i][
                        "available"] = available
                    if available:
                        drivers_data = []
                        drivers_index = set()
                        temp_directory = os.path.join(
                            self.nav_obj.get_katana_dir(), "katana.wapps",
                            "assembler", ".data")
                        kw_repo_obj = KwRepositoryDetails(url, temp_directory)
                        drivers = set(kw_repo_obj.get_pd_names())

                        if not isinstance(
                                self.data["data"]["drivers"]["repository"][i]
                            ["driver"], list):
                            self.data["data"]["drivers"]["repository"][i][
                                "driver"] = [
                                    self.data["data"]["drivers"]["repository"]
                                    [i]["driver"]
                                ]

                        for j in range(
                                0,
                                len(self.data["data"]["drivers"]["repository"]
                                    [i]["driver"])):
                            if "@name" not in self.data["data"]["drivers"][
                                    "repository"][i]["driver"][j]:
                                self.data["data"]["drivers"]["repository"][i][
                                    "driver"][j]["@name"] = self.ref_data[
                                        "data"]["drivers"]["repository"][
                                            "driver"]["@name"]
                            else:
                                if self.data["data"]["drivers"]["repository"][
                                        i]["driver"][j]["@name"] in drivers:
                                    drivers.remove(self.data["data"]["drivers"]
                                                   ["repository"][i]["driver"]
                                                   [j]["@name"])
                                else:
                                    drivers_index.add(j)
                            if "@clone" not in self.data["data"]["drivers"][
                                    "repository"][i]["driver"][j]:
                                self.data["data"]["drivers"]["repository"][i][
                                    "driver"][j]["@clone"] = self.ref_data[
                                        "data"]["drivers"]["repository"][
                                            "driver"]["@clone"]

                        for j in range(
                                0,
                                len(self.data["data"]["drivers"]["repository"]
                                    [i]["driver"])):
                            if j not in drivers_index:
                                drivers_data.append(
                                    copy.deepcopy(
                                        self.data["data"]["drivers"]
                                        ["repository"][i]["driver"][j]))
                        self.data["data"]["drivers"]["repository"][i][
                            "driver"] = copy.deepcopy(drivers_data)

                        for driver_name in drivers:
                            self.data["data"]["drivers"]["repository"][i][
                                "driver"].append({
                                    "@name": driver_name,
                                    "@clone": "no"
                                })

                        if os.path.isdir(kw_repo_obj.repo_directory):
                            delete_dir(kw_repo_obj.repo_directory)
                else:
                    self.data["data"]["drivers"]["repository"][i][
                        "available"] = False

    def verify_warriorspace_data(self):
        flag = True
        if "warriorspace" not in self.data["data"]:
            flag = False
            self.data["data"]["warriorspace"] = copy.deepcopy(
                self.ref_data["data"]["warriorspace"])

        if "repository" not in self.data["data"]["warriorspace"]:
            flag = False
            self.data["data"]["warriorspace"]["repository"] = copy.copy(
                self.ref_data["data"]["warriorspace"]["repository"])

        if not isinstance(self.data["data"]["warriorspace"]["repository"],
                          list):
            self.data["data"]["warriorspace"]["repository"] = [
                self.data["data"]["warriorspace"]["repository"]
            ]

        if flag:
            for i in range(
                    0, len(self.data["data"]["warriorspace"]["repository"])):
                for key, value in self.ref_data["data"]["warriorspace"][
                        "repository"].items():
                    if key not in self.data["data"]["warriorspace"][
                            "repository"][i]:
                        self.data["data"]["warriorspace"]["repository"][i][
                            key] = self.ref_data["data"]["warriorspace"][
                                "repository"][key]

                url = self.data["data"]["warriorspace"]["repository"][i][
                    "@url"]
                if url != "":
                    self.data["data"]["warriorspace"]["repository"][i][
                        "name"] = get_repository_name(url=url)
                    self.data["data"]["warriorspace"]["repository"][i][
                        "available"] = check_url_is_a_valid_repo(url=url)
                else:
                    self.data["data"]["warriorspace"]["repository"][i][
                        "available"] = False
    os.environ["pipmode"] = "True"
# except ModuleNotFoundError as error:
except:
    WARRIORDIR = dirname(dirname(abspath(__file__)))
    sys.path.append(WARRIORDIR)
    try:
        import katana

        os.environ["pipmode"] = "False"
    except:
        raise

from katana.utils.navigator_util import Navigator

nav_obj = Navigator()
BASE_DIR = nav_obj.get_katana_dir()
appmanage_py = os.path.join(BASE_DIR, "appmanage.py")

data = requests.get('https://pypi.python.org/pypi/katanaframework/json')
data = data.json()
ord_dict = OrderedDict()
ord_dict = data['releases'].keys()
versn_list = list(ord_dict)

if (os.path.exists(os.path.join(BASE_DIR, 'wapps'))
        or os.path.exists(os.path.join(BASE_DIR, 'native'))):
    print(
        colored(
            "Please manually backup and then delete the following dirs before performing the upgrade operation",
            "red"))
Example #27
0
from django.shortcuts import render
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')
Example #28
0
limitations under the License.

"""

# -*- coding: utf-8 -*-

import os
from django.shortcuts import render
from django.http import JsonResponse, HttpResponse
from katana.native.settings.settings import Settings
from katana.utils.navigator_util import Navigator
from katana.utils.json_utils import read_json_data
import ast
import json

nav_obj = Navigator()
REF_FILE = os.path.join(
    nav_obj.get_katana_dir(),
    "katana.native",
    "assembler",
    "static",
    "assembler",
    "base_templates",
    "empty.xml",
)
config_json_path = os.path.join(nav_obj.get_katana_dir(), "config.json")

controls = Settings()


def index(request):
Example #29
0
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
Example #30
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import json
import os
import subprocess
import xmltodict
from django.http import JsonResponse
from django.shortcuts import render
from django.views import View
from katana.wapps.assembler.assembler_utils.repository_details import KwRepositoryDetails
from katana.wapps.assembler.assembler_utils.verify_file_contents import VerifyFileContents
from katana.utils.directory_traversal_utils import delete_dir
from katana.utils.git_utils import get_repository_name, check_url_is_a_valid_repo
from katana.utils.navigator_util import Navigator
nav_obj = Navigator()
REF_FILE = os.path.join(nav_obj.get_katana_dir(), "wapps", "assembler",
                        "static", "assembler", "base_templates", "empty.xml")


class AssemblerView(View):
    def get(self, request):
        return render(request, 'assembler/assembler.html')


class ConfigurationFileOps(View):
    def post(self, request):
        template = request.POST.get('filepath')
        filename = "Untitled"
        final_data = {}

        if template == "false":