Ejemplo n.º 1
0
    def create(self, payload_file, template_file, special_char,
               payload_placeholder, rate, outputname, subs1, string1,
               compilers, option1_gcc, option2_gcc, option1_gplusplus,
               option2_gplusplus, value1_gcc, value2_gcc, value1_gplusplus,
               value2_gplusplus, hexed_filename):

        ops1_gcc = []
        ops2_gcc = []
        ops1_gplusplus = []
        ops2_gplusplus = []
        ops1_gcc.extend([option1_gcc, value1_gcc])
        ops1_gplusplus.extend([option1_gplusplus, value1_gplusplus])
        ops2_gcc.extend([option2_gcc, value2_gcc])
        ops2_gplusplus.extend([option2_gplusplus, value2_gplusplus])

        config_filename = hexed_filename + ".conf.json"

        path = os.path.join(app.config['UPLOAD_FOLDER'], hexed_filename,
                            "config", config_filename)

        self.conf.setTemplatePath(template_file)
        self.conf.setPayloadPath(payload_file)
        self.conf.setSpecialChar(special_char)
        self.conf.setPlaceholderPayload(payload_placeholder)

        rate = float(rate)
        self.conf.setFreq(rate)
        self.conf.setOut(outputname)
        for subs, string in zip(subs1, string1):
            self.conf.addToSub((subs, string))
        comps = []
        for compiler in compilers:
            comp = Comp()
            comp.setName(compiler)
            comp.setPath("edit")
            if compiler == "gcc":
                self.tmpOpt1.append(ops1_gcc)
                self.tmpOpt2.append(ops2_gcc)
            elif compiler == "g++":
                self.tmpOpt1 = []
                self.tmpOpt2 = []
                self.tmpOpt1.append(ops1_gplusplus)
                self.tmpOpt2.append(ops2_gplusplus)

            for t in self.tmpOpt1:
                comp.addOpt1(t)
            for t in self.tmpOpt2:
                comp.addOpt2(t)
            comps.append(comp)

        self.tmpOpt1 = []
        self.tmpOpt2 = []
        for comp in comps:
            self.listOfComp.append(comp)

        with open(path, "w") as f:
            tmp = str(self.conf)
            tmp = tmp.replace("\'", "\"")
            f.write(tmp)
        return config_filename
Ejemplo n.º 2
0
    def updateComp(self, top, e, list, index):
        comp = Comp()
        if len(e[0].get()) != 0 and len(e[1].get()) != 0:
            from gui import Gui
            comp.setName(e[0].get())
            comp.setPath(e[1].get())
            
            for t in self.tmpOpt1:
                comp.addOpt1(t)
            for t in self.tmpOpt2:
                comp.addOpt2(t)

            self.tmpOpt1 = []
            self.tmpOpt2 = []

            self.listOfComp[index] = comp
            Gui.remFromList(list, index)        
            Gui.addElToList(list, str(comp), index)
            Gui.destroyTop(top)
Ejemplo n.º 3
0
    def checkComp(self, top, e, list):
        from gui import Gui
        comp = Comp()
        if len(e[0].get()) != 0 and len(e[1].get()) != 0:
            comp.setName(e[0].get())
            comp.setPath(e[1].get())

            for t in self.tmpOpt1:
                comp.addOpt1(t)
            for t in self.tmpOpt2:
                comp.addOpt2(t)

            self.tmpOpt1 = []
            self.tmpOpt2 = []   

            self.listOfComp.append(comp)        
            Gui.addElToList(list, str(comp))
            Gui.destroyTop(top)
        else:
            Gui.alertErr("Error", "Fill obligatory fields", top)