Ejemplo n.º 1
0
    def WriteCodesFile(self):
        gstrs = []
        for i, code in enumerate(self.codenames):
            gstrs.append("codenames({0}) = '{1}'".format(i + 1, code))
        gstrs = '\n'.join(gstrs)

        for codename in self.codenames:
            if codename == "kittie-plotter":
                continue
            nstrs = "ncodes = {0}{1}codename = '{2}'".format(
                len(self.codenames), '\n', codename)
            nlist = ["codes", nstrs]
            glist = ["codes_list", gstrs]
            outstr = kittie_common.Namelist(nlist, glist)
            kittie_common.NMLFile("kittie-codenames",
                                  self.mainpath,
                                  outstr,
                                  codename=codename,
                                  appname=self.codesetup[codename]['appname'],
                                  launchmode=self.launchmode)
Ejemplo n.º 2
0
def WriteGroupsFile(groups, outdir, name):
    scalars = "ngroupnames = {0}{1}appname = '{2}'".format(len(groups), '\n', name)
    setup = ["setup", scalars]

    gstrs = []
    for i, group in enumerate(groups):
        gstrs.append("groupnames({0}) = {1}".format(i+1, group))
    gstrs = '\n'.join(gstrs)
    gsetup = ["helpers_list", gstrs]

    outstr = kittie_common.Namelist(setup, gsetup)
    kittie_common.NMLFile("kittie-setup", outdir, outstr)


    gdict = {'n': len(groups), 'appname': name, 'groups': []}
    for i, group in enumerate(groups):
        gdict['groups'].append(group)
    outstr = yaml.dump(gdict, default_flow_style=False)
    outpath = os.path.join(outdir, ".kittie-setup.yaml")
    with open(outpath, "w") as outfile:
        outfile.write(outstr)
Ejemplo n.º 3
0
    def WriteCodesFile(self):
        gstrs = []
        for i, code in enumerate(self.codenames):
            gstrs.append("codenames({0}) = '{1}'".format(i+1, code))
        gstrs = '\n'.join(gstrs)

        for i, codename in enumerate(self.codenames):
            if codename == "kittie-plotter":
                continue
            nstrs = "ncodes = {0}{1}codename = '{2}'".format(len(self.codenames), '\n', codename)
            nlist = ["codes", nstrs]
            glist = ["codes_list", gstrs]
            outstr = kittie_common.Namelist(nlist, glist)
            kittie_common.NMLFile("kittie-codenames", self.mainpath, outstr, codename=codename, appname=i, launchmode=self.launchmode)

            if self.launchmode == "default":
                outdir = os.path.join(self.mainpath, codename)
            else:
                outdir = self.mainpath
            outdict = {'n': len(self.codenames), 'codename': str(codename), 'codes': list(self.codenames)}
            outstr = yaml.dump(outdict, default_flow_style=False)
            outname = os.path.join(outdir, ".kittie-codenames-{0}.yaml".format(i))
            with open(outname, 'w') as outfile:
                outfile.write(outstr)
Ejemplo n.º 4
0
    def WriteGroupsFile(self):
        for i, codename in enumerate(self.codenames):
            if codename == "kittie-plotter":
                continue

            gstrs = []
            pstrs = []
            params = []
            values = []

            keys = self.codesetup[codename]['groups'].keys()
            names = ["ionames", "nnames = {0}".format(len(keys))]
            for i, key in enumerate(keys):
                entry = self.codesetup[codename]['groups'][key]
                gstr = "names({0}) = '{1}'".format(i + 1, key)
                nparams = 0

                if "engine" in entry:
                    engine = entry["engine"]
                    if type(engine) is str:
                        gstr = "{0}{1}engines({2}) = '{3}'".format(
                            gstr, '\n', i + 1, engine)
                    elif type(engine) is OrderedDict:
                        gstr = "{0}{1}engines({2}) = '{3}'".format(
                            gstr, '\n', i + 1, engine['name'])
                        enginekeys = list(engine.keys())
                        for j in range(len(enginekeys)):
                            if enginekeys[j] == "name":
                                del enginekeys[j]
                                break
                        nparams = len(enginekeys)
                        gstr = "{0}{1}nparams({2}) = {3}".format(
                            gstr, '\n', i + 1, nparams)

                for j in range(nparams):
                    key = enginekeys[j]
                    params += [
                        "params({0}, {1}) = '{2}'".format(i + 1, j + 1, key)
                    ]
                    if (engine[key] == False):
                        values += [
                            "values({0}, {1}) = 'Off'".format(i + 1, j + 1)
                        ]
                    elif (engine[key] == True):
                        values += [
                            "values({0}, {1}) = 'On'".format(i + 1, j + 1)
                        ]
                    else:
                        values += [
                            "values({0}, {1}) = '{2}'".format(
                                i + 1, j + 1, engine[key])
                        ]

                if "plot" in entry:
                    gstr = "{0}{1}nplots({2}) = {3}".format(
                        gstr, "\n", i + 1, len(entry['plot']))
                    for j, name in enumerate(entry['plot']):
                        pstrs += [
                            "plots({0}, {1}) = '{2}'".format(
                                i + 1, j + 1, name)
                        ]

                gstrs += [gstr]

            names_list = ["ionames_list", '\n'.join(gstrs)]
            plots_list = ["plots_list", '\n'.join(pstrs)]
            params_list = ["params_list", '\n'.join(params + values)]
            outstr = kittie_common.Namelist(names, names_list, plots_list,
                                            params_list)
            kittie_common.NMLFile("kittie-groups",
                                  self.mainpath,
                                  outstr,
                                  codename=codename,
                                  appname=self.codesetup[codename]['appname'],
                                  launchmode=self.launchmode)
