A tool based on paramiko used to connect to remote server.
Project description
HY_sshapi
A set of APIs used to contact with a remote (linux-like) server.
Usage
from SSH_Operation.SSH_Operation import SSH_Operation
ssh = SSH_Operation({})
Methods
#══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
# 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
#
#══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file HY_sshapi-2019.3.26.1057.tar.gz
.
File metadata
- Download URL: HY_sshapi-2019.3.26.1057.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b30a16c64c0e925cd8e0344c76f0433c34c617372aed7d50a70c1db9fd925ee0 |
|
MD5 | 79889009a75709ac6440535cf3ee3ac3 |
|
BLAKE2b-256 | 1c9225fec92874801173afa4185b258e13cf65396ebee3df9b6fe04899e9585a |