send commands into system terminal
Project description
cli_user (current v0.1.3/
)
DESCRIPTION_SHORT
send commands into system terminal
DESCRIPTION_LONG
Designed to send commands into OS terminal
Features
- send commands into OS terminal
- check if cli commands are accessible (special utilities is installed)
- access to standard parts of result in a simple ready-to-use form (stdout/stderr/retcode/full state)
- use batch timeout for list
- till_first_true
- counter/counter_in_list
License
See the LICENSE file for license rights and limitations (MIT).
Release history
See the HISTORY.md file for release history.
Installation
pip install cli-user
Import
from cli_user import *
USAGE EXAMPLES
See tests, sourcecode and docstrings for other examples.
1. example1.py
from cli_user import *
print()
print()
print()
print()
victim = CliUser()
victim.send("ping localhost", timeout=0.1)
print()
# victim.print_state()
"""
[CLI_SEND] [ping localhost]
....
==================================================
[#####################ERROR#####################]
self.counter=1
self.counter_in_list=0
self.last_cmd='ping localhost'
self.last_duration=1.041
self.last_finished=True
self.last_finished_success=False
self.last_retcode=None
--------------------------------------------------
self.last_stdout=
|''
|'Обмен пакетами с starichenko.corp.element-t.ru [::1] с 32 байтами данных:'
|'Ответ от ::1: время<1мс '
|'Ответ от ::1: время<1мс '
|''
--------------------------------------------------
self.last_stderr=
--------------------------------------------------
self.last_exx_timeout=Exx_CliTimeout()
==================================================
"""
print()
print()
print()
print()
victim.send(["python --version", ("ping localhost", 0.1), ])
"""
[CLI_SEND] [python --version]
.
[CLI_SEND] [('ping localhost', 0.1)]
....
==================================================
[#####################ERROR#####################]
self.counter=3
self.counter_in_list=2
self.last_cmd='ping localhost'
self.last_duration=1.042
self.last_finished=True
self.last_finished_success=False
self.last_retcode=None
--------------------------------------------------
self.last_stdout=
|''
|'Обмен пакетами с starichenko.corp.element-t.ru [::1] с 32 байтами данных:'
|'Ответ от ::1: время<1мс '
|'Ответ от ::1: время<1мс '
|''
--------------------------------------------------
self.last_stderr=
--------------------------------------------------
self.last_exx_timeout=Exx_CliTimeout()
==================================================
[ERROR] cmd_item=('ping localhost', 0.1) in full sequence cmd=['python --version', ('ping localhost', 0.1)]
"""
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
cli_user-0.1.3.tar.gz
(8.2 kB
view hashes)