Beispiel #1
0
 def print_msg( self, msg ):
     now = strftime( self.now(), "%Y/%m/%d %H:%M:%S" )
     prefix = 'cylc (' + self.mode + ' - ' + now + '): '
     if self.priority == 'NORMAL':
         print prefix + msg
     else:
         print >> sys.stderr, prefix + self.priority + ' ' + msg
Beispiel #2
0
 def print_msg(self, msg):
     if self.utc:
         dt = datetime.utcnow()
     else:
         dt = datetime.now()
     now = strftime(dt, "%Y/%m/%d %H:%M:%S")
     prefix = 'cylc (' + self.mode + ' - ' + now + '): '
     if self.priority == 'NORMAL':
         print prefix + msg
     else:
         print >> sys.stderr, prefix + self.priority + ' ' + msg
Beispiel #3
0
    def update(self):
        try:
            [glbl, states, fam_states] = self.god.get_state_summary()
        except:
            gobject.idle_add( self.connection_lost )
            return False

        # always update global info
        self.global_summary = glbl

        if glbl['stopping']:
            self.status = 'stopping'

        elif glbl['paused']:
            self.status = 'held'

        elif glbl['will_pause_at']:
            self.status = 'hold at ' + glbl[ 'will_pause_at' ]

        elif glbl['will_stop_at']:
            self.status = 'running to ' + glbl[ 'will_stop_at' ]

        else:
            self.status = 'running'

        self.info_bar.set_status( self.status )

        self.mode = glbl[ 'run_mode' ] 

        dt = glbl[ 'last_updated' ]
        self.dt = strftime( dt, " %Y/%m/%d %H:%M:%S" )

        # only update states if a change occurred
        if compare_dict_of_dict( states, self.state_summary ):
            #print "STATE UNCHANGED"
            # only update if state changed
            return False
        else:
            #print "STATE CHANGED"
            self.state_summary = states
            self.fam_state_summary = fam_states
            return True
Beispiel #4
0
    def get_state_summary( self ):
        # derived classes can call this method and then
        # add more information to the summary if necessary.

        n_total = self.outputs.count()
        n_satisfied = self.outputs.count_completed()

        summary = {}
        summary[ 'name' ] = self.name
        summary[ 'label' ] = self.tag
        summary[ 'state' ] = self.state.get_status()
        summary[ 'n_total_outputs' ] = n_total
        summary[ 'n_completed_outputs' ] = n_satisfied
        summary[ 'spawned' ] = self.state.has_spawned()
        summary[ 'latest_message' ] = self.latest_message
        summary[ 'latest_message_priority' ] = self.latest_message_priority

        if self.submitted_time:
            summary[ 'submitted_time' ] = strftime( self.submitted_time, "%H:%M:%S" )
        else:
            summary[ 'submitted_time' ] = '*'

        if self.started_time:
            summary[ 'started_time' ] =  strftime( self.started_time, "%H:%M:%S" )
        else:
            summary[ 'started_time' ] =  '*'

        if self.succeeded_time:
            summary[ 'succeeded_time' ] =  strftime( self.succeeded_time, "%H:%M:%S" )
        else:
            summary[ 'succeeded_time' ] =  '*'

        # str(timedelta) => "1 day, 23:59:55.903937" (for example)
        # to strip off fraction of seconds:
        # timedelta = re.sub( '\.\d*$', '', timedelta )

        # TO DO: the following section could probably be streamlined a bit
        if self.__class__.mean_total_elapsed_time:
            met = self.__class__.mean_total_elapsed_time
            summary[ 'mean total elapsed time' ] =  re.sub( '\.\d*$', '', str(met) )
            if self.started_time:
                if not self.succeeded_time:
                    # started but not succeeded yet, compute ETC
                    current_time = task.clock.get_datetime()
                    run_time = current_time - self.started_time
                    self.to_go = met - run_time
                    self.etc = current_time + self.to_go
                    summary[ 'Tetc' ] = strftime( self.etc, "%H:%M:%S" ) + '(' + re.sub( '\.\d*$', '', displaytd(self.to_go) ) + ')'
                elif self.etc:
                    # the first time a task finishes self.etc is not defined
                    # task succeeded; leave final prediction
                    summary[ 'Tetc' ] = strftime( self.etc, "%H:%M:%S" ) + '(' + re.sub( '\.\d*$', '', displaytd(self.to_go) ) + ')'
                else:
                    summary[ 'Tetc' ] = '*'
            else:
                # not started yet
                summary[ 'Tetc' ] = '*'
        else:
            # first instance: no mean time computed yet
            summary[ 'mean total elapsed time' ] =  '*'
            summary[ 'Tetc' ] = '*'

        summary[ 'logfiles' ] = self.logfiles.get_paths()

        return summary
