当前位置: 首页>>代码示例>>Python>>正文


Python node_manager_fkie.settings函数代码示例

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


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

示例1: loadCache

 def loadCache(self, history_file):
   '''
   Loads the content of the given file and return it as cache.
   @param history_file: the name of the history file
   @type history_file: C{str}
   @return: the dictionary with arguments
   @rtype: C{dict(str(name):[str(value), ...], ...)}
   '''
   result = {}
   historyFile = os.path.join(nm.settings().cfg_path, history_file)
   if os.path.isfile(historyFile):
     with open(historyFile, 'r') as f:
       line = f.readline()
       while line:
         if line:
           line = line.strip()
           if line:
             key, sep, value = line.partition(':=')
             if sep:
               if not key in result.keys():
                 result[key] = [value]
               elif len(result[key]) <= nm.settings().param_history_length:
                 result[key].append(value)
         line = f.readline()
   return result
开发者ID:garyservin,项目名称:multimaster_fkie,代码行数:25,代码来源:history.py

示例2: on_launch_selection_activated

 def on_launch_selection_activated(self, activated):
     '''
     Tries to load the launch file, if one was activated.
     '''
     selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
     for item in selected:
         try:
             lfile = self.launchlist_model.expandItem(item.name, item.path, item.id)
             self.searchPackageLine.setText('')
             if lfile is not None:
                 if item.isLaunchFile():
                     nm.settings().launch_history_add(item.path)
                     key_mod = QApplication.keyboardModifiers()
                     if key_mod & Qt.ShiftModifier:
                         self.load_as_default_signal.emit(item.path, None)
                     elif key_mod & Qt.ControlModifier:
                         self.launchlist_model.setPath(os.path.dirname(item.path))
                     else:
                         self.load_signal.emit(item.path, [], None)
                 elif item.isProfileFile():
                     nm.settings().launch_history_add(item.path)
                     key_mod = QApplication.keyboardModifiers()
                     if key_mod & Qt.ControlModifier:
                         self.launchlist_model.setPath(os.path.dirname(item.path))
                     else:
                         self.load_profile_signal.emit(item.path)
                 elif item.isConfigFile():
                     self.edit_signal.emit([lfile])
         except Exception as e:
             rospy.logwarn("Error while load launch file %s: %s" % (item, utf8(e)))
             MessageBox.warning(self, "Load error",
                                'Error while load launch file:\n%s' % item.name,
                                "%s" % utf8(e))
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:33,代码来源:launch_files_widget.py

示例3: keyPressEvent

 def keyPressEvent(self, event):
     '''
     Defines some of shortcuts for navigation/management in launch
     list view or topics view.
     '''
     key_mod = QApplication.keyboardModifiers()
     if not self.xmlFileView.state() == QAbstractItemView.EditingState:
         # remove history file from list by pressing DEL
         if event == QKeySequence.Delete:
             selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
             for item in selected:
                 nm.settings().launch_history_remove(item.path)
                 self.launchlist_model.reloadCurrentPath()
         elif not key_mod and event.key() == Qt.Key_F4 and self.editXmlButton.isEnabled():
             # open selected launch file in xml editor by F4
             self.on_edit_xml_clicked()
         elif event == QKeySequence.Find:
             # set focus to filter box for packages
             self.searchPackageLine.setFocus(Qt.ActiveWindowFocusReason)
         elif event == QKeySequence.Paste:
             # paste files from clipboard
             self.launchlist_model.paste_from_clipboard()
         elif event == QKeySequence.Copy:
             # copy the selected items as file paths into clipboard
             selected = self.xmlFileView.selectionModel().selectedIndexes()
             indexes = []
             for s in selected:
                 indexes.append(self.launchlist_proxyModel.mapToSource(s))
             self.launchlist_model.copy_to_clipboard(indexes)
     if self.searchPackageLine.hasFocus() and event.key() == Qt.Key_Escape:
         # cancel package filtering on pressing ESC
         self.launchlist_model.show_packages(False)
         self.searchPackageLine.setText('')
         self.xmlFileView.setFocus(Qt.ActiveWindowFocusReason)
     QDockWidget.keyReleaseEvent(self, event)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:35,代码来源:launch_files_widget.py

