@staticmethod<EOL><INDENT>def snmpcmd(op, oid, data=None, datatype=None):<DEDENT>
<EOL>if op == "<STR_LIT>":<EOL><INDENT>cmd = "<STR_LIT>"<EOL>cmd = cmd.format(op, oid, datatype, data)<EOL><DEDENT>else:<EOL><INDENT>cmd = "<STR_LIT>"<EOL>cmd = cmd.format(op, oid)<EOL><DEDENT>proc = subprocess.Popen(<EOL>cmd, shell=True, env={ "<STR_LIT>": "<STR_LIT:C>" },<EOL>stdout=subprocess.PIPE, stderr=subprocess.STDOUT<EOL>)<EOL>output = proc.communicate()[<NUM_LIT:0>].strip()<EOL>if not isinstance("<STR_LIT>", bytes):<EOL><INDENT>output = output.decode(locale.getpreferredencoding())<EOL><DEDENT>rc = proc.poll()<EOL>if rc == <NUM_LIT:0>:<EOL><INDENT>if re.search("<STR_LIT>", output):<EOL><INDENT>raise netsnmpTestEnv.MIBUnavailableError(oid)<EOL><DEDENT>if re.search("<STR_LIT>", output):<EOL><INDENT>raise netsnmpTestEnv.UnknownOIDError(oid)<EOL><DEDENT>return output<EOL><DEDENT>if re.search("<STR_LIT>", output):<EOL><INDENT>raise netsnmpTestEnv.UnknownOIDError(oid)<EOL><DEDENT>if re.search("<STR_LIT>", output):<EOL><INDENT>raise netsnmpTestEnv.SNMPTimeoutError("<STR_LIT>")<EOL><DEDENT>if re.search("<STR_LIT>", output):<EOL><INDENT>raise netsnmpTestEnv.NotWritableError(oid)<EOL><DEDENT>if len(inspect.getargspec(subprocess.CalledProcessError.__init__).args) == <NUM_LIT:3>:<EOL><INDENT>def new_init(self, returncode, cmd, output=None):<EOL><INDENT>self.returncode = returncode<EOL>self.cmd        = cmd<EOL>self.output     = output<EOL><DEDENT>subprocess.CalledProcessError.__init__ = new_init<EOL><DEDENT>raise subprocess.CalledProcessError(rc, cmd, output)<EOL>
Executes a SNMP client operation in the net-snmp test environment.

            "op" is either "get", "set", "walk" or "table".
            "oid" is the OID to run the operation against.
            "data" is the data to set in case of a "set" operation.
                "datatype" is the type of the data (as specified to "snmpset").