在maxcomputer加入paramiko相关资源包
1 #!/usr/bin/python 2 # -*- coding: UTF-8 -*- 3 4 ##@resource_reference{"six.zip"} 5 ##@resource_reference{"PyNaCl-1.4.0.zip"} 6 ##@resource_reference{"paramiko-2.7.2.zip"} 7 ##@resource_reference{"ipaddress-1.0.23.zip"} 8 ##@resource_reference{"enum34.zip"} 9 ##@resource_reference{"cryptography.zip"} 10 ##@resource_reference{"cffi-1.14.3-mu.zip"} 11 ##@resource_reference{"bcrypt-3.1.4.zip"} 12 13 import requests 14 import time 15 import base64 16 import hashlib 17 import httplib 18 import json 19 import sys 20 reload(sys) 21 sys.setdefaultencoding('utf-8') 22 import csv 23 import os 24 from odps import ODPS 25 from odps import options 26 from odps.df import DataFrame 27 import time 28 import datetime 29 from Crypto.Cipher import AES 30 31 options.tunnel.use_instance_tunnel =True 32 33 filename = os.path.abspath('six.zip') 34 pathname = os.path.dirname(os.path.abspath('six.zip')) 35 os.system('unzip six.zip -d ' + pathname) 36 os.system('unzip PyNaCl-1.4.0.zip -d ' + pathname) 37 os.system('unzip paramiko-2.7.2.zip -d ' + pathname) 38 os.system('unzip ipaddress-1.0.23.zip -d ' + pathname) 39 os.system('unzip enum34.zip -d ' + pathname) 40 os.system('unzip cryptography.zip -d ' + pathname) 41 os.system('unzip cffi-1.14.3-mu.zip -d ' + pathname) 42 os.system('unzip bcrypt-3.1.4.zip -d ' + pathname) 43 sys.path.append(pathname) 44 import ipaddress #在这里引用 45 import paramiko 46 47 #ftp服务器信息(自己填写) 48 ip = '' 49 port = '' 50 username = '' 51 password='' 52 config_dict={"ip":ip,"port":port,"username":username,"password":password} #保存参数 53 54 ssh = paramiko.SSHClient() 55 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 56 ssh.connect(config_dict['ip'],port=config_dict['port'], username=config_dict['username'], password=config_dict['password']) 57 file_name='/home/dcos/IDSDATA/riskcon.txt.Z1' 58 file_flag=True 59 60 stdin, stdout, stderr = ssh.exec_command('test -e '+file_name+' && echo "File exists" || echo "File does not exist"') #执行 61 output = stdout.read().decode() #获取服务器结果 62 63 while file_flag: 64 sftp = ssh.open_sftp() 65 try: 66 print(sftp.stat(file_name)) 67 print('file exists') 68 break 69 except IOError: 70 print('file not exists') 71 time.sleep(10) 72 ssh.close()
标签:resource,unzip,Pyodps2,zip,pathname,linux,import,os,paramiko From: https://www.cnblogs.com/zhongxuzhi/p/18291629