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
34
35 import os
36 import itertools
37 import socket
38 import stat
39 import sys
40 import xmlrpclib
41
42 from os.path import isfile, isdir
43
44 import roslib.packages
45 import roslaunch
46 import roslaunch.netapi
47
48 from roswtf.environment import paths, is_executable
49 from roswtf.rules import warning_rule, error_rule
50
52 roslaunch = os.path.join(ctx.ros_root, 'bin', 'roslaunch')
53 if not isfile(roslaunch):
54 return "%(ros_root)s/bin is missing roslaunch"
55 if not is_executable(roslaunch):
56 return "%s is lacking executable permissions"%roslaunch
57
58
59
60
61
63 try:
64 dir = roslib.packages.get_pkg_dir(pkg)
65 except roslib.packages.InvalidROSPkgException:
66
67 return []
68 paths = []
69
70 node_exe = None
71 for p, dirs, files in os.walk(dir):
72 if node_type in files:
73 test_path = os.path.join(p, node_type)
74 s = os.stat(test_path)
75 if (s.st_mode & stat.S_IRWXU == stat.S_IRWXU):
76 paths.append(test_path)
77 if '.svn' in dirs:
78 dirs.remove('.svn')
79 elif '.git' in dirs:
80 dirs.remove('.git')
81 return paths
82
83
94
95
106
108 try:
109 import Crypto
110 except ImportError, e:
111 return True
112
114 try:
115 import paramiko
116 except ImportError, e:
117 return True
119 try:
120 import paramiko
121 ssh = paramiko.SSHClient()
122 try:
123 ssh.load_system_host_keys()
124 except:
125 return True
126 except: pass
127
129 try:
130 import paramiko
131 ssh = paramiko.SSHClient()
132
133 import roslaunch.remoteprocess
134 err_msg = roslaunch.remoteprocess.ssh_check_known_hosts(ssh, address, port, username=username)
135 if err_msg:
136 return err_msg
137
138 if not password:
139 ssh.connect(address, port, username)
140 else:
141 ssh.connect(address, port, username, password)
142
143 except paramiko.BadHostKeyException:
144 return "Unable to verify host key for [%s:%s]"%(address, port)
145 except paramiko.AuthenticationException:
146 return "Authentication to [%s:%s] failed"%(address, port)
147 except paramiko.SSHException, e:
148 return "[%s:%s]: %s"%(address, port, e)
149 except ImportError:
150 pass
151
153 config = roslaunch.ROSLaunchConfig()
154 loader = roslaunch.XmlLoader()
155
156 for launch_file in ctx.launch_files:
157 loader.load(launch_file, config, verbose=False)
158 try:
159 config.validate()
160 config.assign_machines()
161 except roslaunch.RLException, e:
162 return config, []
163 machines = []
164 for n in itertools.chain(config.nodes, config.tests):
165 if n.machine not in machines:
166 machines.append(n.machine)
167 return config, machines
168
170 config = roslaunch.ROSLaunchConfig()
171 loader = roslaunch.XmlLoader()
172
173 for launch_file in ctx.launch_files:
174 loader.load(launch_file, config, verbose=False)
175 try:
176 config.validate()
177 config.assign_machines()
178 except roslaunch.RLException, e:
179 return str(e)
180
182 config, machines = _load_roslaunch_config(ctx)
183 bad = []
184 for m in machines:
185 try:
186 socket.gethostbyname(m.address)
187 except socket.gaierror:
188 bad.append(m.address)
189 return ''.join([' * %s\n'%b for b in bad])
190
192 import roslaunch.core
193 if not ctx.launch_files:
194 return
195 config, machines = _load_roslaunch_config(ctx)
196 err_msgs = []
197 for m in machines:
198 socket.setdefaulttimeout(3.)
199
200 if not roslaunch.core.is_machine_local(m):
201 err_msg = paramiko_ssh(ctx, m.address, m.ssh_port, m.user, m.password)
202 if err_msg:
203 err_msgs.append(err_msg)
204 return err_msgs
205
207
208
209 config, machines = _load_roslaunch_config(ctx)
210 missing = []
211 for n in config.nodes:
212 pkg = n.package
213 try:
214 roslib.packages.get_pkg_dir(pkg, required=True)
215 except:
216 missing.append(pkg)
217 return missing
218
220 config, machines = _load_roslaunch_config(ctx)
221 return config.config_errors
222
224 missing = []
225 for pkg, miss in ctx.launch_file_missing_deps.iteritems():
226 if miss:
227 missing.append("%s/manifest.xml: %s"%(pkg, ', '.join(miss)))
228 return missing
229
231 respawn = []
232 for uri in ctx.roslaunch_uris:
233 try:
234 r = xmlrpclib.ServerProxy(uri)
235 code, msg, val = r.list_processes()
236 active, _ = val
237 respawn.extend([a for a in active if a[1] > 1])
238
239
240 except:
241 pass
242 return ["%s (%s)"%(a[0], a[1]) for a in respawn]
243
245
246 bad = []
247
248 for uri in ctx.roslaunch_uris:
249 try:
250 r = xmlrpclib.ServerProxy(uri)
251 code, msg, val = r.list_children()
252
253 if code == 1:
254 for child_uri in val:
255 try:
256 r = xmlrpclib.ServerProxy(uri)
257 code, msg, val = r.get_pid()
258 except:
259 bad.append(child_uri)
260 except:
261 bad.append(uri)
262 return bad
263
265 dead = []
266 for uri in ctx.roslaunch_uris:
267 try:
268 r = xmlrpclib.ServerProxy(uri)
269 code, msg, val = r.list_processes()
270 _, dead_list = val
271 dead.extend([d[0] for d in dead_list])
272
273
274 except:
275 pass
276 return dead
277
278 online_roslaunch_warnings = [
279 (roslaunch_respawn_check,"These nodes have respawned at least once:"),
280 (roslaunch_dead_check,"These nodes have died:"),
281
282
283 ]
284
285 online_roslaunch_errors = [
286 (roslaunch_ssh_check,"SSH failures:"),
287 ]
288
289 static_roslaunch_warnings = [
290 (roslaunch_duplicate_node_check, "Multiple nodes of same name in packages:"),
291 (pycrypto_check, "pycrypto is not installed"),
292 (paramiko_check, "paramiko is not installed"),
293 (paramiko_system_keys, "cannot load SSH host keys -- your known_hosts file may be corrupt") ,
294 (roslaunch_config_errors, "Loading your launch files reported the following configuration errors:"),
295 ]
296 static_roslaunch_errors = [
297 (bin_roslaunch_check, "roslaunch executable is invalid:"),
298 (roslaunch_missing_deps_check,
299 "Package %(pkg)s is missing roslaunch dependencies.\nPlease add the following tags to %(pkg)s/manifest.xml:"),
300 (roslaunch_missing_pkgs_check,
301 "Cannot find the following required packages:"),
302 (roslaunch_missing_node_check, "Several nodes in your launch file could not be located. These are either typed incorrectly or need to be built:"),
303 (roslaunch_machine_name_check,"Cannot resolve the following hostnames:"),
304 (roslaunch_load_check, "roslaunch load failed"),
305 ]
306
320
323
330