示例4: on_load_as_default_at_host

 def on_load_as_default_at_host(self):
     '''
     Tries to load the selected launch file as default configuration. The button
     is only enabled and this method is called, if the button was enabled by
     on_launch_selection_clicked()
     '''
     selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
     for item in selected:
         path = self.launchlist_model.expandItem(item.name, item.path, item.id)
         if path is not None:
             params = {'Host': ('string', 'localhost')}
             dia = ParameterDialog(params)
             dia.setFilterVisible(False)
             dia.setWindowTitle('Start node on...')
             dia.resize(350, 120)
             dia.setFocusField('Host')
             if dia.exec_():
                 try:
                     params = dia.getKeywords()
                     host = params['Host']
                     rospy.loginfo("LOAD the launch file on host %s as default: %s" % (host, path))
                     nm.settings().launch_history_add(path)
                     self.load_as_default_signal.emit(path, host)
                 except Exception, e:
                     MessageBox.warning(self, "Load default config error",
                                        'Error while parse parameter',
                                        '%s' % utf8(e))
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:27,代码来源:launch_files_widget.py

示例5: setModelData

 def setModelData(self, editor, model, index):
   if isinstance(editor, PathEditor):
     cfg_path = nm.settings().cfg_path
     model.setData(index, editor.path)
     self.reload_settings = (cfg_path != nm.settings().cfg_path)
   else:
     QtGui.QStyledItemDelegate.setModelData(self, editor, model, index)
开发者ID:jhu-lcsr-forks,项目名称:multimaster_fkie,代码行数:7,代码来源:settings_widget.py

示例6: storeSetting

 def storeSetting(self):
   if nm.settings().store_geometry:
     settings = nm.settings().qsettings(nm.settings().CFG_GUI_FILE)
     settings.beginGroup("editor")
     settings.setValue("size", self.size())
     settings.setValue("pos", self.pos())
     settings.setValue("maximized", self.isMaximized())
     settings.endGroup()
开发者ID:jhu-lcsr-forks,项目名称:multimaster_fkie,代码行数:8,代码来源:xml_editor.py

示例7: on_open_xml_clicked

 def on_open_xml_clicked(self):
     (fileName, _) = QFileDialog.getOpenFileName(self,
                                                 "Load launch file",
                                                 self.__current_path,
                                                 "Config files (*.launch);;All files (*)")
     if fileName:
         self.__current_path = os.path.dirname(fileName)
         nm.settings().launch_history_add(fileName)
         self.load_signal.emit(fileName, [], None)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:9,代码来源:launch_files_widget.py

示例8: readSettings

 def readSettings(self):
   if nm.settings().store_geometry:
     settings = nm.settings().qsettings(nm.settings().CFG_GUI_FILE)
     settings.beginGroup("editor")
     maximized = settings.value("maximized", 'false') == 'true'
     if maximized:
       self.showMaximized()
     else:
       self.resize(settings.value("size", QtCore.QSize(800,640)))
       self.move(settings.value("pos", QtCore.QPoint(0, 0)))
     settings.endGroup()
开发者ID:jhu-lcsr-forks,项目名称:multimaster_fkie,代码行数:11,代码来源:xml_editor.py

示例9: on_load_xml_clicked

 def on_load_xml_clicked(self):
     '''
     Tries to load the selected launch file. The button is only enabled and this
     method is called, if the button was enabled by on_launch_selection_clicked()
     '''
     selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
     for item in selected:
         path = self.launchlist_model.expandItem(item.name, item.path, item.id)
         if path is not None:
             nm.settings().launch_history_add(item.path)
             self.load_signal.emit(path, [], None)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:11,代码来源:launch_files_widget.py

示例10: _storeLoadHistory

 def _storeLoadHistory(self, files):
   '''
   Saves the list of recently loaded files to history. The existing history will be replaced!
   @param files: the list with filenames
   @type files: C{[str]}
   '''
   historyFile = nm.settings().qsettings(nm.settings().LAUNCH_HISTORY_FILE)
   historyFile.beginWriteArray("launch_history")
   for i, file in enumerate(files):
     historyFile.setArrayIndex(i)
     historyFile.setValue("file", file)
   historyFile.endArray()
开发者ID:jhu-lcsr-forks,项目名称:multimaster_fkie,代码行数:12,代码来源:launch_list_model.py

