Better logging of ws connection for siteCmd CLI action
This commit is contained in:
parent
9f5600b7f7
commit
8a38983dfc
1 changed files with 10 additions and 1 deletions
11
src/main.py
11
src/main.py
|
@ -328,9 +328,15 @@ class Actions(object):
|
|||
|
||||
site = SiteManager.site_manager.get(address)
|
||||
|
||||
if not site:
|
||||
logging.error("Site not found: %s" % address)
|
||||
return None
|
||||
|
||||
ws = self.getWebsocket(site)
|
||||
|
||||
ws.send(json.dumps({"cmd": cmd, "params": parameters, "id": 1}))
|
||||
res_raw = ws.recv()
|
||||
|
||||
try:
|
||||
res = json.loads(res_raw)
|
||||
except Exception as err:
|
||||
|
@ -343,7 +349,10 @@ class Actions(object):
|
|||
|
||||
def getWebsocket(self, site):
|
||||
import websocket
|
||||
ws = websocket.create_connection("ws://%s:%s/Websocket?wrapper_key=%s" % (config.ui_ip, config.ui_port, site.settings["wrapper_key"]))
|
||||
|
||||
ws_address = "ws://%s:%s/Websocket?wrapper_key=%s" % (config.ui_ip, config.ui_port, site.settings["wrapper_key"])
|
||||
logging.info("Connecting to %s" % ws_address)
|
||||
ws = websocket.create_connection(ws_address)
|
||||
return ws
|
||||
|
||||
def sitePublish(self, address, peer_ip=None, peer_port=15441, inner_path="content.json"):
|
||||
|
|
Loading…
Reference in a new issue