Skip to content

Commit

Permalink
Added basic __init__ code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahvohck committed Sep 18, 2019
1 parent 45b0e11 commit 99a3a12
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gremlin/hid_cerberus.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class HIDCerberus:
'''
cerberus_API_URL = "http://localhost:{port}/api/v1/hidguardian/"
cerberus_API_PORT = 26762
cerberus_listening = False
api_purge_whitelist = "whitelist/purge"
api_purge_devices = "affected/purge"
api_whitelist_get = "whitelist/get"
Expand All @@ -23,7 +24,12 @@ class HIDCerberus:

# TODO: Check if HID Cerberus is running when initialized
# TODO: Check if HID Cerberus is installed?
def __init__(self): pass
def __init__(self):
resp = _get_web(cerberus_API_URL.format(port=cerberus_API_PORT))
if "404" in resp: # The base API URL should return a json object that includes the string "404"
self.cerberus_listening = True
elif "ERROR" in resp: # If ERROR is in the response then we weren't able to connect at all
gremlin.util.display_error("Unable to connect to HID Cerberus. Please check if it is running/installed.")

def add_device(self, vendor_id, product_id):
'''Requests that HID Cerberus add device with vendor_id and product_id'''
Expand Down

0 comments on commit 99a3a12

Please sign in to comment.