Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions ipyvolume/headless.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,20 @@ def _screenshot_data(
# else:
# assert isinstance(fig, ipv.Figure)

chrome = PyChromeDevTools.ChromeInterface(headless_kwargs)

try:
host = "localhost"
port = 9222

if headless_kwargs.get("host"):
host = headless_kwargs.get("host")

chrome = PyChromeDevTools.ChromeInterface(host=host, port=port)
#chrome = PyChromeDevTools.ChromeInterface(host="localhost")
except:
print("Falied to connect to headless chrome, please make sure it's running on host={} and port={}".format(host, port))
raise

chrome.Network.enable()
chrome.Page.enable()
chrome.Page.navigate(url=html_filename)
Expand All @@ -59,16 +72,19 @@ def _screenshot_data(
result = chrome.Runtime.evaluate(expression='ipvss()')
tries = 0
while tries < 10:
#print(str(result))
try:
url = result['result']['result']['value']
url = result[0]['result']['result']['value']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did this change, and which version, and can we make it detect this? so it also works on older versions?

Copy link
Author

@rafique rafique Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't know why/when this has changed. This seems to work fine but recently throwing the following error: "tuple indices must be integers or slices, not str". This is the main reason prompting this pull request. Since there has been no recent update to ipyvolume python module, my guess is that something else (chrome/ipyvolume js module/threejs) has been updated

return url
except:
if 'ipvss' in result['result']['result']['description']:
except Exception as ex:
#print(str(ex))
#raise ex
if 'ipvss' in result[0]['result']['result']['description']:
tries += 1
time.sleep(0.5)
else:
print('error getting result, return value was:', result)
raise
raise ex


def _main():
Expand Down