22
33from climatic .CoreCli import CoreCli
44from climatic .connections .Ssh import Ssh , PTY_WINSIZE_COLS
5+ from typing import List , Optional
56
67
78####################################################################################################
@@ -11,23 +12,21 @@ class Python3Shell(CoreCli):
1112 """ Extend CoreCli with Python3Shell customizations.
1213 """
1314
14- def run (self , cmds : str , ** run_opts ):
15- """ Execute Python3 commands
16-
17- @param cmds A multi-line string with commands to be executed.
18- @param run_opts Same options as CoreCli run method.
15+ def __init__ (self , connection , ** opts ):
16+ """ Initialize OcNOS CLI.
17+ @param connection The connection object to be used for accessing the CLI.
18+ @param opts Same options as CoreCli initializer.
1919 """
20- if not 'marker' in run_opts :
21- run_opts ['marker' ] = '>>>|...'
22-
23- if not 'error_marker' in run_opts :
24- run_opts ['error_marker' ] = 'Error'
25-
26- if not 'strip_cmds' in run_opts :
27- run_opts ['strip_cmds' ] = False
28-
29- return super (Python3Shell , self ).run (cmds , ** run_opts )
20+ if not 'marker' in opts :
21+ self .marker = '>>>|...'
22+ if not 'error_marker' in opts :
23+ self .error_marker = 'Error'
24+ if not 'strip_cmds' in opts :
25+ self .strip_cmds = False
3026
27+ CoreCli .__init__ (self ,
28+ connection ,
29+ ** opts )
3130
3231####################################################################################################
3332## SshPython3Shell
@@ -37,19 +36,31 @@ class SshPython3Shell(Python3Shell):
3736 Core implementation is done by Ssh and Python3Shell.
3837 """
3938
40- def __init__ (self , ip : str , username : str , password : str , port = 22 , sh_markers = ['#' , '>' ]):
39+ def __init__ (self ,
40+ ip : str ,
41+ username : str ,
42+ password : str ,
43+ port : Optional [int ]= 22 ,
44+ sh_markers : Optional [List [str ]]= ['#' , '>' ],
45+ ** opts ):
4146 """ Initialize Python3 Shell.
4247 @param ip IP address of target. Ex: '234.168.10.12'
4348 @param username username for opening SSH connection
4449 @param password password for authentication in SSH connection
4550 @param port Port used for SSH connection. Defaults to 22
4651 @param sh_markers List of accepted markers for the shell when the SSH is established and
4752 before launching python3 interpreter
53+ @param opts Same options as CoreCli initializer.
4854 """
4955 self .sh_markers = sh_markers
5056 self .name = "Python3.SSH"
5157 ssh = Ssh (ip , username , port = port )
52- Python3Shell .__init__ (self , ssh , username = username , password = password , pty_winsize_cols = PTY_WINSIZE_COLS )
58+ Python3Shell .__init__ (self ,
59+ ssh ,
60+ username = username ,
61+ password = password ,
62+ pty_winsize_cols = PTY_WINSIZE_COLS ,
63+ ** opts )
5364
5465 def login (self ):
5566 """ Login to CLI interface.
0 commit comments