flexxui / webruntime

Launch HTML5 apps in the browser or a desktop-like runtime.
http://webruntime.readthedocs.io
BSD 2-Clause "Simplified" License
43 stars 10 forks source link

Unicode error in get_pid_list() #5

Closed almarklein closed 6 years ago

almarklein commented 6 years ago

This was mentioned in a Flexx issue (https://github.com/flexxui/flexx/issues/471#issuecomment-420053555) by @zappfinger:

Most examples work good, but the form example gives me:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Users/richard/anaconda/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/Users/richard/anaconda/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/richard/py35env/lib/python3.5/site-packages/webruntime/_common.py", line 107, in <lambda>
    t = threading.Thread(target=lambda: time.sleep(4) or clean_dirs())
  File "/Users/richard/py35env/lib/python3.5/site-packages/webruntime/_manage.py", line 221, in clean_dirs
    pids = get_pid_list()
  File "/Users/richard/py35env/lib/python3.5/site-packages/webruntime/_manage.py", line 137, in get_pid_list
    out = subprocess.check_output(cmd).decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 46623: invalid continuation byte

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/Users/richard/anaconda/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/Users/richard/anaconda/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/richard/py35env/lib/python3.5/site-packages/webruntime/_common.py", line 107, in <lambda>
    t = threading.Thread(target=lambda: time.sleep(4) or clean_dirs())
  File "/Users/richard/py35env/lib/python3.5/site-packages/webruntime/_manage.py", line 221, in clean_dirs
    pids = get_pid_list()
  File "/Users/richard/py35env/lib/python3.5/site-packages/webruntime/_manage.py", line 137, in get_pid_list
    out = subprocess.check_output(cmd).decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 46375: invalid continuation byte

Traceback (most recent call last):
  File "/Users/richard/PycharmProjects/FlexxTest/flexxTest.py", line 49, in <module>
    m = flx.launch(ThemedForm, 'app')
  File "/Users/richard/py35env/lib/python3.5/site-packages/flexx/app/_funcs.py", line 231, in launch
    return a.launch(runtime, **runtime_kwargs)
  File "/Users/richard/py35env/lib/python3.5/site-packages/flexx/app/_app.py", line 166, in launch
    session._runtime = webruntime.launch(url, runtime=runtime, **runtime_kwargs)
  File "/Users/richard/py35env/lib/python3.5/site-packages/webruntime/__init__.py", line 200, in launch
    raise ValueError('Could not detect a suitable backend among %r.' % runtimes)
ValueError: Could not detect a suitable backend among ['firefox-app', 'nw-app'].

Process finished with exit code 1
almarklein commented 6 years ago

This should be fixed by #6. Please reopen if it is not.

zappfinger commented 6 years ago

Well, this version only solves the first part of the problem (about the unicode). But the last part remains:

[I 21:50:37 flexx.app] Asset store collected 2 new modules. [I 21:50:38 flexx.app] Serving apps at http://localhost:49190/ [I 21:50:38 flexx.app] Asset store collected 23 new modules. Traceback (most recent call last): File "/Users/richard/PycharmProjects/FlexxTest/flexxTest.py", line 49, in m = flx.launch(ThemedForm, 'app') File "/Users/richard/py35env/lib/python3.5/site-packages/flexx/app/_funcs.py", line 231, in launch return a.launch(runtime, runtime_kwargs) File "/Users/richard/py35env/lib/python3.5/site-packages/flexx/app/_app.py", line 166, in launch session._runtime = webruntime.launch(url, runtime=runtime, runtime_kwargs) File "/Users/richard/py35env/lib/python3.5/site-packages/webruntime/init.py", line 200, in launch raise ValueError('Could not detect a suitable backend among %r.' % runtimes) ValueError: Could not detect a suitable backend among ['firefox-app', 'nw-app'].

Process finished with exit code 1

almarklein commented 6 years ago

Right. with the "app" runtime, you need to have either Firefox or Nw.js installed.

zappfinger commented 6 years ago

But I have Firefox installed on my Mac...

Op do 13 sep. 2018 om 10:06 schreef Almar Klein notifications@github.com:

Right. with the "app" runtime, you need to have either Firefox or Nw.js installed.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/flexxui/webruntime/issues/5#issuecomment-420920481, or mute the thread https://github.com/notifications/unsubscribe-auth/AFkYZ4RR6RUXYr-pnnhaMAzbqVLV_lMSks5uahH9gaJpZM4WiOeH .

almarklein commented 6 years ago

Oh, interesting. It looks like webruntime is unable to find it (the code that searches for it is here). Could you please try a few things?

zappfinger commented 6 years ago

Ok, this sort of works. When I change 'app' to 'firefox', it works, but then it recommends me to use 'firefox-browser'. When I do that, it gives me: [I 19:43:55 flexx.app] Asset store collected 2 new modules. [I 19:43:56 flexx.app] Serving apps at http://localhost:49190/ [I 19:43:56 flexx.app] Asset store collected 23 new modules. 70:78: execution error: Firefox got an error: Application isn’t running. (-600) [I 19:43:56 flexx.app] Starting Flexx event loop. [I 19:43:59 flexx.app] New session ThemedForm 3E07Rsrtk8eSzLaRZrenR6JZ

When I use 'firefox-app' I get: Traceback (most recent call last): File "/Users/richard/PycharmProjects/FlexxTest/flexxTest.py", line 49, in m = flx.launch(ThemedForm, 'firefox-app') File "/Users/richard/py35env/lib/python3.5/site-packages/flexx/app/_funcs.py", line 231, in launch return a.launch(runtime, runtime_kwargs) File "/Users/richard/py35env/lib/python3.5/site-packages/flexx/app/_app.py", line 166, in launch session._runtime = webruntime.launch(url, runtime=runtime, runtime_kwargs) File "/Users/richard/py35env/lib/python3.5/site-packages/webruntime/init.py", line 200, in launch raise ValueError('Could not detect a suitable backend among %r.' % runtimes) ValueError: Could not detect a suitable backend among ['firefox-app'].

zappfinger commented 6 years ago

Oh yeah and BTW, Firefox is not my default browser, that is Chrome. Maybe that has something to do with it..

almarklein commented 6 years ago

This is interesting. With 'firefox-browser' it gives an error, but does it still work (i.e. the app is opened in the browser)?

I don't think it matters whether ff is the default browser. My feeling is that webruntime finds a firefox executable that is not right, or broken in some way. It's hard for me to look into this, since I cannot reproduce it :) I can give some directions on where to look, and maybe we will be able to solve it that way.

I am curious what is found by _get_exe() https://github.com/flexxui/webruntime/blob/master/webruntime/_firefox.py#L134, and whether that matches the Firefox on your system. Could you place some breakpoints or print-statements there, to see what path is found?