最小入侵网格(MIG)实用程序库
mig-utils的Python项目详细描述
最小入侵网格(MiG)实用程序python库: 它包括mig.io模块,该模块通过 为sshfs包装(https://github.com/althonos/fs.sshfs)的python sftp的连接和(https://github.com/ParallelSSH/ssh2-python.git) 这是默认和推荐的连接
安装
从pypi安装
pip install mig-utils
从本地git存储库安装
cd mig-utils
pip install .
IO示例
ERDA(https://erda.dk)共享链接访问python3示例。 对于IDMC(https://idmc.dk)
也存在同样的Syrink类(IDMCStand)。# First import the class that gives you access to the share in question*frommig.ioimportERDAShare,IDMCShare# ERDA Sharelink exampleprint("ERDA")# Open connection to a sharelinkerda_share=ERDAShare('SHARELINKID')# List files/dirs in shareprint(erda_share.list())witherda_share.open('tmp','w')astmp:tmp.write("sdfsfsf")# Get a _io.SFTPFileHandle object with automatic closewitherda_share.open('tmp','r')astmp:print(tmp.read())# Get a default _io.SFTPFileHandle object with manual lifetimefile=erda_share.open('tmp','r')print(file.read())file.close()# remove fileerda_share.remove('tmp')print("\n")# IDMC Sharelink exampleprint("IDMC")# Open connection to a sharelinkidmc_share=IDMCShare('SHARELINKID')# List files/dirs in shareprint(idmc_share.list())# write binary stringwithidmc_share.open('b_tmp','wb')asb_tmp:b_tmp.write(b'sadasdasd')# Get a _io.SFTPFileHandle object with automatic closewithidmc_share.open('b_tmp','rb')astmp:print(tmp.read())# Get a default _io.TextIOWrapper object with manual lifetimefile=idmc_share.open('b_tmp','rb')print(file.read())file.close()