예제 #1
0
파일: grid.py 프로젝트: Solvi/pyhrf
    def run(self):
        tm = self._tasks_manager
        hm = tm._hosts_manager
        task = self._task.get()

        # probe host
        hostname = self._host._name
        t, status = hm.probe(hostname)
        if t is None :
            msg.warning('probing %s failed' % hostname)
            #hm.update_host_status(hostname, status)
            self._bad_stop(t, None)
            return

        # get connection
        try:
            t.connect(**self._get_connection_params())
#FIXME : version 1.5.2 (at home) : n'existe pas, verifier a neurospin
#        except paramiko.AuthenticationException:
#            msg.warning('Authentication failed on %s' % hostname)
#            self._bad_stop(t, None)
#            return
        except paramiko.SSHException, e:
            msg.warning('ssh on %s: %s' % (hostname, e))
            self._bad_stop(t, None)
            return
예제 #2
0
    def run(self):
        tm = self._tasks_manager
        hm = tm._hosts_manager
        task = self._task.get()

        # probe host
        hostname = self._host._name
        t, status = hm.probe(hostname)
        if t is None:
            msg.warning('probing %s failed' % hostname)
            #hm.update_host_status(hostname, status)
            self._bad_stop(t, None)
            return

        # get connection
        try:
            t.connect(**self._get_connection_params())


#FIXME : version 1.5.2 (at home) : n'existe pas, verifier a neurospin
#        except paramiko.AuthenticationException:
#            msg.warning('Authentication failed on %s' % hostname)
#            self._bad_stop(t, None)
#            return
        except paramiko.SSHException, e:
            msg.warning('ssh on %s: %s' % (hostname, e))
            self._bad_stop(t, None)
            return
예제 #3
0
파일: grid.py 프로젝트: Solvi/pyhrf
 def _bad_stop(self, transport, channel):
     self._lock.acquire()
     self._stop(transport, channel)
     if not self._killed:
         msg.warning("remove host '%s' from avalaible hosts." % \
                             self._host)
         self._tasks_manager.abnormal_stop(self._task.get())
     self._lock.release()
예제 #4
0
 def _bad_stop(self, transport, channel):
     self._lock.acquire()
     self._stop(transport, channel)
     if not self._killed:
         msg.warning("remove host '%s' from avalaible hosts." % \
                             self._host)
         self._tasks_manager.abnormal_stop(self._task.get())
     self._lock.release()
예제 #5
0
파일: grid.py 프로젝트: Solvi/pyhrf
 def kill(self):
     tm = self._tasks_manager
     try:
         t, status = tm._hosts_manager.probe(self._host._name)
         t.connect(**self._get_connection_params())
         chan = t.open_session()
         cmd = "pkill -t %s" % re.split("/dev/", self._pty)[1]
         chan.exec_command(cmd)
         self._killed = True
         self._bad_stop(t, chan)
     except exceptions.Exception, e:
         msg.warning("can't kill tasks on %s : %s" % \
                         (self._host, e))
예제 #6
0
 def kill(self):
     tm = self._tasks_manager
     try:
         t, status = tm._hosts_manager.probe(self._host._name)
         t.connect(**self._get_connection_params())
         chan = t.open_session()
         cmd = "pkill -t %s" % re.split("/dev/", self._pty)[1]
         chan.exec_command(cmd)
         self._killed = True
         self._bad_stop(t, chan)
     except exceptions.Exception, e:
         msg.warning("can't kill tasks on %s : %s" % \
                         (self._host, e))
예제 #7
0
파일: grid.py 프로젝트: Solvi/pyhrf
 def start(self):
     n = len(self._tasks)
     p = 0 # printed tasks number
     host_pop = self._free_hosts.pop
     while self._tasks_finished_number != n:
         host = self.wait_for_end_or_cmd([p], n, host_pop)
         get_next_task = self._tasks.next
         task = self.wait_for_end_or_cmd([p], n, get_next_task)
         if host and task:
             self.wait_to_be_ready()
             ts = TasksStarter(self, host, task,
                                               self._time_limit)
             ts.start()
         if len(self._free_hosts) == 0 and \
             len(self._active_hosts) == 0: break
         if p != self._tasks_finished_number:
             self.print_status(self._tasks_finished_number,n)
             p = self._tasks_finished_number
         time.sleep(0.01)
     if len(self._free_hosts) == 0 and \
         self._tasks_finished_number != n :
         msg.warning('no more available hosts : sorry :(')
예제 #8
0
 def start(self):
     n = len(self._tasks)
     p = 0  # printed tasks number
     host_pop = self._free_hosts.pop
     while self._tasks_finished_number != n:
         host = self.wait_for_end_or_cmd([p], n, host_pop)
         get_next_task = self._tasks.next
         task = self.wait_for_end_or_cmd([p], n, get_next_task)
         if host and task:
             self.wait_to_be_ready()
             ts = TasksStarter(self, host, task, self._time_limit)
             ts.start()
         if len(self._free_hosts) == 0 and \
             len(self._active_hosts) == 0:
             break
         if p != self._tasks_finished_number:
             self.print_status(self._tasks_finished_number, n)
             p = self._tasks_finished_number
         time.sleep(0.01)
     if len(self._free_hosts) == 0 and \
         self._tasks_finished_number != n :
         msg.warning('no more available hosts : sorry :(')
예제 #9
0
파일: grid.py 프로젝트: Solvi/pyhrf
            return

        # get connection
        try:
            t.connect(**self._get_connection_params())
#FIXME : version 1.5.2 (at home) : n'existe pas, verifier a neurospin
#        except paramiko.AuthenticationException:
#            msg.warning('Authentication failed on %s' % hostname)
#            self._bad_stop(t, None)
#            return
        except paramiko.SSHException, e:
            msg.warning('ssh on %s: %s' % (hostname, e))
            self._bad_stop(t, None)
            return
        except exceptions.Exception, e:
            msg.warning('unknown exception (connection) : %s' % e)
            self._bad_stop(t, None)
            return

        # run task
        try:
            chan = t.open_session()
            if chan is None :
                msg.warning('ssh on %s' % hostname)
                self._bad_stop(t, None)
                return
        except paramiko.SSHException, e:
            msg.warning('ssh on %s: %s' % (hostname, e))
            self._bad_stop(t, None)
            return
        except exceptions.Exception, e:
예제 #10
0
        # get connection
        try:
            t.connect(**self._get_connection_params())


#FIXME : version 1.5.2 (at home) : n'existe pas, verifier a neurospin
#        except paramiko.AuthenticationException:
#            msg.warning('Authentication failed on %s' % hostname)
#            self._bad_stop(t, None)
#            return
        except paramiko.SSHException, e:
            msg.warning('ssh on %s: %s' % (hostname, e))
            self._bad_stop(t, None)
            return
        except exceptions.Exception, e:
            msg.warning('unknown exception (connection) : %s' % e)
            self._bad_stop(t, None)
            return

        # run task
        try:
            chan = t.open_session()
            if chan is None:
                msg.warning('ssh on %s' % hostname)
                self._bad_stop(t, None)
                return
        except paramiko.SSHException, e:
            msg.warning('ssh on %s: %s' % (hostname, e))
            self._bad_stop(t, None)
            return
        except exceptions.Exception, e: