change setup and versions
This commit is contained in:
parent
cba3f8d2d9
commit
b5d6894865
@ -3,6 +3,8 @@
|
|||||||
from .core import node,nodes
|
from .core import node,nodes
|
||||||
from .configfile import configfile
|
from .configfile import configfile
|
||||||
from .connapp import connapp
|
from .connapp import connapp
|
||||||
|
from pkg_resources import get_distribution
|
||||||
|
|
||||||
__version__ = "2.0"
|
|
||||||
__all__ = ["node", "nodes", "configfile", "connapp"]
|
__all__ = ["node", "nodes", "configfile", "connapp"]
|
||||||
|
__version__ = "2.0.9"
|
||||||
|
__author__ = "Federico Luzzi"
|
||||||
|
114
conn/core.py
114
conn/core.py
@ -130,25 +130,22 @@ class node:
|
|||||||
for c in commands:
|
for c in commands:
|
||||||
result = self.child.expect(expects)
|
result = self.child.expect(expects)
|
||||||
self.child.sendline(c)
|
self.child.sendline(c)
|
||||||
match result:
|
if result == 0:
|
||||||
case 0:
|
output = output + self.child.before.decode() + self.child.after.decode()
|
||||||
output = output + self.child.before.decode() + self.child.after.decode()
|
if result == 1:
|
||||||
case 1:
|
output = output + self.child.before.decode()
|
||||||
output = output + self.child.before.decode()
|
|
||||||
else:
|
else:
|
||||||
result = self.child.expect(expects)
|
result = self.child.expect(expects)
|
||||||
self.child.sendline(commands)
|
self.child.sendline(commands)
|
||||||
match result:
|
if result == 0:
|
||||||
case 0:
|
|
||||||
output = output + self.child.before.decode() + self.child.after.decode()
|
|
||||||
case 1:
|
|
||||||
output = output + self.child.before.decode()
|
|
||||||
result = self.child.expect(expects)
|
|
||||||
match result:
|
|
||||||
case 0:
|
|
||||||
output = output + self.child.before.decode() + self.child.after.decode()
|
output = output + self.child.before.decode() + self.child.after.decode()
|
||||||
case 1:
|
if result == 1:
|
||||||
output = output + self.child.before.decode()
|
output = output + self.child.before.decode()
|
||||||
|
result = self.child.expect(expects)
|
||||||
|
if result == 0:
|
||||||
|
output = output + self.child.before.decode() + self.child.after.decode()
|
||||||
|
if result == 1:
|
||||||
|
output = output + self.child.before.decode()
|
||||||
self.child.close()
|
self.child.close()
|
||||||
output = output.lstrip()
|
output = output.lstrip()
|
||||||
if stdout == True:
|
if stdout == True:
|
||||||
@ -173,35 +170,33 @@ class node:
|
|||||||
for c in commands:
|
for c in commands:
|
||||||
result = self.child.expect(expects)
|
result = self.child.expect(expects)
|
||||||
self.child.sendline(c)
|
self.child.sendline(c)
|
||||||
match result:
|
if result == 0:
|
||||||
case 0:
|
output = output + self.child.before.decode() + self.child.after.decode()
|
||||||
output = output + self.child.before.decode() + self.child.after.decode()
|
if result == 1:
|
||||||
case 1:
|
output = output + self.child.before.decode()
|
||||||
output = output + self.child.before.decode()
|
|
||||||
else:
|
else:
|
||||||
self.child.expect(expects)
|
self.child.expect(expects)
|
||||||
self.child.sendline(commands)
|
self.child.sendline(commands)
|
||||||
output = output + self.child.before.decode() + self.child.after.decode()
|
output = output + self.child.before.decode() + self.child.after.decode()
|
||||||
expects = [expected, prompt, pexpect.EOF]
|
expects = [expected, prompt, pexpect.EOF]
|
||||||
results = self.child.expect(expects)
|
results = self.child.expect(expects)
|
||||||
match results:
|
if results == 0:
|
||||||
case 0:
|
self.child.close()
|
||||||
self.child.close()
|
self.result = True
|
||||||
self.result = True
|
output = output + self.child.before.decode() + self.child.after.decode()
|
||||||
|
output = output.lstrip()
|
||||||
|
self.output = output
|
||||||
|
return True
|
||||||
|
if results in [1, 2]:
|
||||||
|
self.child.close()
|
||||||
|
self.result = False
|
||||||
|
if results == 1:
|
||||||
output = output + self.child.before.decode() + self.child.after.decode()
|
output = output + self.child.before.decode() + self.child.after.decode()
|
||||||
output = output.lstrip()
|
elif results == 2:
|
||||||
self.output = output
|
output = output + self.child.before.decode()
|
||||||
return True
|
output = output.lstrip()
|
||||||
case 1 | 2:
|
self.output = output
|
||||||
self.child.close()
|
return False
|
||||||
self.result = False
|
|
||||||
if results == 1:
|
|
||||||
output = output + self.child.before.decode() + self.child.after.decode()
|
|
||||||
elif results == 2:
|
|
||||||
output = output + self.child.before.decode()
|
|
||||||
output = output.lstrip()
|
|
||||||
self.output = output
|
|
||||||
return False
|
|
||||||
else:
|
else:
|
||||||
self.result = None
|
self.result = None
|
||||||
self.output = connect
|
self.output = connect
|
||||||
@ -253,32 +248,31 @@ class node:
|
|||||||
for i in range(0, loops):
|
for i in range(0, loops):
|
||||||
while True:
|
while True:
|
||||||
results = child.expect(expects)
|
results = child.expect(expects)
|
||||||
match results:
|
if results == 0:
|
||||||
case 0:
|
if self.protocol == "ssh":
|
||||||
if self.protocol == "ssh":
|
child.sendline('yes')
|
||||||
child.sendline('yes')
|
elif self.protocol == "telnet":
|
||||||
elif self.protocol == "telnet":
|
if self.user != '':
|
||||||
if self.user != '':
|
child.sendline(self.user)
|
||||||
child.sendline(self.user)
|
|
||||||
else:
|
|
||||||
self.missingtext = True
|
|
||||||
break
|
|
||||||
case 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13:
|
|
||||||
child.close()
|
|
||||||
return "Connection failed code:" + str(results)
|
|
||||||
case 8:
|
|
||||||
if len(passwords) > 0:
|
|
||||||
child.sendline(passwords[i])
|
|
||||||
else:
|
else:
|
||||||
self.missingtext = True
|
self.missingtext = True
|
||||||
break
|
break
|
||||||
case 9 | 11:
|
if results in [1, 2, 3, 4, 5, 6, 7, 12, 13]:
|
||||||
endloop = True
|
child.close()
|
||||||
child.sendline()
|
return "Connection failed code:" + str(results)
|
||||||
break
|
if results == 8:
|
||||||
case 10:
|
if len(passwords) > 0:
|
||||||
child.sendline("\r")
|
child.sendline(passwords[i])
|
||||||
sleep(2)
|
else:
|
||||||
|
self.missingtext = True
|
||||||
|
break
|
||||||
|
if results in [9, 11]:
|
||||||
|
endloop = True
|
||||||
|
child.sendline()
|
||||||
|
break
|
||||||
|
if results == 10:
|
||||||
|
child.sendline("\r")
|
||||||
|
sleep(2)
|
||||||
if endloop:
|
if endloop:
|
||||||
break
|
break
|
||||||
child.readline(0)
|
child.readline(0)
|
||||||
|
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
|
from setuptools import setup
|
||||||
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")
|
|
||||||
|
|
||||||
# Setting up
|
# Setting up
|
||||||
setup(
|
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',
|
|
||||||
]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user