Ejemplo n.º 1
0
 def __init__(self, name):
     super(TaskRegistrySlice, self).__init__(name, display_prefix="tasks")
     from Ganga.Utility.ColourText import Foreground, Background, Effects
     fg = Foreground()
     fx = Effects()
     bg = Background()
     self.status_colours = {
         'new': fx.normal,
         'submitted': fg.orange,
         'running': fg.green,
         'completed': fg.blue,
         'failed': fg.red
     }
     self.fx = fx
     self._proxyClass = TaskRegistrySliceProxy
Ejemplo n.º 2
0
 def __init__(self, name):
     super(JobRegistrySlice, self).__init__(name, display_prefix="jobs")
     from Ganga.Utility.ColourText import Foreground, Background, Effects
     fg = Foreground()
     fx = Effects()
     bg = Background()
     try:
         status_colours = config['jobs_status_colours']
         self.status_colours = dict([(k, eval(v)) for k, v in status_colours.iteritems()])
     except Exception as x:
         logger.warning('configuration problem with colour specification: "%s"', str(x))
         status_colours = config.options['jobs_status_colours'].default_value
         self.status_colours = dict([(k, eval(v)) for k, v in status_colours.iteritems()])
     self.fx = fx
     self._proxyClass = JobRegistrySliceProxy
Ejemplo n.º 3
0
 def __init__(self, name):
     super(TransientRegistrySlice, self).__init__(
         name, display_prefix="box")
     from Ganga.Utility.ColourText import Foreground, Background, Effects
     fg = Foreground()
     fx = Effects()
     bg = Background()
     self.fx = fx
     self.name = 'box'  # needed to ensure that select works properly
     self.status_colours = {'default': fx.normal,
                            'JobTemplate': fg.orange,
                            'Task': fg.green,
                            'Job': fg.blue}
     self._display_columns_functions["id"] = lambda obj: obj.id
     self._display_columns_functions["type"] = lambda obj: obj._name
     self._display_columns_functions["name"] = lambda obj: obj.name
     self._proxyClass = TransientRegistrySliceProxy
Ejemplo n.º 4
0
 def __init__(self, name):
     super(BoxRegistrySlice, self).__init__(name, display_prefix="box")
     self._display_columns_functions["id"] = lambda obj: obj._getRegistry(
     ).find(obj)
     self._display_columns_functions["type"] = lambda obj: obj._name
     self._display_columns_functions["name"] = lambda obj: obj._getRegistry(
     )._getName(obj)
     from Ganga.Utility.ColourText import Foreground, Background, Effects
     fg = Foreground()
     fx = Effects()
     bg = Background()
     self.fx = fx
     self.status_colours = {
         'default': fx.normal,
         'backends': fg.orange,
         'applications': fg.green,
         'jobs': fg.blue
     }
     self._proxyClass = BoxRegistrySliceProxy
Ejemplo n.º 5
0
    def _display(self, interactive=0):
        """Prints content of the shareref metadata in a well formatted way.
        """

        if len(self.__getName()) > 0:
            from Ganga.GPIDev.Lib.File import getSharedPath
            fstring = " %48s | %20s |  %15s"
            disp_string = fstring % ("Shared directory", "Date created",
                                     "Reference count\n")
            #           print fstring % (" ", " "," ")
            disp_string += fstring % (
                "------------------------------------------------",
                "--------------------", "---------------\n")
            zero_ref = False
            unsorted = []
            all_elements = copy.deepcopy(self.__getName())
            for element in all_elements:
                full_shareddir_path = os.path.join(getSharedPath(),
                                                   os.path.basename(element))
                if os.path.isdir(full_shareddir_path):
                    unsorted.append(
                        shareref_data(
                            os.path.basename(element),
                            int(os.path.getctime(full_shareddir_path)),
                            self.__getName()[element]))
                else:
                    unsorted.append(
                        shareref_data(os.path.basename(element),
                                      "Directory not found",
                                      self.__getName()[element]))
            decorated = sorted(
                (name.date, i, name) for i, name in enumerate(unsorted))
            sorted_refs = [name for date, i, name in decorated]
            for line in sorted_refs:
                if isinstance(line.date, int):
                    tmp_string = fstring % (
                        os.path.basename(line.name),
                        time.strftime("%d %b %Y %H:%M:%S",
                                      time.localtime(line.date)), line.counter)
                else:
                    tmp_string = fstring % (os.path.basename(
                        line.name), line.date, line.counter)

                if (line.counter == 0) or (isinstance(line.date, str)):
                    from Ganga.Utility.ColourText import ANSIMarkup, NoMarkup, Foreground, Background, Effects
                    fg = Foreground()
                    fg = Background()
                    fx = Effects()
                    if interactive:
                        m = ANSIMarkup()
                    else:
                        m = NoMarkup()
                    disp_string += fg.red + tmp_string + fx.normal + '\n'
                    #disp_string += m(tmp_string,code=fg.red)
                    if (line.counter == 0):
                        zero_ref = True
                else:
                    disp_string += tmp_string + '\n'

            disp_string += "\nThe shared directory repository is rooted at " + \
                getSharedPath() + "\n"
            if zero_ref:
                disp_string += "\nShared directories with a zero reference count will be removed when Ganga exits.\n"
        else:
            disp_string = "No objects stored in the shared directory."

        return disp_string