一种基于paramiko的工具,用于连接到远程服务器。

HY-sshapi的Python项目详细描述


哈比

用于与远程(类似于linux)服务器联系的一组API

用法

from SSH_Operation.SSH_Operation import SSH_Operation
ssh = SSH_Operation({})

方法


#══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
# Class:   SSH_Operation
#──────────────────────────
# Author:  Hengyue Li
#──────────────────────────
# Version: 
#          2019/03/16
#                new upload function, to upload dir without compression.   
#          2019/03/09: 
#                1. rebuilt interface of InteractiveConnectionSSH
#                2. change filename to from RemoteContral1
#                3. make a package contains interface.py
#          2019/03/01
#          2018/06/01
#          2018/02/28
#          2017/09/04
#──────────────────────────
# discription:
#          operation between local PC with a remote server
#          remember to call connect or disconnect for some function.
#
#──────────────────────────
# Imported :
#     shutil , tempfile , stat
import paramiko
import shutil,os,tempfile,random
from .interactive import *  
# import SSH_Operation.interactive as interactive
#──────────────────────────
# Interface:
#
#        [ini] SSHDict   ( see details in paramiko )
#
#        [sub] connect()
#              connect to server.
# 
#        [sub] connectIfNotConnected()  
#
#        [sub] disconnect()
#              disconnect to server.
#
#        [fun] IsRemotePathExist(remotepah)
#              check if a remote path is existed or not.
#
#        [fun] IsRemoteDirExisted(remotepah):
#              for a given remote path, check if it is directory and existed.
#
#        [fun] RemoveRemoteDIr(remoeDir):
#              remove remote directory
#
#        [fun] send_commandlist(commandlist)
#              return error
#
#        [sub] upload_file(localfile,remotedestination)
#              if we call self.upload_file( "test.file"   ,   "/here"  )
#              then "test.file" will be renamed to "here" and be put at root ("/").
#              if there is file (the same name as localfile) existed at server, it will be coverd.
#
#        [sub] download_file(remotefile,localdestination)
#              the "remotefile" will be copied and be saved as "localdestination"
#              "remotefile" and "localdestination"  are all files exactly. The same as upload
#
#        [sub] CompressUploadDir(localdirectoy,remotedestination): !!!! linux dependent ("tar" is used)
#              The upload file can only be directory and compression will be used. Faster!
#              usage:
#                    localdirectoy     = "some/path/directory"
#                    remotedestination = "other/path"
#              the directory would be put at:    "other/path/directory"
#
#        [sub] upload_dir(localdirectoy,remotedestination)
#              the same as CompressUploadDir without compression
#
#        [sub] CompressDownloadDir(Remotedirectoy,localdestination): !!!! linux dependent ("zip/unzip" is also used)
#              The download file can only be directory and compression will be used. Faster!
#              usage:
#                    Remotedirectoy   = "some/path/directory"
#                    localdestination = "other/path"
#              the directory would be put at:    "other/path/directory"
#              This function is not well designed. Tempral file will be created in the folder.
#              But it looks working fine.
#
#-------------------------------------------------------------------------------------
#             ||     linux server actions    ||
#-------------------------------------------------------------------------------------
#        [fun] IsUserExist(username):
#              return True of False
#              check if username is exist in remote server.
#
#        [fun] CreatUser(username):
#              return possible errors.
#              1. Maybe only root user can use this command.
#              2. not forget to call IsUserExist to check if it is existed or not!
#
#        [fun] RemoveUser(username):
#              like "CreatUser".
#
#        [fun] GetHomePath():     (make connection before this sub)
#              get the home path of the remote
#
#══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在Eclipse中部署到Tomcat时不包括svn目录的java   java注销在Spring引导应用程序中不起作用(不支持POST方法)   prolog中不允许java“内容”群集服务器中出现错误   如何在java中优化两个for循环(for循环中的for循环)   java onCreateDialog和动态对话框(Android)   java通过Selenium WebDriver接受“共享位置”浏览器弹出窗口   在Java中使用Scala类型(类型不匹配)   Android Studio子目录/包突然找不到R.java?   java正则表达式,用于在上次出现大于符号(>)/任何特殊字符后提取值并删除数字   getThreadAllocatedBytes Java API   按钮如何修复线程“JavaFX应用程序线程”java中的异常。lang.IllegalArgumentException:子项:添加了重复的子项:父项=网格   java如何检查列表中的所有图像是否存储在firebase存储中?   即使一个Springbean初始化失败,java也会继续加载webapp   java接口演化继承的返回类型   解析如何在Java中解析“dateTime.tz”   java如何将xml自定义映射到JAXB中的类   java JWPlayer无效许可证密钥错误代码(100012)   java如何使用reset按钮重置参数   缩小从字节到字符的转换范围   Java manager如何管理内存?