Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions kstat/kstat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
Expand All @@ -7,13 +8,14 @@
# and limitations under the License.
#
#
# Copyright 2011 Grigale Ltd. All rigths reserved.
# Use is sujbect to license terms.
# Copyright 2011 Grigale Ltd. All rights reserved.
# Use is subject to license terms.
#

import ctypes as C
import libkstat

from sys import version_info

class Kstat():
def __init__(self, module='', instance=-1, name=''):
Expand All @@ -26,11 +28,23 @@ def __del__(self):
libkstat.kstat_close(self._ctl)

def __str__(self):
s = 'Module: {0}, instance: {1}, name: {2}'.format(self._module, self._inst, self._name)
"""

"""
if version_info[1] > 5:
s = 'Module: {0}, instance: {1}, name: {2}'.format(self._module, self._inst, self._name)
else:
## Include this for older versions of python where .format is not a valid method
s = 'Module: %s, instance: %s, name: %s' % (self._module, self._inst, self._name)
return s

def __repr__(self):
s = 'Kstat("{0}", {1}, "{2}")'.format(self._module, self._inst, self._name)

if version_info[1] > 5:
s = 'Kstat("{0}", {1}, "{2}")'.format(self._module, self._inst, self._name)
else:
## Include this for older versions of python where .format is not a valid method
s = 'Kstat("%s", "%s", "%s")' % (self._module, self._inst, self._name)
return s

def lookup(self):
Expand Down