• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python node_manager_fkie.ssh函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中node_manager_fkie.ssh函数的典型用法代码示例。如果您正苦于以下问题:Python ssh函数的具体用法?Python ssh怎么用?Python ssh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ssh函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: killScreens

 def killScreens(cls, host, node, user=None, parent=None):
   '''
   Searches for the screen associated with the given node and kill this screens. 
   @param host: the host name or ip where the screen is running
   @type host: C{str}
   @param node: the name of the node those screen output to show
   @type node: C{str}
   @param parent: the parent widget to show a message box, if a user 
   input is required.
   @type parent: L{PySide.QtGui.QWidget}
   '''
   if node is None or len(node) == 0:
     return False
   # get the available screens
   screens = cls.getActiveScreens(host, cls.createSessionName(node), user=user) #user=user, pwd=pwd
   if screens:
     from PySide import QtGui
     result = QtGui.QMessageBox.question(parent, "Kill SCREENs?", '\n'.join(screens), QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Ok)
     if result & QtGui.QMessageBox.Ok:
       for s in screens:
         pid, sep, name = s.partition('.')
         if pid:
           try:
             nm.starter().kill(host, int(pid))
           except:
             import traceback
             rospy.logwarn("Error while kill screen (PID: %s) on host '%s': %s", str(pid), str(host), str(traceback.format_exc()))
       if nm.is_local(host):
         ps = subprocess.Popen([cls.SCREEN, '-wipe'])
         # wait for process to avoid 'defunct' processes
         thread = threading.Thread(target=ps.wait)
         thread.setDaemon(True)
         thread.start()
       else:
         nm.ssh().ssh_exec(host, [cls.SCREEN, '-wipe'])
开发者ID:mjschuster,项目名称:multimaster_fkie,代码行数:35,代码来源:screen_handler.py


示例2: deleteLog

 def deleteLog(cls, nodename, host, auto_pw_request=False, user=None, pw=None):
   '''
   Deletes the log file associated with the given node.
   @param nodename: the name of the node (with name space)
   @type nodename: C{str}
   @param host: the host name or ip where the log file are to delete
   @type host: C{str}
   @raise Exception: on errors while resolving host
   @see: L{node_manager_fkie.is_local()}
   '''
   rospy.loginfo("delete log for '%s' on '%s'", str(nodename), str(host))
   if nm.is_local(host):
     screenLog = nm.screen().getScreenLogFile(node=nodename)
     pidFile = nm.screen().getScreenPidFile(node=nodename)
     roslog = nm.screen().getROSLogFile(nodename)
     if os.path.isfile(screenLog):
       os.remove(screenLog)
     if os.path.isfile(pidFile):
       os.remove(pidFile)
     if os.path.isfile(roslog):
       os.remove(roslog)
   else:
     try:
       #output ignored: output, error, ok 
       nm.ssh().ssh_exec(host, [nm.settings().start_remote_script, '--delete_logs', nodename], user, pw, auto_pw_request, close_stdin=True, close_stdout=True, close_stderr=True)
     except nm.AuthenticationRequest as e:
       raise nm.InteractionNeededError(e, cls.deleteLog, (nodename, host, auto_pw_request))
开发者ID:jhu-lcsr-forks,项目名称:multimaster_fkie,代码行数:27,代码来源:start_handler.py


