Exemple #1
0
    def run(self, macro_list):
        # list the environment for the current door
        if len(macro_list) == 0:
            # list All the environment for the current door
            out = List(['Name', 'Value', 'Type'])
            env = self.getAllDoorEnv()
            names_list = list(env.keys())
            names_list.sort(key=str.lower)
            for k in names_list:
                str_val = self.reprValue(env[k])
                type_name = type(env[k]).__name__
                out.appendRow([k, str_val, type_name])
        # list the environment for the current door for the given macros
        else:
            out = List(['Macro', 'Name', 'Value', 'Type'])
            for macro in macro_list:
                env = self.getEnv(key=None, macro_name=macro.name)
                names_list = list(env.keys())
                names_list.sort(key=str.lower)
                for k in names_list:
                    str_val = self.reprValue(env[k])
                    type_name = type(env[k]).__name__
                    out.appendRow([macro.name, k, str_val, type_name])

        for line in out.genOutput():
            self.output(line)
Exemple #2
0
    def run(self):
        try:
            general_hooks = self.getEnv("_GeneralHooks")
        except UnknownEnv:
            self.output("No general hooks")
            return

        out = List(['Hook place', 'Hook(s)'])
        default_dict = {}
        for hook in general_hooks:
            name = hook[0]
            places = hook[1]
            for place in places:
                if place not in list(default_dict.keys()):
                    default_dict[place] = []
                default_dict[place].append(name)
        for pos in list(default_dict.keys()):
            pos_set = 0
            for hook in default_dict[pos]:
                if pos_set:
                    out.appendRow(["", hook])
                else:
                    out.appendRow([pos, hook])
                pos_set = 1
        for line in out.genOutput():
            self.output(line)
    def run(self, filter='.*', show_current=False):
        self.load_from_env()
        if len(self.bm) == 0:
            self.output('No bookmarks defined')
            return
        filter = '.*' if filter is None else filter
        bm_sel = {k: self.bm[k] for k in self.bm if re.match(filter, k)}
        ncols = max([len(ml) for ml in bm_sel.values()])
        if show_current:
            cols = ['name'] + ncols * ['Motor', 'current', 'target']
        else:
            cols = ['name'] + ncols * ['Motor', 'target']
        align = Alignment.Right * len(cols)
        out = List(cols, text_alignment=align)

        for bm_name, motorlist in bm_sel.items():
            row = [bm_name]
            for m in motorlist:
                row.append(m['name'])
                if show_current:
                    mot = self.getMoveable(m['name'])
                    row.append(mot.getPosition())
                row.append(m['position'])
            out.appendRow(row)
        for line in out.genOutput():
            self.output(line)
        self.output('\nmove command is ' + self.mv_cmd)
Exemple #4
0
    def run(self, filter):
        objs = self.objs(filter)
        nb = len(objs)
        if nb is 0:
            if self.subtype is Macro.All:
                if isinstance(self.type, (str, unicode)):
                    t = self.type.lower()
                else:
                    t = ", ".join(self.type).lower()
            else:
                t = self.subtype.lower()
            self.output('No %ss defined' % t)
            return

        cols = self.get_column_names()
        out = List(cols, text_alignment=self.align,
                   max_col_width=self.width)
        objs.sort()
        for obj in objs:
            try:
                out.appendRow(self.obj2Row(obj))
            except:
                pass
        for line in out.genOutput():
            self.output(line)
def printProfile(mcr, server):
    out = List(["Profile (MntGrp): %s"
                % str(getString(mcr, "MntGrp")), ""],
               text_alignment=(Right, Right),
               max_col_width=(-1, 60),)
    printConfList(mcr, "Timer", True, "Timer(s)", out=out)
    printList(mcr, "SelectedComponents", False, "Detector Components",
              True, out=out)
    printList(mcr, "SelectedDataSources", False, "", True, out=out)
    mergeLastTwoRows(out)
    printList(mcr, "PreselectedComponents", False, "Descriptive Components",
              True, out=out)
    if mcr.selector_version <= 2:
        printConfList(mcr, "InitDataSources", True, "", out=out)
    else:
        printList(mcr, "PreselectedDataSources", False, "", True, out=out)
    mergeLastTwoRows(out)
    printList(mcr, "MandatoryComponents", False, "Mandatory Components",
              True, out=out)
    printDict(mcr, "UserData", True, "User Data", out=out)
    printString(mcr, "AppendEntry", out=out)
    out.append(["SelectorServer", str(server)])
    printString(mcr, "ConfigDevice", "ConfigServer", out=out)
    printString(mcr, "WriterDevice", "WriterServer", out=out)
    return out
