Revert "black: re-format"
This reverts commit 5731818de0ce446ceaafc7e75ae39da1b69942ae.
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
Change-Id: Ie61cdc8c7f2825b0d9d66be87a6a3a058de2b372
diff --git a/lib/event_notification.py b/lib/event_notification.py
index 53c010e..363caf4 100755
--- a/lib/event_notification.py
+++ b/lib/event_notification.py
@@ -1,15 +1,14 @@
#!/usr/bin/env python3
-import json
-import ssl
-
-import gen_print as gp
-import gen_valid as gv
import requests
import websocket
+import json
+import ssl
+import gen_valid as gv
+import gen_print as gp
-class event_notification:
+class event_notification():
r"""
Main class to subscribe and receive event notifications.
"""
@@ -37,22 +36,20 @@
r"""
Login and return session object.
"""
- http_header = {"Content-Type": "application/json"}
+ http_header = {'Content-Type': 'application/json'}
session = requests.session()
- response = session.post(
- "https://" + self.__host + "/login",
- headers=http_header,
- json={"data": [self.__user, self.__password]},
- verify=False,
- timeout=30,
- )
+ response = session.post('https://' + self.__host + '/login',
+ headers=http_header,
+ json={"data": [self.__user, self.__password]},
+ verify=False, timeout=30)
gv.valid_value(response.status_code, valid_values=[200])
login_response = json.loads(response.text)
gp.qprint_var(login_response)
- gv.valid_value(login_response["status"], valid_values=["ok"])
+ gv.valid_value(login_response['status'], valid_values=['ok'])
return session
def subscribe(self, dbus_path, enable_trace=False):
+
r"""
Subscribe to the given path and return a list of event notifications.
@@ -82,21 +79,15 @@
cookies = session.cookies.get_dict()
# Convert from dictionary to a string of the following format:
# key=value;key=value...
- cookies = gp.sprint_var(
- cookies,
- fmt=gp.no_header() | gp.strip_brackets(),
- col1_width=0,
- trailing_char="",
- delim="=",
- ).replace("\n", ";")
+ cookies = gp.sprint_var(cookies, fmt=gp.no_header() | gp.strip_brackets(),
+ col1_width=0, trailing_char="",
+ delim="=").replace("\n", ";")
websocket.enableTrace(enable_trace)
- self.__websocket = websocket.create_connection(
- "wss://{host}/subscribe".format(host=self.__host),
- sslopt={"cert_reqs": ssl.CERT_NONE},
- cookie=cookies,
- )
- dbus_path = [path.strip() for path in dbus_path.split(",")]
+ self.__websocket = websocket.create_connection("wss://{host}/subscribe".format(host=self.__host),
+ sslopt={"cert_reqs": ssl.CERT_NONE},
+ cookie=cookies)
+ dbus_path = [path.strip() for path in dbus_path.split(',')]
dbus_path = {"paths": dbus_path}
self.__websocket.send(json.dumps(dbus_path))