add sftp option

This commit is contained in:
Federico Luzzi 2023-11-03 11:59:00 -03:00
parent 97c039459c
commit a3d0e39ba8
6 changed files with 49 additions and 32 deletions

View File

@ -105,7 +105,7 @@ print(result)
### Usage: ### Usage:
``` ```
usage: conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] usage: conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] [--sftp]
conn {profile,move,mv,copy,cp,list,ls,bulk,config} ... conn {profile,move,mv,copy,cp,list,ls,bulk,config} ...
positional arguments: positional arguments:
@ -124,6 +124,7 @@ positional arguments:
-e, --mod, --edit Modify node[@subfolder][@folder] -e, --mod, --edit Modify node[@subfolder][@folder]
-s, --show Show node[@subfolder][@folder] -s, --show Show node[@subfolder][@folder]
-d, --debug Display all conections steps -d, --debug Display all conections steps
-t, --sftp Connects using sftp instead of ssh
``` ```
### Commands: ### Commands:

View File

@ -16,7 +16,7 @@ Connpy is a connection manager that allows you to store nodes to connect them fa
### Usage ### Usage
``` ```
usage: conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] usage: conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] [--sftp]
conn {profile,move,mv,copy,cp,list,ls,bulk,config} ... conn {profile,move,mv,copy,cp,list,ls,bulk,config} ...
positional arguments: positional arguments:
@ -32,6 +32,7 @@ Options:
-e, --mod, --edit Modify node[@subfolder][@folder] -e, --mod, --edit Modify node[@subfolder][@folder]
-s, --show Show node[@subfolder][@folder] -s, --show Show node[@subfolder][@folder]
-d, --debug Display all conections steps -d, --debug Display all conections steps
-t, --sftp Connects using sftp instead of ssh
Commands: Commands:
profile Manage profiles profile Manage profiles

View File

@ -1,2 +1,2 @@
__version__ = "3.6.1" __version__ = "3.6.2"

View File

@ -78,7 +78,8 @@ class connapp:
nodecrud.add_argument("-r","--del", "--rm", dest="action", action="store_const", help="Delete node[@subfolder][@folder] or [@subfolder]@folder", const="del", default="connect") nodecrud.add_argument("-r","--del", "--rm", dest="action", action="store_const", help="Delete node[@subfolder][@folder] or [@subfolder]@folder", const="del", default="connect")
nodecrud.add_argument("-e","--mod", "--edit", dest="action", action="store_const", help="Modify node[@subfolder][@folder]", const="mod", default="connect") nodecrud.add_argument("-e","--mod", "--edit", dest="action", action="store_const", help="Modify node[@subfolder][@folder]", const="mod", default="connect")
nodecrud.add_argument("-s","--show", dest="action", action="store_const", help="Show node[@subfolder][@folder]", const="show", default="connect") nodecrud.add_argument("-s","--show", dest="action", action="store_const", help="Show node[@subfolder][@folder]", const="show", default="connect")
nodecrud.add_argument("-d","--debug", dest="action", action="store_const", help="Display all conections steps", const="debug", default="connect") nodecrud.add_argument("-d","--debug", dest="debug", action="store_true", help="Display all conections steps")
nodeparser.add_argument("-t","--sftp", dest="sftp", action="store_true", help="Connects using sftp instead of ssh")
nodeparser.set_defaults(func=self._func_node) nodeparser.set_defaults(func=self._func_node)
#PROFILEPARSER #PROFILEPARSER
profileparser = subparsers.add_parser("profile", help="Manage profiles") profileparser = subparsers.add_parser("profile", help="Manage profiles")
@ -169,7 +170,7 @@ class connapp:
#Function called when connecting or managing nodes. #Function called when connecting or managing nodes.
if not self.case and args.data != None: if not self.case and args.data != None:
args.data = args.data.lower() args.data = args.data.lower()
actions = {"version": self._version, "connect": self._connect, "debug": self._connect, "add": self._add, "del": self._del, "mod": self._mod, "show": self._show} actions = {"version": self._version, "connect": self._connect, "add": self._add, "del": self._del, "mod": self._mod, "show": self._show}
return actions.get(args.action)(args) return actions.get(args.action)(args)
def _version(self, args): def _version(self, args):
@ -196,7 +197,9 @@ class connapp:
exit(7) exit(7)
node = self.config.getitem(matches[0]) node = self.config.getitem(matches[0])
node = self.node(matches[0],**node, config = self.config) node = self.node(matches[0],**node, config = self.config)
if args.action == "debug": if args.sftp:
node.protocol = "sftp"
if args.debug:
node.interact(debug = True) node.interact(debug = True)
else: else:
node.interact() node.interact()
@ -1212,7 +1215,7 @@ class connapp:
if type == "node": if type == "node":
return "node[@subfolder][@folder]\nConnect to specific node or show all matching nodes\n[@subfolder][@folder]\nShow all available connections globaly or in specified path" return "node[@subfolder][@folder]\nConnect to specific node or show all matching nodes\n[@subfolder][@folder]\nShow all available connections globaly or in specified path"
if type == "usage": if type == "usage":
return "conn [-h] [--add | --del | --mod | --show | --debug] [node|folder]\n conn {profile,move,mv,copy,cp,list,ls,bulk,config} ..." return "conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] [--sftp]\n conn {profile,move,mv,copy,cp,list,ls,bulk,config} ..."
if type == "end": if type == "end":
return "Commands:\n profile Manage profiles\n move (mv) Move node\n copy (cp) Copy node\n list (ls) List profiles, nodes or folders\n bulk Add nodes in bulk\n export Export connection folder to Yaml file\n import Import connection folder to config from Yaml file\n run Run scripts or commands on nodes\n config Manage app config\n api Start and stop connpy api\n ai Make request to an AI" return "Commands:\n profile Manage profiles\n move (mv) Move node\n copy (cp) Copy node\n list (ls) List profiles, nodes or folders\n bulk Add nodes in bulk\n export Export connection folder to Yaml file\n import Import connection folder to config from Yaml file\n run Run scripts or commands on nodes\n config Manage app config\n api Start and stop connpy api\n ai Make request to an AI"
if type == "bashcompletion": if type == "bashcompletion":

View File

@ -418,16 +418,15 @@ class node:
def _connect(self, debug = False, timeout = 10, max_attempts = 3): def _connect(self, debug = False, timeout = 10, max_attempts = 3):
# Method to connect to the node, it parse all the information, create the ssh/telnet command and login to the node. # Method to connect to the node, it parse all the information, create the ssh/telnet command and login to the node.
if self.protocol == "ssh": if self.protocol in ["ssh", "sftp"]:
cmd = "ssh" cmd = self.protocol
if self.idletime > 0: if self.idletime > 0:
cmd = cmd + " -o ServerAliveInterval=" + str(self.idletime) cmd = cmd + " -o ServerAliveInterval=" + str(self.idletime)
if self.user == '':
cmd = cmd + " {}".format(self.host)
else:
cmd = cmd + " {}".format("@".join([self.user,self.host]))
if self.port != '': if self.port != '':
if self.protocol == "ssh":
cmd = cmd + " -p " + self.port cmd = cmd + " -p " + self.port
elif self.protocol == "sftp":
cmd = cmd + " -P " + self.port
if self.options != '': if self.options != '':
cmd = cmd + " " + self.options cmd = cmd + " " + self.options
if self.logs != '': if self.logs != '':
@ -436,6 +435,10 @@ class node:
passwords = self._passtx(self.password) passwords = self._passtx(self.password)
else: else:
passwords = [] passwords = []
if self.user == '':
cmd = cmd + " {}".format(self.host)
else:
cmd = cmd + " {}".format("@".join([self.user,self.host]))
expects = ['yes/no', 'refused', 'supported', 'cipher', 'ssh-keygen.*\"', 'timeout|timed.out', 'unavailable', 'closed', '[p|P]assword:|[u|U]sername:', r'>$|#$|\$$|>.$|#.$|\$.$', 'suspend', pexpect.EOF, pexpect.TIMEOUT, "No route to host", "resolve hostname", "no matching"] expects = ['yes/no', 'refused', 'supported', 'cipher', 'ssh-keygen.*\"', 'timeout|timed.out', 'unavailable', 'closed', '[p|P]assword:|[u|U]sername:', r'>$|#$|\$$|>.$|#.$|\$.$', 'suspend', pexpect.EOF, pexpect.TIMEOUT, "No route to host", "resolve hostname", "no matching"]
elif self.protocol == "telnet": elif self.protocol == "telnet":
cmd = "telnet " + self.host cmd = "telnet " + self.host
@ -468,7 +471,7 @@ class node:
while True: while True:
results = child.expect(expects, timeout=timeout) results = child.expect(expects, timeout=timeout)
if results == 0: if results == 0:
if self.protocol == "ssh": if self.protocol in ["ssh", "sftp"]:
child.sendline('yes') child.sendline('yes')
elif self.protocol == "telnet": elif self.protocol == "telnet":
if self.user != '': if self.user != '':
@ -487,7 +490,7 @@ class node:
after = "Connection timeout" after = "Connection timeout"
else: else:
after = child.after.decode() after = child.after.decode()
return ("Connection failed code:" + str(results) + "\n" + child.before.decode() + after + child.readline().decode()).rstrip() return ("Connection failed code:" + str(results) + "\n" + child.before.decode().lstrip() + after + child.readline().decode()).rstrip()
if results == 8: if results == 8:
if len(passwords) > 0: if len(passwords) > 0:
child.sendline(passwords[i]) child.sendline(passwords[i])

View File

@ -35,7 +35,7 @@
- Much more! - Much more!
</code></pre> </code></pre>
<h3 id="usage">Usage</h3> <h3 id="usage">Usage</h3>
<pre><code>usage: conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] <pre><code>usage: conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] [--sftp]
conn {profile,move,mv,copy,cp,list,ls,bulk,config} ... conn {profile,move,mv,copy,cp,list,ls,bulk,config} ...
positional arguments: positional arguments:
@ -51,6 +51,7 @@ Options:
-e, --mod, --edit Modify node[@subfolder][@folder] -e, --mod, --edit Modify node[@subfolder][@folder]
-s, --show Show node[@subfolder][@folder] -s, --show Show node[@subfolder][@folder]
-d, --debug Display all conections steps -d, --debug Display all conections steps
-t, --sftp Connects using sftp instead of ssh
Commands: Commands:
profile Manage profiles profile Manage profiles
@ -269,7 +270,7 @@ Connpy is a connection manager that allows you to store nodes to connect them fa
### Usage ### Usage
``` ```
usage: conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] usage: conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] [--sftp]
conn {profile,move,mv,copy,cp,list,ls,bulk,config} ... conn {profile,move,mv,copy,cp,list,ls,bulk,config} ...
positional arguments: positional arguments:
@ -285,6 +286,7 @@ Options:
-e, --mod, --edit Modify node[@subfolder][@folder] -e, --mod, --edit Modify node[@subfolder][@folder]
-s, --show Show node[@subfolder][@folder] -s, --show Show node[@subfolder][@folder]
-d, --debug Display all conections steps -d, --debug Display all conections steps
-t, --sftp Connects using sftp instead of ssh
Commands: Commands:
profile Manage profiles profile Manage profiles
@ -1869,7 +1871,8 @@ Categorize the user&#39;s request based on the operation they want to perform on
nodecrud.add_argument(&#34;-r&#34;,&#34;--del&#34;, &#34;--rm&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Delete node[@subfolder][@folder] or [@subfolder]@folder&#34;, const=&#34;del&#34;, default=&#34;connect&#34;) nodecrud.add_argument(&#34;-r&#34;,&#34;--del&#34;, &#34;--rm&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Delete node[@subfolder][@folder] or [@subfolder]@folder&#34;, const=&#34;del&#34;, default=&#34;connect&#34;)
nodecrud.add_argument(&#34;-e&#34;,&#34;--mod&#34;, &#34;--edit&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Modify node[@subfolder][@folder]&#34;, const=&#34;mod&#34;, default=&#34;connect&#34;) nodecrud.add_argument(&#34;-e&#34;,&#34;--mod&#34;, &#34;--edit&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Modify node[@subfolder][@folder]&#34;, const=&#34;mod&#34;, default=&#34;connect&#34;)
nodecrud.add_argument(&#34;-s&#34;,&#34;--show&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Show node[@subfolder][@folder]&#34;, const=&#34;show&#34;, default=&#34;connect&#34;) nodecrud.add_argument(&#34;-s&#34;,&#34;--show&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Show node[@subfolder][@folder]&#34;, const=&#34;show&#34;, default=&#34;connect&#34;)
nodecrud.add_argument(&#34;-d&#34;,&#34;--debug&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Display all conections steps&#34;, const=&#34;debug&#34;, default=&#34;connect&#34;) nodecrud.add_argument(&#34;-d&#34;,&#34;--debug&#34;, dest=&#34;debug&#34;, action=&#34;store_true&#34;, help=&#34;Display all conections steps&#34;)
nodeparser.add_argument(&#34;-t&#34;,&#34;--sftp&#34;, dest=&#34;sftp&#34;, action=&#34;store_true&#34;, help=&#34;Connects using sftp instead of ssh&#34;)
nodeparser.set_defaults(func=self._func_node) nodeparser.set_defaults(func=self._func_node)
#PROFILEPARSER #PROFILEPARSER
profileparser = subparsers.add_parser(&#34;profile&#34;, help=&#34;Manage profiles&#34;) profileparser = subparsers.add_parser(&#34;profile&#34;, help=&#34;Manage profiles&#34;)
@ -1960,7 +1963,7 @@ Categorize the user&#39;s request based on the operation they want to perform on
#Function called when connecting or managing nodes. #Function called when connecting or managing nodes.
if not self.case and args.data != None: if not self.case and args.data != None:
args.data = args.data.lower() args.data = args.data.lower()
actions = {&#34;version&#34;: self._version, &#34;connect&#34;: self._connect, &#34;debug&#34;: self._connect, &#34;add&#34;: self._add, &#34;del&#34;: self._del, &#34;mod&#34;: self._mod, &#34;show&#34;: self._show} actions = {&#34;version&#34;: self._version, &#34;connect&#34;: self._connect, &#34;add&#34;: self._add, &#34;del&#34;: self._del, &#34;mod&#34;: self._mod, &#34;show&#34;: self._show}
return actions.get(args.action)(args) return actions.get(args.action)(args)
def _version(self, args): def _version(self, args):
@ -1987,7 +1990,9 @@ Categorize the user&#39;s request based on the operation they want to perform on
exit(7) exit(7)
node = self.config.getitem(matches[0]) node = self.config.getitem(matches[0])
node = self.node(matches[0],**node, config = self.config) node = self.node(matches[0],**node, config = self.config)
if args.action == &#34;debug&#34;: if args.sftp:
node.protocol = &#34;sftp&#34;
if args.debug:
node.interact(debug = True) node.interact(debug = True)
else: else:
node.interact() node.interact()
@ -3003,7 +3008,7 @@ Categorize the user&#39;s request based on the operation they want to perform on
if type == &#34;node&#34;: if type == &#34;node&#34;:
return &#34;node[@subfolder][@folder]\nConnect to specific node or show all matching nodes\n[@subfolder][@folder]\nShow all available connections globaly or in specified path&#34; return &#34;node[@subfolder][@folder]\nConnect to specific node or show all matching nodes\n[@subfolder][@folder]\nShow all available connections globaly or in specified path&#34;
if type == &#34;usage&#34;: if type == &#34;usage&#34;:
return &#34;conn [-h] [--add | --del | --mod | --show | --debug] [node|folder]\n conn {profile,move,mv,copy,cp,list,ls,bulk,config} ...&#34; return &#34;conn [-h] [--add | --del | --mod | --show | --debug] [node|folder] [--sftp]\n conn {profile,move,mv,copy,cp,list,ls,bulk,config} ...&#34;
if type == &#34;end&#34;: if type == &#34;end&#34;:
return &#34;Commands:\n profile Manage profiles\n move (mv) Move node\n copy (cp) Copy node\n list (ls) List profiles, nodes or folders\n bulk Add nodes in bulk\n export Export connection folder to Yaml file\n import Import connection folder to config from Yaml file\n run Run scripts or commands on nodes\n config Manage app config\n api Start and stop connpy api\n ai Make request to an AI&#34; return &#34;Commands:\n profile Manage profiles\n move (mv) Move node\n copy (cp) Copy node\n list (ls) List profiles, nodes or folders\n bulk Add nodes in bulk\n export Export connection folder to Yaml file\n import Import connection folder to config from Yaml file\n run Run scripts or commands on nodes\n config Manage app config\n api Start and stop connpy api\n ai Make request to an AI&#34;
if type == &#34;bashcompletion&#34;: if type == &#34;bashcompletion&#34;:
@ -3235,7 +3240,8 @@ tasks:
nodecrud.add_argument(&#34;-r&#34;,&#34;--del&#34;, &#34;--rm&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Delete node[@subfolder][@folder] or [@subfolder]@folder&#34;, const=&#34;del&#34;, default=&#34;connect&#34;) nodecrud.add_argument(&#34;-r&#34;,&#34;--del&#34;, &#34;--rm&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Delete node[@subfolder][@folder] or [@subfolder]@folder&#34;, const=&#34;del&#34;, default=&#34;connect&#34;)
nodecrud.add_argument(&#34;-e&#34;,&#34;--mod&#34;, &#34;--edit&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Modify node[@subfolder][@folder]&#34;, const=&#34;mod&#34;, default=&#34;connect&#34;) nodecrud.add_argument(&#34;-e&#34;,&#34;--mod&#34;, &#34;--edit&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Modify node[@subfolder][@folder]&#34;, const=&#34;mod&#34;, default=&#34;connect&#34;)
nodecrud.add_argument(&#34;-s&#34;,&#34;--show&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Show node[@subfolder][@folder]&#34;, const=&#34;show&#34;, default=&#34;connect&#34;) nodecrud.add_argument(&#34;-s&#34;,&#34;--show&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Show node[@subfolder][@folder]&#34;, const=&#34;show&#34;, default=&#34;connect&#34;)
nodecrud.add_argument(&#34;-d&#34;,&#34;--debug&#34;, dest=&#34;action&#34;, action=&#34;store_const&#34;, help=&#34;Display all conections steps&#34;, const=&#34;debug&#34;, default=&#34;connect&#34;) nodecrud.add_argument(&#34;-d&#34;,&#34;--debug&#34;, dest=&#34;debug&#34;, action=&#34;store_true&#34;, help=&#34;Display all conections steps&#34;)
nodeparser.add_argument(&#34;-t&#34;,&#34;--sftp&#34;, dest=&#34;sftp&#34;, action=&#34;store_true&#34;, help=&#34;Connects using sftp instead of ssh&#34;)
nodeparser.set_defaults(func=self._func_node) nodeparser.set_defaults(func=self._func_node)
#PROFILEPARSER #PROFILEPARSER
profileparser = subparsers.add_parser(&#34;profile&#34;, help=&#34;Manage profiles&#34;) profileparser = subparsers.add_parser(&#34;profile&#34;, help=&#34;Manage profiles&#34;)
@ -3770,16 +3776,15 @@ tasks:
def _connect(self, debug = False, timeout = 10, max_attempts = 3): def _connect(self, debug = False, timeout = 10, max_attempts = 3):
# Method to connect to the node, it parse all the information, create the ssh/telnet command and login to the node. # Method to connect to the node, it parse all the information, create the ssh/telnet command and login to the node.
if self.protocol == &#34;ssh&#34;: if self.protocol in [&#34;ssh&#34;, &#34;sftp&#34;]:
cmd = &#34;ssh&#34; cmd = self.protocol
if self.idletime &gt; 0: if self.idletime &gt; 0:
cmd = cmd + &#34; -o ServerAliveInterval=&#34; + str(self.idletime) cmd = cmd + &#34; -o ServerAliveInterval=&#34; + str(self.idletime)
if self.user == &#39;&#39;:
cmd = cmd + &#34; {}&#34;.format(self.host)
else:
cmd = cmd + &#34; {}&#34;.format(&#34;@&#34;.join([self.user,self.host]))
if self.port != &#39;&#39;: if self.port != &#39;&#39;:
if self.protocol == &#34;ssh&#34;:
cmd = cmd + &#34; -p &#34; + self.port cmd = cmd + &#34; -p &#34; + self.port
elif self.protocol == &#34;sftp&#34;:
cmd = cmd + &#34; -P &#34; + self.port
if self.options != &#39;&#39;: if self.options != &#39;&#39;:
cmd = cmd + &#34; &#34; + self.options cmd = cmd + &#34; &#34; + self.options
if self.logs != &#39;&#39;: if self.logs != &#39;&#39;:
@ -3788,6 +3793,10 @@ tasks:
passwords = self._passtx(self.password) passwords = self._passtx(self.password)
else: else:
passwords = [] passwords = []
if self.user == &#39;&#39;:
cmd = cmd + &#34; {}&#34;.format(self.host)
else:
cmd = cmd + &#34; {}&#34;.format(&#34;@&#34;.join([self.user,self.host]))
expects = [&#39;yes/no&#39;, &#39;refused&#39;, &#39;supported&#39;, &#39;cipher&#39;, &#39;ssh-keygen.*\&#34;&#39;, &#39;timeout|timed.out&#39;, &#39;unavailable&#39;, &#39;closed&#39;, &#39;[p|P]assword:|[u|U]sername:&#39;, r&#39;&gt;$|#$|\$$|&gt;.$|#.$|\$.$&#39;, &#39;suspend&#39;, pexpect.EOF, pexpect.TIMEOUT, &#34;No route to host&#34;, &#34;resolve hostname&#34;, &#34;no matching&#34;] expects = [&#39;yes/no&#39;, &#39;refused&#39;, &#39;supported&#39;, &#39;cipher&#39;, &#39;ssh-keygen.*\&#34;&#39;, &#39;timeout|timed.out&#39;, &#39;unavailable&#39;, &#39;closed&#39;, &#39;[p|P]assword:|[u|U]sername:&#39;, r&#39;&gt;$|#$|\$$|&gt;.$|#.$|\$.$&#39;, &#39;suspend&#39;, pexpect.EOF, pexpect.TIMEOUT, &#34;No route to host&#34;, &#34;resolve hostname&#34;, &#34;no matching&#34;]
elif self.protocol == &#34;telnet&#34;: elif self.protocol == &#34;telnet&#34;:
cmd = &#34;telnet &#34; + self.host cmd = &#34;telnet &#34; + self.host
@ -3820,7 +3829,7 @@ tasks:
while True: while True:
results = child.expect(expects, timeout=timeout) results = child.expect(expects, timeout=timeout)
if results == 0: if results == 0:
if self.protocol == &#34;ssh&#34;: if self.protocol in [&#34;ssh&#34;, &#34;sftp&#34;]:
child.sendline(&#39;yes&#39;) child.sendline(&#39;yes&#39;)
elif self.protocol == &#34;telnet&#34;: elif self.protocol == &#34;telnet&#34;:
if self.user != &#39;&#39;: if self.user != &#39;&#39;:
@ -3839,7 +3848,7 @@ tasks:
after = &#34;Connection timeout&#34; after = &#34;Connection timeout&#34;
else: else:
after = child.after.decode() after = child.after.decode()
return (&#34;Connection failed code:&#34; + str(results) + &#34;\n&#34; + child.before.decode() + after + child.readline().decode()).rstrip() return (&#34;Connection failed code:&#34; + str(results) + &#34;\n&#34; + child.before.decode().lstrip() + after + child.readline().decode()).rstrip()
if results == 8: if results == 8:
if len(passwords) &gt; 0: if len(passwords) &gt; 0:
child.sendline(passwords[i]) child.sendline(passwords[i])