Beispiel #5
0
 def _init_by_datetime(self, dtvalue):
     return strftime(dtvalue, "%Y%m%d%H%M%S")
Beispiel #6
0
 def _str_from_datetime(self, dt):
     return strftime(dt, "%Y%m%d%H%M%S")
Beispiel #7
0
    def update(self):
        #print "Attempting Update"

        if self.god is None:
            gobject.idle_add( self.connection_lost )
            return False

        try:
            new_err_content, new_err_size = self.log.get_err_content(
                prev_size=self.err_log_size,
                max_lines=self._err_num_log_lines)
        except (AttributeError, Pyro.errors.NamingError):
            # TODO: post-backwards compatibility concerns, remove this handling.
            new_err_content = ""
            new_err_size = self.err_log_size
        except Pyro.errors.ProtocolError:
            gobject.idle_add( self.connection_lost )
            return False

        err_log_changed = (new_err_size != self.err_log_size)
        if err_log_changed:
            self.err_log_lines += new_err_content.splitlines()
            self.err_log_lines = self.err_log_lines[-self._err_num_log_lines:]
            self.err_log_size = new_err_size

        update_summaries = False
        try:
            summary_update_time = self.god.get_summary_update_time()
            if (summary_update_time is None or
                    self._summary_update_time is None or
                    summary_update_time != self._summary_update_time):
                self._summary_update_time = summary_update_time
                update_summaries = True
        except AttributeError as e:
            # TODO: post-backwards compatibility concerns, remove this handling.
            # Force an update for daemons using the old API.
            update_summaries = True
        except (Pyro.errors.ProtocolError, Pyro.errors.NamingError):
            gobject.idle_add( self.connection_lost )
            return False

        if update_summaries:
            try:
                [glbl, states, fam_states] = self.god.get_state_summary()
                self.task_list = self.god.get_task_name_list()
            except (Pyro.errors.ProtocolError, Pyro.errors.NamingError):
                gobject.idle_add( self.connection_lost )
                return False

            if not glbl:
                self.task_list = []
                return False

            self.task_list.sort()

            if glbl['stopping']:
                self.status = 'stopping'

            elif glbl['paused']:
                self.status = 'held'

            elif glbl['will_pause_at']:
                self.status = 'hold at ' + glbl[ 'will_pause_at' ]

            elif glbl['will_stop_at']:
                self.status = 'running to ' + glbl[ 'will_stop_at' ]

            else:
                self.status = 'running'

            self.mode = glbl['run_mode']

            if self.cfg.use_defn_order and 'namespace definition order' in glbl: 
                # (protect for compat with old suite daemons)
                nsdo = glbl['namespace definition order']
                if self.ns_defn_order != nsdo:
                    self.ns_defn_order = nsdo
                    self.dict_ns_defn_order = dict( zip( nsdo, range(0,len(nsdo))))

            dt = glbl[ 'last_updated' ]
            self.dt = strftime( dt, " %Y/%m/%d %H:%M:%S" )
            self.dt_date = dt

            self.global_summary = glbl
            self.state_summary = states
            self.fam_state_summary = fam_states

        if update_summaries or err_log_changed:
            return True
        return False