Exemple #6
0
    def run(self, filter):
        objs = self.objs(filter)
        nb = len(objs)
        if nb == 0:
            if self.subtype is Macro.All:
                if isinstance(self.type, str):
                    t = self.type.lower()
                else:
                    t = ", ".join(self.type).lower()
            else:
                t = self.subtype.lower()
            self.output('No %ss defined' % t)
            return

        cols = self.get_column_names()
        out = List(cols, text_alignment=self.align, max_col_width=self.width)
        objs.sort()
        for obj in objs:
            try:
                out.appendRow(self.obj2Row(obj))
            except:
                pass

        for line in out.genOutput():
            self.output(line)

        if (self.show_overwritten_msg is True
                and hasattr(self, "overwritten_msg")):
            self.warning(self.overwritten_msg)
Exemple #7
0
    def run(self):
        vo = self.getViewOptions()
        out = List(['View option', 'Value'])
        for key, value in list(vo.items()):
            out.appendRow([key, str(value)])

        for line in out.genOutput():
            self.output(line)
Exemple #8
0
    def run(self):
        env = self.getGlobalEnv()
        out = List(['Name', 'Value', 'Type'])
        for k, v in env.items():
            str_v = reprValue(v)
            type_v = type(v).__name__
            out.appendRow([str(k), str_v, type_v])

        for line in out.genOutput():
            self.output(line)
Exemple #9
0
 def run(self):
     try:
         snapshot_items = self.getEnv("PreScanSnapshot")
     except UnknownEnv:
         self.output("No pre-scan snapshot")
         return
     out = List(['Snap item', 'Snap item full name'])
     for full_name, label in snapshot_items:
         out.appendRow([label, full_name])
     for line in out.genOutput():
         self.output(line)
Exemple #10
0
def printTable(mcr, lst):
    """ Print adjusted list """
    headers = orderedKeys(lst)
    out = List(headers,
               text_alignment=tuple([Right] * len(headers)),
               max_col_width=tuple([-1] * len(headers)),
               )
    for dct in lst:
        row = [(dct[key] if key in dct else 'None') for key in headers]
        out.appendRow(row)
    for line in out.genOutput():
        mcr.output(line)
Exemple #11
0
    def run(self, filter):
        # TODO: passing a list causes TypeError: unhashable type: 'list'
        # uncomment it when bug-473 is fixed:
        # https://sourceforge.net/p/sardana/tickets/473/
        filter = filter[0]
        cols = self.get_column_names()
        out = List(cols, text_alignment=self.align, max_col_width=self.width)

        for m in self.getMacros(filter):
            if m.name.startswith("_"):
                continue
            out.appendRow([m.name, m.module_name, m.get_brief_description()])

        for line in out.genOutput():
            self.output(line)
Exemple #12
0
def get_meas_conf(self, detail, meas_grp):
    """Print measurement group configuration in form of a table.

    Examples of usage:

    >>> get_meas_conf  # get <ActiveMntGrp> simple configuration
    >>> get_meas_conf all  # get <ActiveMntGrp> complete configuration
    >>> get_meas_conf simple mntgrp01  # get mntgrp01 simple configuration
    >>> get_meas_conf all mntgrp01  # get mntgrp01 complete configuration
    """
    if detail is None or detail == "simple":
        parameters = simple_parameters
    elif detail == "all":
        parameters = parameter_map.keys()
    else:
        raise ValueError("wrong detail level: {}".format(detail))
    if meas_grp is None:
        meas_grp = self.getEnv("ActiveMntGrp")
        self.print("ActiveMntGrp = {}".format(meas_grp))
        meas_grp = self.getMeasurementGroup(meas_grp)
    col_headers = ["Channel"]
    width = [-1]
    align = [Alignment.Right]
    cols = []
    for parameter in parameters:
        parameter, sanitizer, _ = parameter_map[parameter]
        getter = getattr(meas_grp, "get" + parameter)
        ret = getter()
        if len(cols) == 0:
            # add channel names as first column
            cols.append(ret.keys())
        values = ret.values()
        if sanitizer is not None:
            values = sanitizer(values)
        cols.append(values)
        col_headers.append(parameter)
        width.append(-1)
        align.append(Alignment.Right)
    out = List(col_headers, text_alignment=align, max_col_width=width)
    for row in zip(*cols):
        out.appendRow(row)
    for line in out.genOutput():
        self.output(line)
Exemple #13
0
    def run(self, filter):
        # TODO: passing a list causes TypeError: unhashable type: 'list'
        # uncomment it when bug-473 is fixed:
        # https://sourceforge.net/p/sardana/tickets/473/
        filter = filter[0]
        cols = self.get_column_names()
        out = List(cols, text_alignment=self.align, max_col_width=self.width)

        for m in self.getMacros(filter):
            if m.name.startswith("_"):
                continue
            desc_length = self.getViewOption(ViewOption.DescriptionLength)
            description = m.get_brief_description(max_chars=desc_length)
            if len(description) < 61:
                out.appendRow([m.name, m.module_name, description])
            else:
                out.appendRow([m.name, m.module_name, description[0:60]])
                for i in range(1, len(description) / 60 + 1):
                    out.appendRow(["", "", description[60 * i:60 * (i + 1)]])

        for line in out.genOutput():
            self.output(line)