示例3: _on_display_anchorClicked

 def _on_display_anchorClicked(self, url, user=None, pw=None):
   try:
     ok = False
     if self.show_only_rate:
       self.ssh_input_file, self.ssh_output_file, self.ssh_error_file, ok = nm.ssh().ssh_exec(url.host(), ['rostopic hz %s'%(self.topic)], user, pw, auto_pw_request=True, get_pty=True)
       self.status_label.setText('connected to %s over SSH'%url.host())
     else:
       self.combobox_displ_hz.setEnabled(False)
       nostr = '--nostr' if self.no_str_checkbox.isChecked() else ''
       noarr = '--noarr' if self.no_arr_checkbox.isChecked() else ''
       self.ssh_input_file, self.ssh_output_file, self.ssh_error_file, ok = nm.ssh().ssh_exec(url.host(), ['rostopic echo %s %s %s'%(nostr, noarr, self.topic)], user, pw, auto_pw_request=True, get_pty=True)
     if ok:
       self.display.clear()
       target = self._read_output_hz if self.show_only_rate else self._read_output
       thread = threading.Thread(target=target, args=((self.ssh_output_file,)))
       thread.setDaemon(True)
       thread.start()
       thread = threading.Thread(target=self._read_error, args=((self.ssh_error_file,)))
       thread.setDaemon(True)
       thread.start()
     elif self.ssh_output_file:
       self.ssh_output_file.close()
       self.ssh_error_file.close()
   except Exception as e:
     self._append_error_text('%s\n'%e)
开发者ID:garyservin,项目名称:multimaster_fkie,代码行数:25,代码来源:echo_dialog.py


示例4: openLog

 def openLog(cls, nodename, host):
   '''
   Opens the log file associated with the given node in a new terminal.
   @param nodename: the name of the node (with name space)
   @type nodename: C{str}
   @param host: the host name or ip where the log file are
   @type host: C{str}
   @return: C{True}, if a log file was found
   @rtype: C{bool}
   @raise Exception: on errors while resolving host
   @see: L{node_manager_fkie.is_local()}
   '''
   title_opt = ' '.join(['"LOG', nodename, 'on', host, '"'])
   if nm.is_local(host):
     found = False
     screenLog = nm.screen().getScreenLogFile(node=nodename)
     if os.path.isfile(screenLog):
       cmd = nm.terminal_cmd([nm.LESS, screenLog], title_opt)
       rospy.loginfo("open log: %s", cmd)
       subprocess.Popen(shlex.split(cmd))
       found = True
     #open roslog file
     roslog = nm.screen().getROSLogFile(nodename)
     if os.path.isfile(roslog):
       title_opt = title_opt.replace('LOG', 'ROSLOG')
       cmd = nm.terminal_cmd([nm.LESS, roslog], title_opt)
       rospy.loginfo("open ROS log: %s", cmd)
       subprocess.Popen(shlex.split(cmd))
       found = True
     return found
   else:
     nm.ssh().ssh_x11_exec(host, [nm.STARTER_SCRIPT, '--show_screen_log', nodename], title_opt)
     nm.ssh().ssh_x11_exec(host, [nm.STARTER_SCRIPT, '--show_ros_log', nodename], title_opt.replace('LOG', 'ROSLOG'))
   return False
开发者ID:schneider42,项目名称:fkie-ros-pkg,代码行数:34,代码来源:start_handler.py


示例5: openLog

 def openLog(cls, nodename, host, user=None):
   '''
   Opens the log file associated with the given node in a new terminal.
   @param nodename: the name of the node (with name space)
   @type nodename: C{str}
   @param host: the host name or ip where the log file are
   @type host: C{str}
   @return: C{True}, if a log file was found
   @rtype: C{bool}
   @raise Exception: on errors while resolving host
   @see: L{node_manager_fkie.is_local()}
   '''
   rospy.loginfo("show log for '%s' on '%s'", str(nodename), str(host))
   title_opt = 'LOG %s on %s'%(nodename, host)
   if nm.is_local(host):
     found = False
     screenLog = nm.screen().getScreenLogFile(node=nodename)
     if os.path.isfile(screenLog):
       cmd = nm.settings().terminal_cmd([nm.settings().log_viewer, screenLog], title_opt)
       rospy.loginfo("open log: %s", cmd)
       SupervisedPopen(shlex.split(cmd), id="Open log", description="Open log for '%s' on '%s'"%(str(nodename), str(host)))
       found = True
     #open roslog file
     roslog = nm.screen().getROSLogFile(nodename)
     if os.path.isfile(roslog):
       title_opt = title_opt.replace('LOG', 'ROSLOG')
       cmd = nm.settings().terminal_cmd([nm.settings().log_viewer, roslog], title_opt)
       rospy.loginfo("open ROS log: %s", cmd)
       SupervisedPopen(shlex.split(cmd), id="Open log", description="Open log for '%s' on '%s'"%(str(nodename), str(host)))
       found = True
     return found
   else:
     ps = nm.ssh().ssh_x11_exec(host, [nm.settings().start_remote_script, '--show_screen_log', nodename], title_opt, user)
     ps = nm.ssh().ssh_x11_exec(host, [nm.settings().start_remote_script, '--show_ros_log', nodename], title_opt.replace('LOG', 'ROSLOG'), user)
   return False
开发者ID:jhu-lcsr-forks,项目名称:multimaster_fkie,代码行数:35,代码来源:start_handler.py


示例6: killScreens

 def killScreens(cls, node, host, auto_ok_request=True, user=None, pw=None):
     '''
     Searches for the screen associated with the given node and kill this screens.
     @param node: the name of the node those screen output to show
     @type node: C{str}
     @param host: the host name or ip where the screen is running
     @type host: C{str}
     '''
     if node is None or len(node) == 0:
         return False
     try:
         # get the available screens
         screens = cls._getActiveScreens(host, cls.createSessionName(node), auto_ok_request, user=user, pwd=pw)  # user=user, pwd=pwd
         if screens:
             do_kill = True
             if auto_ok_request:
                 from node_manager_fkie.detailed_msg_box import MessageBox
                 result = MessageBox.question(None, "Kill SCREENs?", '\n'.join(screens), buttons=MessageBox.Ok | MessageBox.Cancel)
                 if result == MessageBox.Ok:
                     do_kill = True
             if do_kill:
                 for s in screens:
                     pid, _, _ = s.partition('.')
                     if pid:
                         try:
                             nm.starter()._kill_wo(host, int(pid), auto_ok_request, user, pw)
                         except:
                             import traceback
                             rospy.logwarn("Error while kill screen (PID: %s) on host '%s': %s", utf8(pid), utf8(host), traceback.format_exc(1))
                 if nm.is_local(host):
                     SupervisedPopen([cls.SCREEN, '-wipe'], object_id='screen -wipe', description="screen: clean up the socket with -wipe")
                 else:
                     nm.ssh().ssh_exec(host, [cls.SCREEN, '-wipe'], close_stdin=True, close_stdout=True, close_stderr=True)
     except nm.AuthenticationRequest as e:
         raise nm.InteractionNeededError(e, cls.killScreens, (node, host, auto_ok_request))
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:35,代码来源:screen_handler.py