Beispiel #8
0
    def update(self):
        #print "Updating"
        try:
            [glbl, states_full, fam_states_full] = self.god.get_state_summary()
        except:
            gobject.idle_add( self.connection_lost )
            return False

        # The graph layout is not stable even when (py)graphviz is  
        # presented with the same graph (may be a node ordering issue
        # due to use of dicts?). For this reason we only plot node name 
        # and color (state) and only replot when node content or states 
        # change.  The full state summary contains task timing
        # information that changes continually, so we have to disregard
        # this when checking for changes. So: just extract the critical
        # info here:
        states = {}
        for id in states_full:
            if id not in states:
                states[id] = {}
            states[id]['name' ] = states_full[id]['name' ]
            states[id]['label'] = states_full[id]['label']
            states[id]['state'] = states_full[id]['state']

        f_states = {}
        for id in fam_states_full:
            if id not in states:
                f_states[id] = {}
            f_states[id]['name' ] = fam_states_full[id]['name' ]
            f_states[id]['label'] = fam_states_full[id]['label']
            f_states[id]['state'] = fam_states_full[id]['state'] 
        # always update global info
        self.global_summary = glbl

        if glbl['stopping']:
            self.status = 'stopping'

        elif glbl['paused']:
            self.status = 'held'
       
        elif glbl['will_pause_at']:
            self.status = 'hold at ' + glbl[ 'will_pause_at' ]

        elif glbl['will_stop_at']:
            self.status = 'running to ' + glbl[ 'will_stop_at' ]

        else:
            self.status = 'running'

        self.info_bar.set_status( self.status )

        self.mode = glbl['run_mode']

        dt = glbl[ 'last_updated' ]
        self.dt = strftime( dt, " %Y/%m/%d %H:%M:%S" ) 

        # only update states if a change occurred, or action required
        if self.action_required:
            self.state_summary = states
            self.fam_state_summary = f_states
            return True
        elif self.graph_disconnect:
            return False
        elif not compare_dict_of_dict( states, self.state_summary ):
            # state changed - implicitly includes family state change.
            #print 'STATE CHANGED'
            self.state_summary = states
            self.fam_state_summary = f_states
            return True
        else:
            return False
Beispiel #9
0
 def _init_by_datetime( self, dtvalue ):
     return strftime( dtvalue, "%Y%m%d%H%M%S" )
Beispiel #10
0
 def _str_from_datetime( self, dt ): 
     return strftime( dt, "%Y%m%d%H%M%S" )
Beispiel #11
0
    def update(self):
        #print "Attempting Update"
        
        if self.god is None:
            gobject.idle_add( self.connection_lost )
            return False

        try:
            new_err_content, new_err_size = self.log.get_err_content(
                prev_size=self.err_log_size,
                max_lines=self._err_num_log_lines)
        except (AttributeError, Pyro.errors.NamingError):
            # TODO: post-backwards compatibility concerns, remove this handling.
            new_err_content = ""
            new_err_size = self.err_log_size
        except Pyro.errors.ProtocolError:
            gobject.idle_add( self.connection_lost )
            return False

        err_log_changed = (new_err_size != self.err_log_size)
        if err_log_changed:
            self.err_log_lines += new_err_content.splitlines()
            self.err_log_lines = self.err_log_lines[-self._err_num_log_lines:]
            self.err_log_size = new_err_size
        
        update_summaries = False
        try:
            summary_update_time = self.god.get_summary_update_time()
            if (summary_update_time is None or
                    self._summary_update_time is None or
                    summary_update_time != self._summary_update_time):
                self._summary_update_time = summary_update_time
                update_summaries = True
        except AttributeError as e:
            # TODO: post-backwards compatibility concerns, remove this handling.
            # Force an update for daemons using the old API.
            update_summaries = True
        except (Pyro.errors.ProtocolError, Pyro.errors.NamingError):
            gobject.idle_add( self.connection_lost )
            return False

        if update_summaries:
            try:
                [glbl, states, fam_states] = self.god.get_state_summary()
                self.task_list = self.god.get_task_name_list()
            except (Pyro.errors.ProtocolError, Pyro.errors.NamingError):
                gobject.idle_add( self.connection_lost )
                return False

            if not glbl:
                self.task_list = []
                return False

            self.task_list.sort()

            if glbl['stopping']:
                self.status = 'stopping'

            elif glbl['paused']:
                self.status = 'held'

            elif glbl['will_pause_at']:
                self.status = 'hold at ' + glbl[ 'will_pause_at' ]

            elif glbl['will_stop_at']:
                self.status = 'running to ' + glbl[ 'will_stop_at' ]

            else:
                self.status = 'running'

            self.mode = glbl['run_mode']

            dt = glbl[ 'last_updated' ]
            self.dt = strftime( dt, " %Y/%m/%d %H:%M:%S" )

            self.global_summary = glbl
            self.state_summary = states
            self.fam_state_summary = fam_states

        if update_summaries or err_log_changed:
            return True
        return False