Example #1
0
                    scp_command.sendline(ssh_password)
                    scp_command.read()
            except Exception, e:
                print_string = "ssh scp file error %d:%s" % (x, e)
                print_info.print_info(print_info.PRINT_ERROR, print_string)
            else:
                print_string = "ssh scp file %s to %s ok" % (src_file,
                                                             dst_file)
                print_info.print_info(print_info.PRINT_INFO, print_string)
                return 1
        return 0

    def scp_file_to_dst(self, local_file):
        ret = self.ssh_exec_scp(ssh_user + '@' + ssh_ip + ':' + remote_path,
                                local_path + '/' + local_file)
        return ret

    def scp_file_dst_to_local(self, local_dir):
        ret = self.ssh_exec_scp(
            local_path,
            ssh_user + '@' + ssh_ip + ':' + remote_path + '/' + local_dir)
        return ret


if __name__ == '__main__':
    print_info.init(print_info.PRINT_DEBUG)
    ssh_scp_test = ssh_scp('10.0.70.102', 22, 'apuser', '123456',
                           '/home/local/SPREADTRUM/lc.fan/flc/code/pybz/test',
                           '/home/apuser/Web_Buglist')
    ssh_scp_test.scp_file_to_dst("pybz.zip")
    ssh_scp_test.scp_file_dst_to_local('apply-v4.0')
Example #2
0
    save_file = path + '/' + file_name
    f = open(save_file, 'ab')
    f.write(contents)
    f.close()


def read_line(path, file_name):
    read_file = path + '/' + file_name
    f = open(read_file, 'rb')
    lines = f.readlines()
    f.close()
    return lines


if __name__ == '__main__':
    print_info.init(print_info.PRINT_INFO)
    save_write("/home/local/SPREADTRUM/lc.fan/flc/code/pybz", "test_file", "log_status:0" + '\n')
    file_data = read_data("/home/local/SPREADTRUM/lc.fan/flc/code/pybz", "test_file")
    print_info.print_info(print_info.PRINT_INFO, file_data)
    save_append("/home/local/SPREADTRUM/lc.fan/flc/code/pybz", "test_file", "symbols_status:0:3" + '\n')
    data_list = read_line("/home/local/SPREADTRUM/lc.fan/flc/code/pybz", "test_file")
    for x in data_list:
        if '\n' in x:
            # delete '\n'
            data_list[data_list.index(x)] = x.strip('\n')

    for x in data_list:
        print 'data line % s ' % x
        print_info.print_info(print_info.PRINT_INFO, x)
        if ':' in x:
            cut_data = x.split(':')