示例11: setData

 def setData(self, value, role=Qt.EditRole):
     if role == Qt.EditRole:
         # rename the file or folder
         if self.name != value and self.id in [self.RECENT_FILE, self.LAUNCH_FILE, self.RECENT_PROFILE, self.PROFILE, self.CFG_FILE, self.FOLDER]:
             new_path = os.path.join(os.path.dirname(self.path), value)
             if not os.path.exists(new_path):
                 os.rename(self.path, new_path)
                 if self.name != value and self.id in [self.RECENT_FILE, self.RECENT_PROFILE]:
                     # update in history
                     nm.settings().launch_history_add(new_path, replace=self.path)
                 self.name = value
                 self.path = new_path
             else:
                 MessageBox.warning(self, "Path already exists",
                                    "`%s` already exists!" % value, "Complete path: %s" % new_path)
     return QStandardItem.setData(self, value, role)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:16,代码来源:launch_list_model.py

示例12: 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'", utf8(nodename), utf8(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
             _, stdout, _, ok = nm.ssh().ssh_exec(host, [nm.settings().start_remote_script, '--delete_logs', nodename], user, pw, auto_pw_request, close_stdin=True, close_stdout=False, close_stderr=True)
             if ok:
                 stdout.readlines()
                 stdout.close()
         except nm.AuthenticationRequest as e:
             raise nm.InteractionNeededError(e, cls.deleteLog, (nodename, host, auto_pw_request))
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:30,代码来源:start_handler.py

示例13: transfer

 def transfer(self, host, local_file, remote_file, user=None, pw=None, auto_pw_request=False):
     '''
     Copies a file to a remote location using paramiko sfpt.
     @param host: the host
     @type host: C{str}
     @param local_file: the local file
     @type local_file: str
     @param remote_file: the remote file name
     @type remote_file: str
     @param user: user name
     @param pw: the password
     '''
     with self.mutex:
         try:
             ssh = self._getSSH(host, nm.settings().host_user(host) if user is None else user, pw, True, auto_pw_request)
             if ssh is not None:
                 sftp = ssh.open_sftp()
                 try:
                     sftp.mkdir(os.path.dirname(remote_file))
                 except:
                     pass
                 sftp.put(local_file, remote_file)
                 rospy.loginfo("SSH COPY %s -> %[email protected]%s:%s", local_file, ssh._transport.get_username(), host, remote_file)
         except AuthenticationRequest as e:
             raise
         except Exception, e:
             raise
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:27,代码来源:ssh_handler.py

示例14: _included_files

 def _included_files(self, path):
     '''
     Returns all included files in the given file.
     '''
     result = []
     with open(path, 'r') as f:
         data = f.read()
         reg = QRegExp("=[\s\t]*\".*\"")
         reg.setMinimal(True)
         pos = reg.indexIn(data)
         while pos != -1 and self._isrunning:
             try:
                 pp = interpret_path(reg.cap(0).strip('"'))
                 f = QFile(pp)
                 ext = os.path.splitext(pp)
                 if f.exists() and ext[1] in nm.settings().SEARCH_IN_EXT:
                     result.append(pp)
             except Exception as exp:
                 parsed_text = pp
                 try:
                     parsed_text = reg.cap(0).strip('"')
                 except:
                     pass
                 self.warning_signal.emit("Error while parse '%s': %s" % (parsed_text, exp))
             pos += reg.matchedLength()
             pos = reg.indexIn(data, pos)
     return result
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:27,代码来源:text_search_thread.py

示例15: includedFiles

 def includedFiles(self):
     '''
     Returns all included files in the document.
     '''
     result = []
     b = self.document().begin()
     while b != self.document().end():
         text = b.text()
         index = self.index(text)
         if index > -1:
             startIndex = text.find('"', index)
             if startIndex > -1:
                 endIndex = text.find('"', startIndex + 1)
                 fileName = text[startIndex + 1:endIndex]
                 if len(fileName) > 0:
                     try:
                         path = interpret_path(fileName)
                         f = QFile(path)
                         ext = os.path.splitext(path)
                         if f.exists() and ext[1] in nm.settings().SEARCH_IN_EXT:
                             result.append(path)
                     except:
                         import traceback
                         print traceback.format_exc(1)
         b = b.next()
     return result
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:26,代码来源:text_edit.py


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