Ejemplo n.º 1
0
 def test_01_instance_raise_exception_1(self):
     with self.assertRaises(TypeError):
         nm = NMCLI(text="Not boolean")
Ejemplo n.º 2
0
 def test_00_constructor_2(self):
     _env = {'LANG': 'C'}
     nm = NMCLI(env=_env)
     self.assertEqual(nm.env, _env)
Ejemplo n.º 3
0
 def test_01_instance_raise_exception_0(self):
     with self.assertRaises(NameError):
         nm = NMCLI(path='/usr/local/not_nmcli')
Ejemplo n.º 4
0
If you want to pass environment variables when executing nmcli,
you can specify 'env' argument.
    nm = NMCLI(env={'LANG': 'C'})

Throw TypeError exception if you specify other than 'None' or
a dictionary.


If you need super-user priviledge to execute 'nmcli' command,
you can specify 'sudo' argument.
    nm = NMCLI(sudo='path/to/sudo')

Throw NameError exception if path-to-sudo ending without 'sudo'.
Throw FileNotFoundError if the file specified is not executable.
"""
nm = NMCLI(text=True, env={'LANG':'C'})

"""
All methods return a tuple containing returncode, stdout and stderr.

returncode : exit status code from 'nmcli' command
stdout     : standard outout from 'nmcli' command
             some methods return a dict or list
stderr     : standard error output from 'nmcli'
             empty str is returned when 'nmcli' finished successfully
"""

# show version of 'nmcli'
returncode, stdout, stderr = nm.show_version()
print(stdout)