示例7: openLog

 def openLog(cls, nodename, host, user=None):
   '''
   Opens the log file associated with the given node in a new terminal.
   @param nodename: the name of the node (with name space)
   @type nodename: C{str}
   @param host: the host name or ip where the log file are
   @type host: C{str}
   @return: C{True}, if a log file was found
   @rtype: C{bool}
   @raise Exception: on errors while resolving host
   @see: L{node_manager_fkie.is_local()}
   '''
   rospy.loginfo("show log for '%s' on '%s'", str(nodename), str(host))
   title_opt = ' '.join(['"LOG', nodename, 'on', host, '"'])
   if nm.is_local(host):
     found = False
     screenLog = nm.screen().getScreenLogFile(node=nodename)
     if os.path.isfile(screenLog):
       cmd = nm.terminal_cmd([nm.LESS, screenLog], title_opt)
       rospy.loginfo("open log: %s", cmd)
       ps = subprocess.Popen(shlex.split(cmd))
       # wait for process to avoid 'defunct' processes
       thread = threading.Thread(target=ps.wait)
       thread.setDaemon(True)
       thread.start()
       found = True
     #open roslog file
     roslog = nm.screen().getROSLogFile(nodename)
     if os.path.isfile(roslog):
       title_opt = title_opt.replace('LOG', 'ROSLOG')
       cmd = nm.terminal_cmd([nm.LESS, roslog], title_opt)
       rospy.loginfo("open ROS log: %s", cmd)
       ps = subprocess.Popen(shlex.split(cmd))
       # wait for process to avoid 'defunct' processes
       thread = threading.Thread(target=ps.wait)
       thread.setDaemon(True)
       thread.start()
       found = True
     return found
   else:
     ps = nm.ssh().ssh_x11_exec(host, [nm.STARTER_SCRIPT, '--show_screen_log', nodename], title_opt, user)
     # wait for process to avoid 'defunct' processes
     thread = threading.Thread(target=ps.wait)
     thread.setDaemon(True)
     thread.start()
     ps = nm.ssh().ssh_x11_exec(host, [nm.STARTER_SCRIPT, '--show_ros_log', nodename], title_opt.replace('LOG', 'ROSLOG'), user)
     # wait for process to avoid 'defunct' processes
     thread = threading.Thread(target=ps.wait)
     thread.setDaemon(True)
     thread.start()
   return False
开发者ID:awesomebytes,项目名称:multimaster_fkie,代码行数:51,代码来源:start_handler.py


示例8: _resolve_abs_paths

 def _resolve_abs_paths(cls, value, host, user, pw, auto_pw_request):
     '''
     Replaces the local absolute path by remote absolute path. Only valid ROS
     package paths are resolved.
     @return: value, is absolute path, remote package found (ignore it on local host or if is not absolute path!), package name (if absolute path and remote package NOT found)
     '''
     if isinstance(value, types.StringTypes) and value.startswith('/') and (os.path.isfile(value) or os.path.isdir(value)):
         if nm.is_local(host):
             return value, True, True, ''
         else:
             path = os.path.dirname(value) if os.path.isfile(value) else value
             package, package_path = package_name(path)
             if package:
                 _, stdout, _, ok = nm.ssh().ssh_exec(host, ['rospack', 'find', package], user, pw, auto_pw_request, close_stdin=True, close_stderr=True)
                 output = stdout.read()
                 stdout.close()
                 if ok:
                     if output:
                         value.replace(package_path, output)
                         return value.replace(package_path, output.strip()), True, True, package
                     else:
                         # package on remote host not found!
                         # TODO add error message
                         #      error = stderr.read()
                         pass
             return value, True, False, ''
     else:
         return value, False, False, ''
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:28,代码来源:start_handler.py


示例9: getActiveScreens

 def getActiveScreens(cls, host, session='', user=None, pwd=None):
   '''
   Returns the list with all compatible screen names. If the session is set to 
   an empty string all screens will be returned.
   @param host: the host name or IP to search for the screen session.
   @type host: C{str}
   @param session: the name or the suffix of the screen session
   @type session: C{str} (Default: C{''})
   @return: the list with session names
   @rtype: C{[str(session name), ...]}
   @raise Exception: on errors while resolving host
   @see: L{node_manager_fkie.is_local()}
   '''
   output = None
   result = []
   if nm.is_local(host):
     out, out_err = cls.getLocalOutput([cls.SCREEN, '-ls'])
     output = out
   else:
     (stdin, stdout, stderr), ok = nm.ssh().ssh_exec(host, [cls.SCREEN, ' -ls'])
     if ok:
       stdin.close()
 #        error = stderr.read()
       output = stdout.read()
   if not (output is None):
     splits = output.split()
     for i in splits:
       if i.count('.') > 0 and i.endswith(session):
         result.append(i)
   return result
开发者ID:schneider42,项目名称:fkie-ros-pkg,代码行数:30,代码来源:screen_handler.py


