Skip to content

Commit

Permalink
Minor refinements to docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimian committed Mar 31, 2016
1 parent 578ee68 commit d6ab8ed
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
12 changes: 6 additions & 6 deletions easysnmp/easy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def snmp_get(oids, **session_kargs):
"""
Perform an SNMP GET operation to retrieve a particular piece of
information
information.
:param oids: you may pass in a list of OIDs or single item; each item
may be a string representing the entire OID
Expand All @@ -25,7 +25,7 @@ def snmp_get(oids, **session_kargs):
def snmp_set(oid, value, type=None, **session_kargs):
"""
Perform an SNMP SET operation to update a particular piece of
information
information.
:param oid: the OID that you wish to set which may be a string
representing the entire OID (e.g. 'sysDescr.0') or may
Expand All @@ -46,7 +46,7 @@ def snmp_set(oid, value, type=None, **session_kargs):
def snmp_set_multiple(oid_values, **session_kargs):
"""
Perform multiple SNMP SET operations to update various pieces of
information at the same time
information at the same time.
:param oid_values: a list of tuples whereby each tuple contains a
(oid, value) or an (oid, value, snmp_type)
Expand All @@ -62,7 +62,7 @@ def snmp_set_multiple(oid_values, **session_kargs):
def snmp_get_next(oids, **session_kargs):
"""
Uses an SNMP GETNEXT operation to retrieve the next variable after
the chosen item
the chosen item.
:param oids: you may pass in a list of OIDs or single item; each item
may be a string representing the entire OID
Expand All @@ -81,7 +81,7 @@ def snmp_get_next(oids, **session_kargs):
def snmp_get_bulk(oids, non_repeaters, max_repetitions, **session_kargs):
"""
Performs a bulk SNMP GET operation to retrieve multiple pieces of
information in a single packet
information in a single packet.
:param oids: you may pass in a list of OIDs or single item; each item
may be a string representing the entire OID
Expand All @@ -105,7 +105,7 @@ def snmp_get_bulk(oids, non_repeaters, max_repetitions, **session_kargs):
def snmp_walk(oids='.1.3.6.1.2.1', **session_kargs):
"""
Uses SNMP GETNEXT operation to automatically retrieve multiple
pieces of information in an OID for you
pieces of information in an OID for you.
:param oids: you may pass in a single item (multiple values currently
experimental) which may be a string representing the
Expand Down
14 changes: 7 additions & 7 deletions easysnmp/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@


class EasySNMPError(Exception):
"""The base Easy SNMP exception which covers all exceptions raised"""
"""The base Easy SNMP exception which covers all exceptions raised."""
pass


class EasySNMPConnectionError(EasySNMPError):
"""Indicates a problem connecting to the remote host"""
"""Indicates a problem connecting to the remote host."""
pass


class EasySNMPTimeoutError(EasySNMPConnectionError):
"""Raised when an SNMP request times out"""
"""Raised when an SNMP request times out."""
pass


class EasySNMPUnknownObjectIDError(EasySNMPError):
"""Raised when an inexisted OID is requested"""
"""Raised when an inexisted OID is requested."""
pass


Expand All @@ -32,20 +32,20 @@ class EasySNMPNoSuchNameError(EasySNMPError):
class EasySNMPNoSuchObjectError(EasySNMPError):
"""
Raised when an OID is requested which may have some form of existence but
an invalid object name
an invalid object name.
"""
pass


class EasySNMPNoSuchInstanceError(EasySNMPError):
"""
Raised when a particular OID index requested from Net-SNMP doesn't exist
Raised when a particular OID index requested from Net-SNMP doesn't exist.
"""
pass


