self._loadavg = None
self._mem_total = None
self._mem_free = None
- self._mem_cached = None
- self._mem_buffers = None
self._mem_swap_total = None
self._mem_swap_free = None
- self._platform_distro = 'Unknown'
self._net_interfaces = 'Unknown\n'
self._net_routing_table = 'Unknown\n'
self._net_stats = 'Unknown\n'
self._net_connections = 'Unknown\n'
+ # The following are Linux speicific, and should eventually be removed
+ # from this level; for now we simply default to None (so they won't
+ # be printed)
+ self._platform_distro = None
+ self._mem_cached = None
+ self._mem_buffers = None
+
def get_num_processors(self):
"""Returns the number of processors. This is the number of
hyperthreads when hyper-threading is enabled.
return self._platform_is_smp
def get_platform_distro(self):
- """Returns the name of the OS distribution in use."""
+ """Returns the name of the OS distribution in use.
+
+ Note: the concept of 'distribution' is Linux specific. This shouldn't
+ be at this level.
+
+ """
return self._platform_distro
def get_uptime(self):
except (subprocess.CalledProcessError, OSError):
pass
- self._platform_distro = self._platform_name + ' ' + self._platform_version
-
try:
s = subprocess.check_output(['ifconfig'])
self._net_interfaces = s.decode('utf-8')
self.assertEqual(None, s.get_mem_buffers())
self.assertEqual(None, s.get_mem_swap_total())
self.assertEqual(None, s.get_mem_swap_free())
- self.assertEqual('Unknown', s.get_platform_distro())
+ self.assertEqual(None, s.get_platform_distro())
self.assertEqual('Unknown\n', s.get_net_interfaces())
self.assertEqual('Unknown\n', s.get_net_routing_table())
self.assertEqual('Unknown\n', s.get_net_stats())
self.assertEqual(None, s.get_mem_buffers())
self.assertEqual(None, s.get_mem_swap_total())
self.assertEqual(None, s.get_mem_swap_free())
- self.assertEqual('Unknown', s.get_platform_distro())
+ self.assertEqual(None, s.get_platform_distro())
self.assertEqual('Unknown\n', s.get_net_interfaces())
self.assertEqual('Unknown\n', s.get_net_routing_table())
self.assertEqual('Unknown\n', s.get_net_stats())
self.assertLess(abs(76632 - s.get_uptime()), 4)
self.assertEqual(None, s.get_mem_cached())
self.assertEqual(None, s.get_mem_buffers())
+ self.assertEqual(None, s.get_platform_distro())
# These test that the corresponding tools are being called (and
# no further processing is done on this data). Please see the
self.assertEqual(566791168, s.get_mem_swap_total())
self.assertEqual(566789120, s.get_mem_swap_free())
- # Try new regex assertion (which replaced the deprecated
- # assertRegexpMatches. If it is not available, use the old one
- try:
- self.assertRegex(s.get_platform_distro(), '^OpenBSD\s+.*')
- except AttributeError:
- self.assertRegexpMatches(s.get_platform_distro(), '^OpenBSD\s+.*')
-
def test_sysinfo_freebsd(self):
"""Tests the FreeBSD implementation of SysInfo. Note that this
tests deep into the implementation, and not just the
self.assertEqual(543214321 - (343434 * 1024), s.get_mem_free())
self.assertEqual(1037533184, s.get_mem_swap_total())
self.assertEqual(1037533184, s.get_mem_swap_free())
- # Try new regex assertion (which replaced the deprecated
- # assertRegexpMatches. If it is not available, use the old one
- try:
- self.assertRegex(s.get_platform_distro(), '^FreeBSD\s+.*')
- except AttributeError:
- self.assertRegexpMatches(s.get_platform_distro(), '^FreeBSD\s+.*')
def test_sysinfo_osx(self):
"""Tests the OS X implementation of SysInfo. Note that this
self.assertEqual((23456 * 4096), s.get_mem_free())
self.assertEqual(18874368.0, s.get_mem_swap_total())
self.assertEqual(1075988.48, s.get_mem_swap_free())
- # Try new regex assertion (which replaced the deprecated
- # assertRegexpMatches. If it is not available, use the old one
- try:
- self.assertRegex(s.get_platform_distro(), '^Darwin\s+.*')
- except AttributeError:
- self.assertRegexpMatches(s.get_platform_distro(), '^Darwin\s+.*')
if __name__ == "__main__":
unittest.main()