change setup and versions
This commit is contained in:
parent
cba3f8d2d9
commit
b5d6894865
@ -3,6 +3,8 @@
|
||||
from .core import node,nodes
|
||||
from .configfile import configfile
|
||||
from .connapp import connapp
|
||||
from pkg_resources import get_distribution
|
||||
|
||||
__version__ = "2.0"
|
||||
__all__ = ["node", "nodes", "configfile", "connapp"]
|
||||
__version__ = "2.0.9"
|
||||
__author__ = "Federico Luzzi"
|
||||
|
36
conn/core.py
36
conn/core.py
@ -130,24 +130,21 @@ class node:
|
||||
for c in commands:
|
||||
result = self.child.expect(expects)
|
||||
self.child.sendline(c)
|
||||
match result:
|
||||
case 0:
|
||||
if result == 0:
|
||||
output = output + self.child.before.decode() + self.child.after.decode()
|
||||
case 1:
|
||||
if result == 1:
|
||||
output = output + self.child.before.decode()
|
||||
else:
|
||||
result = self.child.expect(expects)
|
||||
self.child.sendline(commands)
|
||||
match result:
|
||||
case 0:
|
||||
if result == 0:
|
||||
output = output + self.child.before.decode() + self.child.after.decode()
|
||||
case 1:
|
||||
if result == 1:
|
||||
output = output + self.child.before.decode()
|
||||
result = self.child.expect(expects)
|
||||
match result:
|
||||
case 0:
|
||||
if result == 0:
|
||||
output = output + self.child.before.decode() + self.child.after.decode()
|
||||
case 1:
|
||||
if result == 1:
|
||||
output = output + self.child.before.decode()
|
||||
self.child.close()
|
||||
output = output.lstrip()
|
||||
@ -173,10 +170,9 @@ class node:
|
||||
for c in commands:
|
||||
result = self.child.expect(expects)
|
||||
self.child.sendline(c)
|
||||
match result:
|
||||
case 0:
|
||||
if result == 0:
|
||||
output = output + self.child.before.decode() + self.child.after.decode()
|
||||
case 1:
|
||||
if result == 1:
|
||||
output = output + self.child.before.decode()
|
||||
else:
|
||||
self.child.expect(expects)
|
||||
@ -184,15 +180,14 @@ class node:
|
||||
output = output + self.child.before.decode() + self.child.after.decode()
|
||||
expects = [expected, prompt, pexpect.EOF]
|
||||
results = self.child.expect(expects)
|
||||
match results:
|
||||
case 0:
|
||||
if results == 0:
|
||||
self.child.close()
|
||||
self.result = True
|
||||
output = output + self.child.before.decode() + self.child.after.decode()
|
||||
output = output.lstrip()
|
||||
self.output = output
|
||||
return True
|
||||
case 1 | 2:
|
||||
if results in [1, 2]:
|
||||
self.child.close()
|
||||
self.result = False
|
||||
if results == 1:
|
||||
@ -253,8 +248,7 @@ class node:
|
||||
for i in range(0, loops):
|
||||
while True:
|
||||
results = child.expect(expects)
|
||||
match results:
|
||||
case 0:
|
||||
if results == 0:
|
||||
if self.protocol == "ssh":
|
||||
child.sendline('yes')
|
||||
elif self.protocol == "telnet":
|
||||
@ -263,20 +257,20 @@ class node:
|
||||
else:
|
||||
self.missingtext = True
|
||||
break
|
||||
case 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13:
|
||||
if results in [1, 2, 3, 4, 5, 6, 7, 12, 13]:
|
||||
child.close()
|
||||
return "Connection failed code:" + str(results)
|
||||
case 8:
|
||||
if results == 8:
|
||||
if len(passwords) > 0:
|
||||
child.sendline(passwords[i])
|
||||
else:
|
||||
self.missingtext = True
|
||||
break
|
||||
case 9 | 11:
|
||||
if results in [9, 11]:
|
||||
endloop = True
|
||||
child.sendline()
|
||||
break
|
||||
case 10:
|
||||
if results == 10:
|
||||
child.sendline("\r")
|
||||
sleep(2)
|
||||
if endloop:
|
||||
|
30
setup.cfg
Normal file
30
setup.cfg
Normal file
@ -0,0 +1,30 @@
|
||||
[metadata]
|
||||
name = conn
|
||||
version = attr: conn.__version__
|
||||
description = Conn is a SSH/Telnet connection manager and automation module
|
||||
long_description = file: README.md
|
||||
keywords = networking, automation, ssh, telnet, connection manager
|
||||
author = Federico Luzzi
|
||||
author_mail = fluzzi@gmail.com
|
||||
url = https://github.com/fluzzi/connpy
|
||||
license = MIT License
|
||||
license_files = LICENSE
|
||||
classifiers =
|
||||
Development Status :: 4 - Beta
|
||||
Topic :: System :: Networking
|
||||
Intended Audience :: Telecommunications Industry
|
||||
Programming Language :: Python :: 3
|
||||
Natural Language :: English
|
||||
Operating System :: MacOS
|
||||
Operating System :: Unix
|
||||
|
||||
[options]
|
||||
packages = find:
|
||||
install_requires =
|
||||
inquirer
|
||||
pexpect
|
||||
pycryptodome
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
conn = conn.app:main
|
38
setup.py
38
setup.py
@ -1,38 +1,4 @@
|
||||
from setuptools import setup, find_packages
|
||||
import pathlib
|
||||
|
||||
VERSION = '2.0.8'
|
||||
DESCRIPTION = 'Conn is a SSH/Telnet connection manager and automation module'
|
||||
|
||||
here = pathlib.Path(__file__).parent.resolve()
|
||||
LONG_DESCRIPTION = (here / "README.md").read_text(encoding="utf-8")
|
||||
from setuptools import setup
|
||||
|
||||
# Setting up
|
||||
setup(
|
||||
name="conn",
|
||||
version=VERSION,
|
||||
author="Federico Luzzi",
|
||||
author_email="<fluzzi@gmail.com>",
|
||||
description=DESCRIPTION,
|
||||
long_description=LONG_DESCRIPTION,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/fluzzi/connpy",
|
||||
packages=find_packages(),
|
||||
install_requires=["inquirer","pexpect","pycryptodome"], # add any additional packages that
|
||||
keywords=['networking', 'automation', 'ssh', 'telnet', 'connection manager'],
|
||||
classifiers= [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Topic :: System :: Networking",
|
||||
"Intended Audience :: Telecommunications Industry",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Natural Language :: English",
|
||||
# "Operating System :: MacOS :: MacOS X",
|
||||
# "Operating System :: Microsoft :: Windows",
|
||||
"Operating System :: Unix"
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'conn=conn.app:main',
|
||||
]
|
||||
}
|
||||
)
|
||||
setup()
|
||||
|
Loading…
Reference in New Issue
Block a user