示例10: openScreenTerminal

  def openScreenTerminal(cls, host, screen_name, nodename, user=None):
    '''
    Open the screen output in a new terminal.
    @param host: the host name or ip where the screen is running.
    @type host: C{str}
    @param screen_name: the name of the screen to show
    @type screen_name: C{str}
    @param nodename: the name of the node is used for the title of the terminal
    @type nodename: C{str}
    @raise Exception: on errors while resolving host
    @see: L{node_manager_fkie.is_local()}
    '''
    #create a title of the terminal
#    pid, session_name = cls.splitSessionName(screen_name)
    title_opt = ' '.join(['"SCREEN', nodename, 'on', host, '"'])
    if nm.is_local(host):
      cmd = nm.terminal_cmd([cls.SCREEN, '-x', screen_name], title_opt)
      rospy.loginfo("Open screen terminal: %s", cmd)
      ps = subprocess.Popen(shlex.split(cmd))
      # wait for process to avoid 'defunct' processes
      thread = threading.Thread(target=ps.wait)
      thread.setDaemon(True)
      thread.start()
    else:
      ps = nm.ssh().ssh_x11_exec(host, [cls.SCREEN, '-x', screen_name], title_opt)
      rospy.loginfo("Open remote screen terminal: %s", ps)
      # wait for process to avoid 'defunct' processes
      thread = threading.Thread(target=ps.wait)
      thread.setDaemon(True)
      thread.start()
开发者ID:markusachtelik,项目名称:multimaster_fkie,代码行数:30,代码来源:screen_handler.py


示例11: kill

 def kill(self, host, pid):
   '''
   Kills the process with given process id on given host.
   @param host: the name or address of the host, where the process must be killed.
   @type host: C{str}
   @param pid: the process id
   @type pid: C{int}
   @raise StartException: on error
   @raise Exception: on errors while resolving host
   @see: L{node_manager_fkie.is_local()}
   '''
   if nm.is_local(host): 
     import signal
     os.kill(pid, signal.SIGKILL)
     rospy.loginfo("kill: %s", str(pid))
   else:
     # kill on a remote machine
     cmd = ['kill -9', str(pid)]
     rospy.loginfo("kill remote on %s: %s", host, ' '.join(cmd))
     (stdin, stdout, stderr), ok = nm.ssh().ssh_exec(host, cmd)
     if ok:
       stdin.close()
       error = stderr.read()
       if error:
         rospy.logwarn("ERROR while kill %s: %s", str(pid), error)
         raise nm.StartException(str(''.join(['The host "', host, '" reports:\n', error])))
       output = stdout.read()
       if output:
         rospy.logdebug("STDOUT while kill %s on %s: %s", str(pid), host, output)
开发者ID:mjschuster,项目名称:multimaster_fkie,代码行数:29,代码来源:start_handler.py


示例12: _on_request_interact

 def _on_request_interact(self, ident, descr, req):
   '''
   If the interaction of the user is needed a message dialog must be exceuted 
   in the main Qt thread. The requests are done by different request exceptinos.
   These are handled by this method.
   '''
   if isinstance(req.request, nm.AuthenticationRequest):
     res, user, pw = nm.ssh()._requestPW(req.request.user, req.request.host)
     if not res:
       self._on_progress_canceled()
       return
     pt = ProgressThread(ident, descr, req.method, (req.args+(user, pw)))
     pt.finished_signal.connect(self._progress_thread_finished)
     pt.error_signal.connect(self._progress_thread_error)
     pt.request_interact_signal.connect(self._on_request_interact)
     pt.start()
   elif isinstance(req.request, nm.ScreenSelectionRequest):
     from select_dialog import SelectDialog
     items, _ = SelectDialog.getValue('Show screen', '', req.request.choices.keys(), False)
     if not items:
       self._progress_thread_finished(ident)
       return
     res = [req.request.choices[i] for i in items]
     pt = ProgressThread(ident, descr, req.method, (req.args+(res,)))
     pt.finished_signal.connect(self._progress_thread_finished)
     pt.error_signal.connect(self._progress_thread_error)
     pt.request_interact_signal.connect(self._on_request_interact)
     pt.start()
   elif isinstance(req.request, nm.BinarySelectionRequest):
     from select_dialog import SelectDialog
     items, _ = SelectDialog.getValue('Multiple executables', '', req.request.choices, True)
     if not items:
       self._progress_thread_finished(ident)
       return
     res = items[0]
     pt = ProgressThread(ident, descr, req.method, (req.args+(res,)))
     pt.finished_signal.connect(self._progress_thread_finished)
     pt.error_signal.connect(self._progress_thread_error)
     pt.request_interact_signal.connect(self._on_request_interact)
     pt.start()
   elif isinstance(req.request, nm.LaunchArgsSelectionRequest):
     from parameter_dialog import ParameterDialog
     inputDia = ParameterDialog(req.request.args_dict)
     inputDia.setFilterVisible(False)
     inputDia.setWindowTitle(''.join(['Enter the argv for ', req.request.launchfile]))
     if inputDia.exec_():
       params = inputDia.getKeywords()
       argv = []
       for p,v in params.items():
         if v:
           argv.append(''.join([p, ':=', v]))
       res = argv
       pt = ProgressThread(ident, descr, req.method, (req.args+(argv,)))
       pt.finished_signal.connect(self._progress_thread_finished)
       pt.error_signal.connect(self._progress_thread_error)
       pt.request_interact_signal.connect(self._on_request_interact)
       pt.start()
     else:
       self._progress_thread_finished(ident)
       return
开发者ID:jhu-lcsr-forks,项目名称:multimaster_fkie,代码行数:60,代码来源:progress_queue.py


示例13: _resolve_abs_paths

  def _resolve_abs_paths(cls, value, host):
    '''
    Replaces the local absolute path by remote absolute path. Only valid ROS
    package paths are resolved.
    @return: value, is absolute path, remote package found (ignore it on local host or if is not absolute path!), package name (if absolute path and remote package NOT found)
    '''
    if isinstance(value, types.StringTypes) and value.startswith('/') and (os.path.isfile(value) or os.path.isdir(value)):
      if nm.is_local(host):
        return value, True, True, ''
      else:
#        print "ABS PATH:", value, os.path.dirname(value)
        dir = os.path.dirname(value) if os.path.isfile(value) else value
        package, package_path = LaunchConfig.packageName(dir)
        if package:
          (stdin, stdout, stderr), ok = nm.ssh().ssh_exec(host, ['rospack', 'find', package])
          if ok:
            stdin.close()
            output = stdout.read()
            if output:
#              print "  RESOLVED:", output
#              print "  PACK_PATH:", package_path
              value.replace(package_path, output)
#              print "  RENAMED:", value.replace(package_path, output.strip())
              return value.replace(package_path, output.strip()), True, True, package
            else:
              # package on remote host not found! 
              # TODO add error message
              #      error = stderr.read()
              pass
        return value, True, False, ''
    else:
      return value, False, False, ''
开发者ID:mjschuster,项目名称:multimaster_fkie,代码行数:32,代码来源:start_handler.py


示例14: _getActiveScreens

 def _getActiveScreens(cls, host, session='', auto_pw_request=True, user=None, pwd=None):
   '''
   Returns the list with all compatible screen names. If the session is set to 
   an empty string all screens will be returned.
   @param host: the host name or IP to search for the screen session.
   @type host: C{str}
   @param session: the name or the suffix of the screen session
   @type session: C{str} (Default: C{''})
   @return: the list with session names
   @rtype: C{[str(session name), ...]}
   @raise Exception: on errors while resolving host
   @see: L{node_manager_fkie.is_local()}
   '''
   output = None
   result = []
   if nm.is_local(host):
     output = cls.getLocalOutput([cls.SCREEN, '-ls'])
   else:
     _, stdout, _, _ = nm.ssh().ssh_exec(host, [cls.SCREEN, ' -ls'], user, pwd, auto_pw_request, close_stdin=True, close_stderr=True)
     output = stdout.read()
     stdout.close()
   if output:
     splits = output.split()
     for i in splits:
       if i.count('.') > 0 and i.endswith(session) and i.find('._') >= 0:
         result.append(i)
   return result
