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