def sleep_task(self):
     task_id = self.currentrow[0]
     status = self.currentrow[5]
     if status in ('RUNNING', 'CONTINUING'):
         bibsched_set_status(task_id, 'ABOUT TO SLEEP', status)
         self.update_rows()
         self.repaint()
         self.display_in_footer("SLEEP signal sent to task #%s" % task_id)
     else:
         self.display_in_footer("Cannot put to sleep non-running processes")
 def sleep_task(self):
     task_id = self.currentrow[0]
     status = self.currentrow[5]
     if status in ('RUNNING', 'CONTINUING'):
         bibsched_set_status(task_id, 'ABOUT TO SLEEP', status)
         self.update_rows()
         self.repaint()
         self.display_in_footer("SLEEP signal sent to task #%s" % task_id)
     else:
         self.display_in_footer("Cannot put to sleep non-running processes")
 def init_task(self):
     task_id = self.currentrow[0]
     status = self.currentrow[5]
     if status not in ('RUNNING', 'CONTINUING', 'SLEEPING'):
         bibsched_set_status(task_id, "WAITING")
         bibsched_set_progress(task_id, "")
         bibsched_set_host(task_id, "")
         self.update_rows()
         self.repaint()
         self.display_in_footer("process initialised")
     else:
         self.display_in_footer("Cannot initialise running processes")
 def init_task(self):
     task_id = self.currentrow[0]
     status = self.currentrow[5]
     if status not in ('RUNNING', 'CONTINUING', 'SLEEPING'):
         bibsched_set_status(task_id, "WAITING")
         bibsched_set_progress(task_id, "")
         bibsched_set_host(task_id, "")
         self.update_rows()
         self.repaint()
         self.display_in_footer("process initialised")
     else:
         self.display_in_footer("Cannot initialise running processes")
 def acknowledge_task(self):
     task_id = self.currentrow[0]
     task_name = self.currentrow[1]
     status = self.currentrow[5]
     if status in ('ERROR', 'DONE WITH ERRORS', 'ERRORS REPORTED'):
         argv = task_get_options(task_id, task_name)
         sleeptime = get_sleeptime(argv)
         if not sleeptime or self._display_YN_box("WARNING! This is a periodic task.\n\nAre you sure you want to acknowledge the %s process %s?" % (task_name, task_id)):
             bibsched_set_status(task_id, 'ACK ' + status, status)
             self.update_rows()
             self.repaint()
             self.display_in_footer("Acknowledged error")
 def delete_task(self):
     task_id = self.currentrow[0]
     status = self.currentrow[5]
     if status not in ('RUNNING', 'CONTINUING', 'SLEEPING', 'SCHEDULED',
                       'ABOUT TO STOP', 'ABOUT TO SLEEP'):
         msg = 'Are you sure you want to delete this task?'
         if self._display_YN_box(msg):
             bibsched_set_status(task_id, "%s_DELETED" % status, status)
             self.display_in_footer("process deleted")
             self.update_rows()
             self.repaint()
     else:
         self.display_in_footer("Cannot delete running processes")
 def delete_task(self):
     task_id = self.currentrow[0]
     status = self.currentrow[5]
     if status not in ('RUNNING', 'CONTINUING', 'SLEEPING', 'SCHEDULED',
                       'ABOUT TO STOP', 'ABOUT TO SLEEP'):
         msg = 'Are you sure you want to delete this task?'
         if self._display_YN_box(msg):
             bibsched_set_status(task_id, "%s_DELETED" % status, status)
             self.display_in_footer("process deleted")
             self.update_rows()
             self.repaint()
     else:
         self.display_in_footer("Cannot delete running processes")
 def kill_task(self):
     task_id = self.currentrow[0]
     process = self.currentrow[1]
     status = self.currentrow[5]
     if status in ('RUNNING', 'CONTINUING', 'ABOUT TO STOP', 'ABOUT TO SLEEP', 'SLEEPING'):
         if self._display_YN_box("Are you sure you want to kill the %s process %s?" % (process, task_id)):
             bibsched_send_signal(task_id, signal.SIGKILL)
             bibsched_set_status(task_id, 'KILLED')
             self.update_rows()
             self.repaint()
             self.display_in_footer("KILL signal sent to task #%s" % task_id)
     else:
         self.display_in_footer("Cannot kill non-running processes")
 def acknowledge_task(self):
     task_id = self.currentrow[0]
     task_name = self.currentrow[1]
     status = self.currentrow[5]
     if status in ('ERROR', 'DONE WITH ERRORS', 'ERRORS REPORTED'):
         argv = task_get_options(task_id, task_name)
         sleeptime = get_sleeptime(argv)
         if not sleeptime or self._display_YN_box(
                 "WARNING! This is a periodic task.\n\nAre you sure you want to acknowledge the %s process %s?"
                 % (task_name, task_id)):
             bibsched_set_status(task_id, 'ACK ' + status, status)
             self.update_rows()
             self.repaint()
             self.display_in_footer("Acknowledged error")
 def kill_task(self):
     task_id = self.currentrow[0]
     process = self.currentrow[1]
     status = self.currentrow[5]
     if status in ('RUNNING', 'CONTINUING', 'ABOUT TO STOP',
                   'ABOUT TO SLEEP', 'SLEEPING'):
         if self._display_YN_box(
                 "Are you sure you want to kill the %s process %s?" %
             (process, task_id)):
             bibsched_send_signal(task_id, signal.SIGKILL)
             bibsched_set_status(task_id, 'KILLED')
             self.update_rows()
             self.repaint()
             self.display_in_footer("KILL signal sent to task #%s" %
                                    task_id)
     else:
         self.display_in_footer("Cannot kill non-running processes")
    def wakeup_task(self):
        if not self.currentrow:
            self.display_in_footer("no task selected")
            return

        task_id = self.currentrow[0]
        status = self.currentrow[5]
        #if self.count_processes('RUNNING') + self.count_processes('CONTINUING') >= 1:
        #self.display_in_footer("a process is already running!")
        if status == "SLEEPING":
            if not bibsched_send_signal(task_id, signal.SIGCONT):
                bibsched_set_status(task_id, "ERROR", "SLEEPING")
            self.update_rows()
            self.repaint()
            self.display_in_footer("process woken up")
        else:
            self.display_in_footer("process is not sleeping")
        self.stdscr.refresh()
    def wakeup_task(self):
        if not self.currentrow:
            self.display_in_footer("no task selected")
            return

        task_id = self.currentrow[0]
        status = self.currentrow[5]
        #if self.count_processes('RUNNING') + self.count_processes('CONTINUING') >= 1:
            #self.display_in_footer("a process is already running!")
        if status == "SLEEPING":
            if not bibsched_send_signal(task_id, signal.SIGCONT):
                bibsched_set_status(task_id, "ERROR", "SLEEPING")
            self.update_rows()
            self.repaint()
            self.display_in_footer("process woken up")
        else:
            self.display_in_footer("process is not sleeping")
        self.stdscr.refresh()
 def stop_task(self):
     task_id = self.currentrow[0]
     status = self.currentrow[5]
     if status in ('RUNNING', 'CONTINUING', 'ABOUT TO SLEEP', 'SLEEPING'):
         if status == 'SLEEPING':
             bibsched_set_status(task_id, 'NOW STOP', 'SLEEPING')
             bibsched_send_signal(task_id, signal.SIGCONT)
             count = 10
             while bibsched_get_status(task_id) == 'NOW STOP':
                 if count <= 0:
                     bibsched_set_status(task_id, 'ERROR', 'NOW STOP')
                     self.update_rows()
                     self.repaint()
                     self.display_in_footer(
                         "It seems impossible to wakeup this task.")
                     return
                 time.sleep(CFG_BIBSCHED_REFRESHTIME)
                 count -= 1
         else:
             bibsched_set_status(task_id, 'ABOUT TO STOP', status)
         self.update_rows()
         self.repaint()
         self.display_in_footer("STOP signal sent to task #%s" % task_id)
     else:
         self.display_in_footer("Cannot stop non-running processes")
 def stop_task(self):
     task_id = self.currentrow[0]
     status = self.currentrow[5]
     if status in ('RUNNING', 'CONTINUING', 'ABOUT TO SLEEP', 'SLEEPING'):
         if status == 'SLEEPING':
             bibsched_set_status(task_id, 'NOW STOP', 'SLEEPING')
             bibsched_send_signal(task_id, signal.SIGCONT)
             count = 10
             while bibsched_get_status(task_id) == 'NOW STOP':
                 if count <= 0:
                     bibsched_set_status(task_id, 'ERROR', 'NOW STOP')
                     self.update_rows()
                     self.repaint()
                     self.display_in_footer("It seems impossible to wakeup this task.")
                     return
                 time.sleep(CFG_BIBSCHED_REFRESHTIME)
                 count -= 1
         else:
             bibsched_set_status(task_id, 'ABOUT TO STOP', status)
         self.update_rows()
         self.repaint()
         self.display_in_footer("STOP signal sent to task #%s" % task_id)
     else:
         self.display_in_footer("Cannot stop non-running processes")