Ejemplo n.º 1
0
 def test_02_show_version_1(self):
     nm = NMCLI(text=True)
     rc, stdout, stderr = nm.show_version()
     self.assertEqual(rc, 0)
     self.assertEqual(stdout.split()[0], 'nmcli')
Ejemplo n.º 2
0
 def test_02_show_version_2(self):
     nm = NMCLI(env={'LANG': 'C'})
     rc, stdout, stderr = nm.show_version()
     self.assertEqual(rc, 0)
     self.assertEqual(stdout.split()[0:3], [b'nmcli', b'tool,', b'version'])
Ejemplo n.º 3
0
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)


nm = NMCLI() # return values will be in type of bytes and default LOCALE
# show version of 'nmcli'
returncode, stdout, stderr = nm.show_version()
print(stdout)

# list devices recognised by NetworkManager
returncode, stdout, stderr = nm.list_devices()
print(stdout)

# list connections
returncode, stdout, stderr = nm.list_connections()
print(stdout)