Python3 Remote Commands
- PyStorage:
Python3 Remote Commands toolkit
- Copyright:
Copyright (c) 2016 Bruno Costa, Kairo Araujo <coder@marreta.org>
- License:
BSD
- Development:
Installing
Using PIP
Just run the PIP
$ sudo pip install pyrcmd3
From local
Download the pyrcmd3 from PIP or from Marreta Github http://github.com/marreta-sources/pyrcmd3/ and uncompress
$ python setup.py install
Using
At the moment the pyrcmd3 supports commands over SSH.
SSH support
Attributes:
- Address:
IP or Hostname to client server
- User:
User used to connect using ssh
- Passwd:
Password used to connect to ssh
- timeout:
Timeout to Connect (Hostname is valid and has route to host), default value for timeout is 30
Return:
- returns:
Dictionary (Array) with Return Code, Std output and Std Error
Exceptions:
- AuthFailure:
Client to Server Problem with Authentication
- BadHostKey:
Host Key does not match
- SshProtocol:
Problem of SSH2 Negotiation
- TimeOut:
Timeout while trying to connect to a valid address
- TimeoutExecuting:
Timeout while trying to execute command.
Sample:
Simple use:
>>> import pyrcmd3 >>> remote = pyrcmd3.SSH('192.168.0.1', 'foobar', 'Password1') >>> remote_out = remote.execute('ls') >>> print remote_out {'return_code': 0, 'stderr': '', 'stdout': 'total 24\ndrwx------ 3 kairo users 512 Jan 30 11:31 .\ndrwx------ 10 kairo users 512 Jan 30 11:30 ..\n-rw------- 1 kairo users 0 Jan 30 11:30 foobar.txt\ndrwx------ 2 kairo users 512 Jan 30 11:31 marretinha\n'} >>> print remote_out['return_code'] 0 >>> print remote_out['stdout'] total 24 drwx------ 3 kairo users 512 Jan 30 11:31 . drwx------ 10 kairo users 512 Jan 30 11:30 .. -rw------- 1 kairo users 0 Jan 30 11:30 foobar.txt drwx------ 2 kairo users 512 Jan 30 11:31 marretinhaWorking with exceptions
>>> import pyrcmd3 >>> server=pyrcmd3.SSH('localhost', 'foo', 'i dont remember', timeout=10) >>> try: ... server.execute('ls') ... except pyrcmd3.exceptions.TimeoutExecutingException as e: ... print(e) ... Timeout while trying to execute command.
Contributing
Make the for from https://github.com/marreta-sources/pyrcmd3
Change the code
- Test the code
First check all the PEP8 recommendations and possible spells.
Run tests with tox
Create a http://travis-ci.com for your fork and verify the tests
- Submit your code doing a pull request
1. try to give us details about the code. We are newbies with Python and it will be help us.
Metadata
Release files for pyrcmd3 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyrcmd3-0.1.0.tar.gz | 4.9 kB | Details |
Release files / pyrcmd3-0.1.0.tar.gz
| Download URL | pyrcmd3-0.1.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e21e8b9765e3472a64c8d2832a8066484bc367163a35063ce41ee0a52ca517d3
|
|
BLAKE2b-256 checksum How to use checksums |
ce619b3bc459812d5b0002e96f005d69596416e60c3a6539c698a91e9c3a8fdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |