Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 128kb url limit in open_config_page #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
11 changes: 6 additions & 5 deletions pebble_tool/util/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
import time
from six.moves.urllib import parse as urlparse
import webbrowser

import tempfile
from .phone_sensor import SENSOR_PAGE_HTML


logger = logging.getLogger("pebble_tool.util.browser")

class BrowserController(object):
def __init__(self):
self.port = None

def open_config_page(self, url, callback):
self.port = port = self._choose_port()
url = self.url_append_params(url, {'return_to': 'http://localhost:{}/close?'.format(port)})
webbrowser.open_new(url)
self.serve_page(port, callback)
with tempfile.NamedTemporaryFile(suffix = '.html') as tmp:
tmp.write('<meta http-equiv="refresh" content="0;url={}"/>'.format(url))
tmp.flush()
webbrowser.open(tmp.name)
self.serve_page(port, callback)

def serve_page(self, port, callback):
# This is an array so AppConfigHandler doesn't create an instance variable when trying to set the state to False
Expand Down