lfcli_base: renamed module to follow PEP8 reccos

This commit is contained in:
Jed Reynolds
2020-06-01 14:00:25 -07:00
parent 6da7ef8afc
commit 356a2cae4f

View File

@@ -0,0 +1,32 @@
#!env /usr/bin/python
# Extend this class to use common set of debug and request features for your script
from LANforge.LFUtils import *
class LFCliBase:
def __init__(self, lfjson_host="localhost", lfjson_port=8080, _debug=False):
self.debugOn = _debug
self.lfjson_host = lfjson_host
self.lfjson_port = lfjson_port
self.mgr_url = f"http://{self.lfjson_host}:{self.lfjson_port}/"
def jsonPost(self, _req_url, _data):
lf_r = LFRequest.LFRequest(self.mgr_url + _req_url)
_data['suppress_preexec_cli'] = True
_data['suppress_preexec_method'] = True
lf_r.addPostData(_data)
json_response = lf_r.jsonPost(self.debugOn)
# Debugging
# if (json_response != None):
# print("jsonReq: response: ")
# LFUtils.debug_printer.pprint(vars(json_response))
return json_response
def jsonGet(self, _req_url):
lf_r = LFRequest.LFRequest(self.mgr_url + _req_url)
json_response = lf_r.getAsJson(self.debugOn)
return json_response
# ~class