4 ## Copyright (c) 2010-2017 Intel Corporation
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
10 ## http://www.apache.org/licenses/LICENSE-2.0
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
24 def ssh(user, ip, cmd):
27 ssh_options += "-o StrictHostKeyChecking=no "
28 ssh_options += "-o UserKnownHostsFile=/dev/null "
29 ssh_options += "-o LogLevel=quiet "
30 running = os.popen("ssh " + ssh_options + " " + user + "@" + ip + " \"" + cmd + "\"");
32 ret['out'] = running.read().strip();
33 ret['ret'] = running.close();
34 if (ret['ret'] == None):
39 def ssh_check_quit(obj, user, ip, cmd):
40 ret = ssh(user, ip, cmd);
43 obj._err_str = ret['out'];
47 def __init__(self, user, ip):
51 return ssh(self._user, self._ip, cmd);
52 def run_forked(self, cmd):
53 thread.start_new_thread(ssh, (self._user, self._ip, cmd));
55 def scp(self, src, dst):
56 running = os.popen("scp " + self._user + "@" + self._ip + ":" + src + " " + dst);
57 return running.close();