1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 import os
34 import roslib
35
36 from common import get_ros_home, masteruri_from_ros
39
40 USER_DEFAULT = 'robot'
41
42
43 PKG_NAME = 'node_manager_fkie'
44 PACKAGE_DIR = roslib.packages.get_pkg_dir(PKG_NAME)
45 ROBOTS_DIR = os.path.join(PACKAGE_DIR, 'images')
46 CFG_PATH = os.path.join('.node_manager', os.sep)
47 '''@ivar: configuration path to store the history.'''
48 HELP_FILE = os.path.join(PACKAGE_DIR, 'README.rst')
49 CURRENT_DIALOG_PATH = os.path.expanduser('~')
50 LOG_PATH = os.environ.get('ROS_LOG_DIR') if os.environ.get('ROS_LOG_DIR') else os.path.join(os.path.expanduser('~'), '.ros/log/')
51
52 LOG_VIEWER = "/usr/bin/less -fKLnQrSU"
53 STARTER_SCRIPT = 'rosrun node_manager_fkie remote_nm.py'
54 RESPAWN_SCRIPT = 'rosrun node_manager_fkie respawn'
55 '''
56 the script used on remote hosts to start new ROS nodes
57 '''
58
59 LAUNCH_HISTORY_FILE = 'launch.history'
60 LAUNCH_HISTORY_LENGTH = 5
61
62 PARAM_HISTORY_FILE = 'param.history'
63 PARAM_HISTORY_LENGTH = 12
64
65 CFG_REDIRECT_FILE = 'redirect'
66 CFG_FILE = 'settings.ini'
67 CFG_GUI_FILE = 'settings.ini'
68
69 TIMEOUT_CONTROL = 5
70 TIMEOUT_UPDATES = 20
71
72 SEARCH_IN_EXT = ['.launch', '.yaml', '.conf', '.cfg', '.iface', '.sync', '.test', '.xml']
73 LAUNCH_VIEW_EXT = ['.yaml', '.conf', '.cfg', '.iface', '.sync', '.test']
74
75 STORE_GEOMETRY = True
76
79
114
116 return self._masteruri
117
118 @property
120 return self._cfg_path
121
122 @cfg_path.setter
137
138 @property
140 return self._robots_path
141
142 @robots_path.setter
144 if path:
145 if not os.path.isdir(path):
146 os.makedirs(path)
147 self._robots_path = path
148 settings = self.qsettings(self.CFG_FILE)
149 settings.setValue('robots_path', self._robots_path)
150
151 @property
153 return self._default_user
154
155 @default_user.setter
161
162 @property
164 return self._launch_history_length
165
166 @launch_history_length.setter
168 self._launch_history_length = len
169 settings = self.qsettings(self.CFG_FILE)
170 settings.setValue('launch_history_length', self._launch_history_length)
171
172 @property
174 return self._param_history_length
175
176 @param_history_length.setter
177 - def param_history_length(self, len):
178 self._param_history_length = len
179 settings = self.qsettings(self.CFG_FILE)
180 settings.setValue('param_history_length', self._param_history_length)
181
182 @property
184 return self._current_dialog_path
185
186 @current_dialog_path.setter
188 self._current_dialog_path = path
189
191 return os.path.join(self.ROBOTS_DIR, '%s.png'%robot_name)
192
193 @property
195 return self._log_viewer
196
197 @log_viewer.setter
199 self._log_viewer = viewer
200
201 @property
203 return self._start_remote_script
204
205 @start_remote_script.setter
207 self._start_remote_script = script
208
209 @property
211 return self._respawn_script
212
213 @respawn_script.setter
215 self._respawn_script = script
216
217 @property
219 return self._launch_view_file_ext
220
221 @launch_view_file_ext.setter
227
228 @property
230 return self._store_geometry
231
232 @store_geometry.setter
239
241 if isinstance(v, bool):
242 return v
243 return v.lower() in ("yes", "true", "t", "1")
244
246 if isinstance(l, list):
247 return l
248 try:
249 l = l.strip('[]')
250 l = l.replace('u"', '')
251 l = l.replace('"', '')
252 l = l.replace("'", '')
253 l = l.replace(",", ' ')
254 return [str(i).strip() for i in l.split(' ') if i]
255 except:
256 return []
257
259 '''
260 Creates a command string to run with a terminal prefix
261 @param cmd: the list with a command and args
262 @type cmd: [str,..]
263 @param title: the title of the terminal
264 @type title: str
265 @return: command with a terminal prefix
266 @rtype: str
267 '''
268 if self._terminal_emulator is None:
269 self._terminal_emulator = ""
270 for t in ['/usr/bin/x-terminal-emulator', '/usr/bin/xterm']:
271 if os.path.isfile(t) and os.access(t, os.X_OK):
272 self._terminal_emulator = t
273 break
274 if self._terminal_emulator == "": return ""
275 return "%s -T %s -e %s"%(self._terminal_emulator, title, ' '.join(cmd))
276
278 from python_qt_binding import QtCore
279 path = file
280 if not file.startswith(os.path.sep):
281 path = os.path.join(self.cfg_path, file)
282 return QtCore.QSettings(path,
283 QtCore.QSettings.IniFormat)
284