开发者ID:jhu-lcsr-forks,项目名称:multimaster_fkie,代码行数:27,代码来源:screen_handler.py


示例15: _rosclean_wo

 def _rosclean_wo(self, host, auto_pw_request=False, user=None, pw=None):
     if nm.is_local(host):
         rospy.loginfo("rosclean purge on localhost!")
         cmd = nm.settings().terminal_cmd(['rosclean purge -y'], "rosclean")
         SupervisedPopen(shlex.split(cmd), object_id="rosclean", description="rosclean")
     else:
         rospy.loginfo("rosclean %s", host)
         # kill on a remote machine
         cmd = ['rosclean purge -y']
         _ = nm.ssh().ssh_x11_exec(host, cmd, 'rosclean purge on %s' % host, user)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:10,代码来源:start_handler.py


示例16: _poweroff_wo

 def _poweroff_wo(self, host, auto_pw_request=False, user=None, pw=None):
     if nm.is_local(host):
         rospy.logwarn("shutdown localhost localhost!")
         cmd = nm.settings().terminal_cmd(['sudo poweroff'], "poweroff")
         SupervisedPopen(shlex.split(cmd), object_id="poweroff", description="poweroff")
     else:
         rospy.loginfo("poweroff %s", host)
         # kill on a remote machine
         cmd = ['sudo poweroff']
         _ = nm.ssh().ssh_x11_exec(host, cmd, 'Shutdown %s' % host, user)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:10,代码来源:start_handler.py


示例17: transfer_files

 def transfer_files(cls, host, path, auto_pw_request=False, user=None, pw=None):
     '''
     Copies the given file to the remote host. Uses caching of remote paths.
     '''
     # get package of the file
     if nm.is_local(host):
         # it's local -> no copy needed
         return
     (pkg_name, pkg_path) = package_name(os.path.dirname(path))
     if pkg_name is not None:
         # get the subpath of the file
         subfile_path = path.replace(pkg_path, '')
         # get the path of the package on the remote machine
         try:
             output = ''
             error = ''
             ok = True
             if host in CACHED_PKG_PATH and pkg_name in CACHED_PKG_PATH[host]:
                 output = CACHED_PKG_PATH[host][pkg_name]
             else:
                 if host not in CACHED_PKG_PATH:
                     CACHED_PKG_PATH[host] = dict()
                 _, stdout, stderr, ok = nm.ssh().ssh_exec(host, [nm.settings().start_remote_script, '--package', pkg_name], user, pw, auto_pw_request, close_stdin=True)
                 output = stdout.read()
                 error = stderr.read()
                 stdout.close()
                 stderr.close()
             if ok:
                 if error:
                     rospy.logwarn("ERROR while transfer %s to %s: %s", path, host, error)
                     raise StartException(utf8(''.join(['The host "', host, '" reports:\n', error])))
                 if output:
                     CACHED_PKG_PATH[host][pkg_name] = output
                     nm.ssh().transfer(host, path, os.path.join(output.strip(), subfile_path.strip(os.sep)), user)
                 else:
                     raise StartException("Remote host no returned any answer. Is there the new version of node_manager installed?")
             else:
                 raise StartException("Can't get path from remote host. Is there the new version of node_manager installed?")
         except nm.AuthenticationRequest as e:
             raise nm.InteractionNeededError(e, cls.transfer_files, (host, path, auto_pw_request))
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:40,代码来源:start_handler.py


