Ejemplo n.º 1
0
 def _load_interface(self):
     interface_file = resolve_url(rospy.get_param('~interface_url', ''))
     if interface_file:
         rospy.loginfo("interface_url: %s", interface_file)
     try:
         data = read_interface(interface_file) if interface_file else {}
         # set the ignore hosts list
         self._re_ignore_hosts = create_pattern('ignore_hosts', data, interface_file, [])
         # set the sync hosts list
         self._re_sync_hosts = create_pattern('sync_hosts', data, interface_file, [])
         self.__sync_topics_on_demand = False
         if interface_file:
             if 'sync_topics_on_demand' in data:
                 self.__sync_topics_on_demand = data['sync_topics_on_demand']
         elif rospy.has_param('~sync_topics_on_demand'):
             self.__sync_topics_on_demand = rospy.get_param('~sync_topics_on_demand')
         rospy.loginfo("sync_topics_on_demand: %s", self.__sync_topics_on_demand)
         self.__resync_on_reconnect = rospy.get_param('~resync_on_reconnect', True)
         rospy.loginfo("resync_on_reconnect: %s", self.__resync_on_reconnect)
         self.__resync_on_reconnect_timeout = rospy.get_param('~resync_on_reconnect_timeout', 0)
         rospy.loginfo("resync_on_reconnect_timeout: %s", self.__resync_on_reconnect_timeout)
     except:
         import traceback
         # kill the ros node, to notify the user about the error
         rospy.logerr("Error on load interface: %s", traceback.format_exc())
         import os
         import signal
         os.kill(os.getpid(), signal.SIGKILL)
Ejemplo n.º 2
0
    def accept(self):
        if self.textedit.isVisible():
            try:
                tmp_file = os.path.join(screen.LOG_PATH,
                                        'tmp_sync_interface.sync')
                with open(tmp_file, 'w+') as f:
                    f.write(self.textedit.toPlainText())
                from fkie_master_discovery.common import read_interface
                read_interface(tmp_file)
                if not self._new_iface and self.interface_field.currentText(
                ) in self._interfaces_files:
                    fileName = self._interfaces_files[
                        self.interface_field.currentText()]
                else:
                    fileName, _ = QFileDialog.getSaveFileName(
                        self, 'Save sync interface', '/home',
                        "Sync Files (*.sync)")
                if fileName:
                    with open(fileName, 'w+') as f:
                        self._interface_filename = fileName
                        f.write(self.textedit.toPlainText())
                        if self._new_iface:
                            self.interface_field.clear()
                            self._interfaces_files = None
                        self._on_select_interface_clicked()


#        QDialog.accept(self)
#        self.resetView()
            except Exception as e:
                MessageBox.warning(self, "Create sync interface",
                                   "Error while create interface", utf8(e))
        elif self.interface_field.isVisible():
            interface = self.interface_field.currentText()
            if self._interfaces_files and interface in self._interfaces_files:
                self._interface_filename = self._interfaces_files[interface]
                self._sync_args = []
                self._sync_args.append(''.join(['_interface_url:=',
                                                interface]))
                QDialog.accept(self)
                self.resetView()
        else:
            QDialog.accept(self)
            self.resetView()