Ejemplo n.º 5
0
    def WriteGroupsFile(self):

        for k, codename in enumerate(self.codenames):
            if codename == "kittie-plotter":
                continue

            gstrs = []
            pstrs = []
            params = []
            values = []

            keys = self.codesetup[codename]['groups'].keys()
            names = ["ionames", "nnames = {0}".format(len(keys)) + "\n" + "timingdir = '{0}'".format(self.timingdir)]

            for i, key in enumerate(keys):
                entry = self.codesetup[codename]['groups'][key]
                gstr = "names({0}) = '{1}'".format(i+1, key)
                nparams = 0

                if entry['AddStep']:
                    gstr = "{0}{1}kittie_addstep({2}) = T".format(gstr, '\n', i+1)

                if (self.keywords['timed'] in entry) and (entry[self.keywords['timed']]):
                    gstr = "{0}{1}kittie_timed({2}) = T".format(gstr, '\n', i+1)
                else:
                    gstr = "{0}{1}kittie_timed({2}) = F".format(gstr, '\n', i+1)


                if 'filename' in entry:
                    gstr = "{0}{1}kittie_filenames({2}) = '{3}'".format(gstr, '\n', i+1, entry['filename'])


                if 'engine' in entry:
                    engine = entry['engine']
                    if type(engine) is str:
                        gstr = "{0}{1}engines({2}) = '{3}'".format(gstr, '\n', i+1, engine)
                    elif type(engine) is OrderedDict:
                        gstr = "{0}{1}engines({2}) = '{3}'".format(gstr, '\n', i+1, engine['name'])
                        enginekeys = list(engine.keys())
                        for j in range(len(enginekeys)):
                            if enginekeys[j] == "name":
                                del enginekeys[j]
                                break
                        nparams = len(enginekeys)
                        gstr = "{0}{1}nparams({2}) = {3}".format(gstr, '\n', i+1, nparams)

                for j in range(nparams):
                    key = enginekeys[j]
                    params += ["params({0}, {1}) = '{2}'".format(i+1, j+1, key)]
                    if (engine[key] == False):
                        values += ["values({0}, {1}) = 'Off'".format(i+1, j+1)]
                    elif (engine[key] == True):
                        values += ["values({0}, {1}) = 'On'".format(i+1, j+1)]
                    else:
                        values += ["values({0}, {1}) = '{2}'".format(i+1, j+1, engine[key])]

                if "plot" in entry:
                    gstr = "{0}{1}nplots({2}) = {3}".format(gstr, "\n", i+1, len(entry['plot']))
                    for j, name in enumerate(entry['plot']):
                        pstrs += ["plots({0}, {1}) = '{2}'".format(i+1, j+1, name)]

                gstrs += [gstr]

            names_list = ["ionames_list", '\n'.join(gstrs)]
            plots_list = ["plots_list", '\n'.join(pstrs)]
            params_list = ["params_list", '\n'.join(params+values)]
            outstr = kittie_common.Namelist(names, names_list, plots_list, params_list)
            kittie_common.NMLFile("kittie-groups", self.mainpath, outstr, codename=codename, appname=k, launchmode=self.launchmode)

            if self.launchmode == "default":
                outdir = os.path.join(self.mainpath, codename)
            else:
                outdir = self.mainpath
            self.codesetup[codename]['groups'][".timingdir"] = self.timingdir
            outstr = yaml.dump(self.codesetup[codename]['groups'], default_flow_style=False, Dumper=self.OrderedDumper)
            outname = os.path.join(outdir, ".kittie-groups-{0}.yaml".format(k))
            with open(outname, "w") as outfile:
                outfile.write(outstr)

        if "monitors" in self.codenames:
            codename = "monitors"
            if self.launchmode == "default":
                outdir = os.path.join(self.mainpath, codename)
            else:
                outdir = self.mainpath

            outname = os.path.join(outdir, "groups.yaml")
            outstr = yaml.dump(self.monitors['groups'], default_flow_style=False, Dumper=self.OrderedDumper)
            with open(outname, "w") as outfile:
                outfile.write(outstr)

            outname = os.path.join(outdir, "monitor-config.yaml")
            outstr = yaml.dump(self.monitors['monitors'], default_flow_style=False, Dumper=self.OrderedDumper)
            with open(outname, "w") as outfile:
                outfile.write(outstr)