示例18: transfer_files

 def transfer_files(cls, host, file, auto_pw_request=False, user=None, pw=None):
   '''
   Copies the given file to the remote host. Uses caching of remote paths.
   '''
   # get package of the file
   if nm.is_local(host):
     #it's local -> no copy needed
     return
   (pkg_name, pkg_path) = package_name(os.path.dirname(file))
   if not pkg_name is None:
     # get the subpath of the file
     subfile_path = file.replace(pkg_path, '')
     # get the path of the package on the remote machine
     try:
       output = ''
       error = ''
       ok = True
       if CACHED_PKG_PATH.has_key(host) and CACHED_PKG_PATH[host].has_key(pkg_name):
         output = CACHED_PKG_PATH[host][pkg_name]
       else:
         if not CACHED_PKG_PATH.has_key(host):
           CACHED_PKG_PATH[host] = dict()
         output, error, ok = nm.ssh().ssh_exec(host, [nm.STARTER_SCRIPT, '--package', pkg_name], user, pw, auto_pw_request)
       if ok:
         if error:
           rospy.logwarn("ERROR while transfer %s to %s: %s", file, host, error)
           raise StartException(str(''.join(['The host "', host, '" reports:\n', error])))
         if output:
           CACHED_PKG_PATH[host][pkg_name] = output
           nm.ssh().transfer(host, file, os.path.join(output.strip(), subfile_path.strip(os.sep)), user)
         else:
           raise StartException("Remote host no returned any answer. Is there the new version of node_manager installed?")
       else:
         raise StartException("Can't get path from remote host. Is there the new version of node_manager installed?")
     except nm.AuthenticationRequest as e:
       raise nm.InteractionNeededError(e, cls.transfer_files, (host, file, auto_pw_request))
开发者ID:awesomebytes,项目名称:multimaster_fkie,代码行数:36,代码来源:start_handler.py


示例19: _kill_wo

 def _kill_wo(self, host, pid, auto_pw_request=False, user=None, pw=None):
   rospy.loginfo("kill %s on %s", str(pid), host)
   if nm.is_local(host): 
     os.kill(pid, signal.SIGKILL)
     rospy.loginfo("kill: %s", str(pid))
   else:
     # kill on a remote machine
     cmd = ['kill -9', str(pid)]
     output, error, ok = nm.ssh().ssh_exec(host, cmd, user, pw, False)
     if ok:
       if error:
         rospy.logwarn("ERROR while kill %s: %s", str(pid), error)
         raise StartException(str(''.join(['The host "', host, '" reports:\n', error])))
       if output:
         rospy.logdebug("STDOUT while kill %s on %s: %s", str(pid), host, output)
开发者ID:awesomebytes,项目名称:multimaster_fkie,代码行数:15,代码来源:start_handler.py


示例20: copylogPath2Clipboards

 def copylogPath2Clipboards(self, host, nodes=[], auto_pw_request=True, user=None, pw=None):
   if nm.is_local(host):
     if len(nodes) == 1:
       return nm.screen().getScreenLogFile(node=nodes[0])
     else:
       return nm.screen().LOG_PATH
   else:
     request = '[]' if len(nodes) != 1 else nodes[0]
     try:
       output, error, ok = nm.ssh().ssh_exec(host, [nm.STARTER_SCRIPT, '--ros_log_path', request], user, pw, auto_pw_request)
       if ok:
         return output
       else:
         raise StartException(str(''.join(['Get log path from "', host, '" failed:\n', error])))
     except nm.AuthenticationRequest as e:
       raise nm.InteractionNeededError(e, cls.deleteLog, (nodename, host, auto_pw_request))
开发者ID:Lolu28,项目名称:multimaster_fkie,代码行数:16,代码来源:start_handler.py



注:本文中的node_manager_fkie.ssh函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factory.create_structureNode函数代码示例发布时间:2022-05-27
下一篇:
Python node_manager_fkie.settings函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap