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
51
62
63
74
76 try:
77 import Crypto
78 except ImportError as e:
79 return True
80
82 try:
83 import paramiko
84 except ImportError as e:
85 return True
87 try:
88 import paramiko
89 ssh = paramiko.SSHClient()
90 try:
91 ssh.load_system_host_keys()
92 except:
93 return True
94 except: pass
95
97 try:
98 import paramiko
99 ssh = paramiko.SSHClient()
100
101 import roslaunch.remoteprocess
102 err_msg = roslaunch.remoteprocess.ssh_check_known_hosts(ssh, address, port, username=username)
103 if err_msg:
104 return err_msg
105
106 if not password:
107 ssh.connect(address, port, username)
108 else:
109 ssh.connect(address, port, username, password)
110
111 except paramiko.BadHostKeyException:
112 return "Unable to verify host key for [%s:%s]"%(address, port)
113 except paramiko.AuthenticationException:
114 return "Authentication to [%s:%s] failed"%(address, port)
115 except paramiko.SSHException as e:
116 return "[%s:%s]: %s"%(address, port, e)
117 except ImportError:
118 pass
119
121 config = roslaunch.ROSLaunchConfig()
122 loader = roslaunch.XmlLoader()
123
124 for launch_file in ctx.launch_files:
125 loader.load(launch_file, config, verbose=False)
126 try:
127 config.assign_machines()
128 except roslaunch.RLException as e:
129 return config, []
130 machines = []
131 for n in itertools.chain(config.nodes, config.tests):
132 if n.machine not in machines:
133 machines.append(n.machine)
134 return config, machines
135
137 config = roslaunch.ROSLaunchConfig()
138 loader = roslaunch.XmlLoader()
139
140 for launch_file in ctx.launch_files:
141 loader.load(launch_file, config, verbose=False)
142 try:
143 config.assign_machines()
144 except roslaunch.RLException as e:
145 return str(e)
146
148 config, machines = _load_roslaunch_config(ctx)
149 bad = []
150 for m in machines:
151 try:
152
153 socket.getaddrinfo(m.address, 0, 0, 0, socket.SOL_TCP)
154 except socket.gaierror:
155 bad.append(m.address)
156 return ''.join([' * %s\n'%b for b in bad])
157
159 import roslaunch.core
160 if not ctx.launch_files:
161 return
162 config, machines = _load_roslaunch_config(ctx)
163 err_msgs = []
164 for m in machines:
165 socket.setdefaulttimeout(3.)
166
167 if not roslaunch.core.is_machine_local(m):
168 err_msg = paramiko_ssh(ctx, m.address, m.ssh_port, m.user, m.password)
169 if err_msg:
170 err_msgs.append(err_msg)
171 return err_msgs
172
174
175
176 config, machines = _load_roslaunch_config(ctx)
177 missing = []
178 for n in config.nodes:
179 pkg = n.package
180 try:
181 roslib.packages.get_pkg_dir(pkg, required=True)
182 except:
183 missing.append(pkg)
184 return missing
185
187 config, machines = _load_roslaunch_config(ctx)
188 return config.config_errors
189
191 missing = []
192 for pkg, miss in ctx.launch_file_missing_deps.iteritems():
193 if miss:
194 missing.append("%s/manifest.xml: %s"%(pkg, ', '.join(miss)))
195 return missing
196
198 respawn = []
199 for uri in ctx.roslaunch_uris:
200 try:
201 r = xmlrpclib.ServerProxy(uri)
202 code, msg, val = r.list_processes()
203 active, _ = val
204 respawn.extend([a for a in active if a[1] > 1])
205
206
207 except:
208 pass
209 return ["%s (%s)"%(a[0], a[1]) for a in respawn]
210
212
213 bad = []
214
215 for uri in ctx.roslaunch_uris:
216 try:
217 r = xmlrpclib.ServerProxy(uri)
218 code, msg, val = r.list_children()
219
220 if code == 1:
221 for child_uri in val:
222 try:
223 r = xmlrpclib.ServerProxy(uri)
224 code, msg, val = r.get_pid()
225 except:
226 bad.append(child_uri)
227 except:
228 bad.append(uri)
229 return bad
230
232 dead = []
233 for uri in ctx.roslaunch_uris:
234 try:
235 r = xmlrpclib.ServerProxy(uri)
236 code, msg, val = r.list_processes()
237 _, dead_list = val
238 dead.extend([d[0] for d in dead_list])
239
240
241 except:
242 pass
243 return dead
244
245 online_roslaunch_warnings = [
246 (roslaunch_respawn_check,"These nodes have respawned at least once:"),
247 (roslaunch_dead_check,"These nodes have died:"),
248
249
250 ]
251
252 online_roslaunch_errors = [
253 (roslaunch_ssh_check,"SSH failures:"),
254 ]
255
256 static_roslaunch_warnings = [
257 (roslaunch_duplicate_node_check, "Multiple nodes of same name in packages:"),
258 (pycrypto_check, "pycrypto is not installed"),
259 (paramiko_check, "paramiko is not installed"),
260 (paramiko_system_keys, "cannot load SSH host keys -- your known_hosts file may be corrupt") ,
261 (roslaunch_config_errors, "Loading your launch files reported the following configuration errors:"),
262 ]
263 static_roslaunch_errors = [
264
265
266
267 (roslaunch_missing_pkgs_check,
268 "Cannot find the following required packages:"),
269 (roslaunch_missing_node_check, "Several nodes in your launch file could not be located. These are either typed incorrectly or need to be built:"),
270 (roslaunch_machine_name_check,"Cannot resolve the following hostnames:"),
271 (roslaunch_load_check, "roslaunch load failed"),
272 ]
273
287
290
297