class EasySNMPUndeterminedTypeError(EasySNMPError):
"""
Raised when the type cannot be determine when setting the value of an OID
Raised when the type cannot be determine when setting the value of an OID.
"""
pass
2 changes: 1 addition & 1 deletion easysnmp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def normalize_oid(oid, oid_index=None):
"""
Ensures that the index is set correctly given an OID definition
Ensures that the index is set correctly given an OID definition.
:param oid: the OID to normalize
:param oid_index: the OID index to normalize
Expand Down
18 changes: 9 additions & 9 deletions easysnmp/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
def build_varlist(oids):
"""
Prepare the variable binding list which will be used by the
C interface
C interface.
:param oids: an individual or list of strings or tuples representing
one or more OIDs
Expand Down Expand Up @@ -62,7 +62,7 @@ def build_varlist(oids):
def validate_results(varlist):
"""
Validates a list of SNMPVariable objects and raises any appropriate
exceptions where necessary
exceptions where necessary.
:param varlist: a variable list containing SNMPVariable objects to be
processed
Expand Down Expand Up @@ -296,7 +296,7 @@ def connect_hostname(self):
def get(self, oids):
"""
Perform an SNMP GET operation using the prepared session to
retrieve a particular piece of information
retrieve a particular piece of information.
:param oids: you may pass in a list of OIDs or single item; each item
may be a string representing the entire OID
Expand All @@ -323,7 +323,7 @@ def get(self, oids):

def set(self, oid, value, snmp_type=None):
"""
Perform an SNMP SET operation using the prepared session
Perform an SNMP SET operation using the prepared session.
:param oid: the OID that you wish to set which may be a string
representing the entire OID (e.g. 'sysDescr.0') or may
Expand Down Expand Up @@ -351,7 +351,7 @@ def set(self, oid, value, snmp_type=None):
def set_multiple(self, oid_values):
"""
Perform an SNMP SET operation on multiple OIDs with multiple
values using the prepared session
values using the prepared session.
:param oid_values: a list of tuples whereby each tuple contains a
(oid, value) or an (oid, value, snmp_type)
Expand Down Expand Up @@ -385,7 +385,7 @@ def set_multiple(self, oid_values):
def get_next(self, oids):
"""
Uses an SNMP GETNEXT operation using the prepared session to
retrieve the next variable after the chosen item
retrieve the next variable after the chosen item.
:param oids: you may pass in a list of OIDs or single item; each item
may be a string representing the entire OID
Expand Down Expand Up @@ -413,7 +413,7 @@ def get_next(self, oids):
def get_bulk(self, oids, non_repeaters, max_repetitions):
"""
Performs a bulk SNMP GET operation using the prepared session to
retrieve multiple pieces of information in a single packet
retrieve multiple pieces of information in a single packet.
:param oids: you may pass in a list of OIDs or single item; each item
may be a string representing the entire OID
Expand Down Expand Up @@ -449,7 +449,7 @@ def get_bulk(self, oids, non_repeaters, max_repetitions):
def walk(self, oids='.1.3.6.1.2.1'):
"""
Uses SNMP GETNEXT operation using the prepared session to
automatically retrieve multiple pieces of information in an OID
automatically retrieve multiple pieces of information in an OID.
:param oids: you may pass in a single item (multiple values currently
experimental) which may be a string representing the
Expand All @@ -474,5 +474,5 @@ def walk(self, oids='.1.3.6.1.2.1'):
return list(varlist)

def __del__(self):
"""Deletes the session and frees up memory"""
"""Deletes the session and frees up memory."""
return interface.delete_session(self)
4 changes: 2 additions & 2 deletions easysnmp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def strip_non_printable(value):
"""
Removes any non-printable characters and adds an indicator to the string
when binary characters are fonud
when binary characters are fonud.
:param value: the value that you wish to strip
"""
Expand All @@ -32,7 +32,7 @@ def tostr(value):
"""
Converts any variable to a string or returns None if the variable
contained None to begin with; this function currently supports None,
unicode strings, byte strings and numbers
unicode strings, byte strings and numbers.
:param value: the value you wish to convert to a string
"""
Expand Down
5 changes: 3 additions & 2 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@


class SNMPSetCLIError(Exception):
"""An exception raised when an SNMP SET fails via the CLI"""
"""An exception raised when an SNMP SET fails via the CLI."""


def snmp_set_via_cli(oid, value, type):
"""Sets an SNMP variable using the snmpset command
"""
Sets an SNMP variable using the snmpset command.
:param oid: the OID to update
:param value: the new value to set the OID to
Expand Down

0 comments on commit d6ab8ed

Please sign in to comment.