markfinger / python-react

Server-side rendering of React components
MIT License
1.62k stars 116 forks source link

example not working #43

Closed musicformellons closed 9 years ago

musicformellons commented 9 years ago

I tried to run the example in a virtualenv 'test' but I get an error message: (test)MfM@MfM-XPS:~/TEST/python-react-master/example$ python3 example.pyTraceback (most recent call last): File "example.py", line 4, in from settings import DEBUG, BASE_DIR File "/home/MfM/TEST/python-react-master/example/settings.py", line 11, in USE_MANAGER=DEBUG File "/usr/local/lib/python3.4/dist-packages/js_host/conf.py", line 60, in configure from .host import host File "/usr/local/lib/python3.4/dist-packages/js_host/host.py", line 13, in status = read_status_from_config_file(config_file) File "/usr/local/lib/python3.4/dist-packages/js_host/bin.py", line 31, in read_status_from_config_file return json.loads(stdout) File "/usr/lib/python3.4/json/init.py", line 318, in loads return _default_decoder.decode(s) File "/usr/lib/python3.4/json/decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode raise ValueError(errmsg("Expecting value", s, err.value)) from None ValueError: Expecting value: line 1 column 1 (char 0)

markfinger commented 9 years ago

Can you put print(stdout) before return json.loads(stdout) and paste what it spits out.

For context, it's hitting a JS CLI interface and trying to get the server's config. Once the config's available in the python side, it knows where to send requests, etc.

musicformellons commented 9 years ago

Thanks for your help. Maybe I am clumsy but when I put the line "print(stdout)" before line 31 in "/usr/local/lib/python3.4/dist-packages/js_host/bin.py", I do not get any output in the terminal. Or does stdout put it somewhere else?

markfinger commented 9 years ago

Strange.

If you add print(cmd), you'll get the CLI command that it's trying to run. If you run that command yourself, you should get an indication of what the problem is.

It'll be something like node node_modules/js-host/bin/js-host.js host.config.js --config

musicformellons commented 9 years ago

The print(cmd) gives: ('node', '/home/MfM/TEST/python-react-master/example/node_modules/js-host/bin/js-host.js', '/home/MfM/TEST/python-react-master/example/host.config.js', '--config')

When I run it like: node /home/MfM/TEST/python-react-master/example/node_modules/js-host/bin/js-host.js /home/MfM/TEST/python-react-master/example/host.config.js --config

Nothing happends (no output)...

musicformellons commented 9 years ago

Ah I now also noticed that the output of print(stdout) was actually a 'return'/Enter (and nothing else...).

markfinger commented 9 years ago

The problem's somewhere in js-host itself - it's pretty fragile and seems to have a bunch of weird issues that I've never been able to replicate. When I get the time, I'm intending to switch back to just using a basic rendering server.

In regards to fixing your problem, what happens if you run it without the --config flag?

musicformellons commented 9 years ago

Then nothing happends:

(test3.4.3) MfM@MfM-XPS:~/TEST/python-react-master/example$ node /home/MfM/TEST/python-react-master/example/node_modules/js-host/bin/js-host.js /home/MfM/TEST/python-react-master/example/host.config.js (test3.4.3) MfM@MfM-XPS:~/TEST/python-react-master/example$

markfinger commented 9 years ago

Wow, I've never seen that before. Can you:

musicformellons commented 9 years ago

Did it. When running npm (I need to sudo) I get some warnings: (test3.4.3) MfM@MfM-XPS:~/TEST/python-react-master/example$ sudo npm install npm WARN deprecated webpack-wrapper@0.2.2: webpack-build has replaced this package npm WARN optional dep failed, continuing fsevents@0.3.6 npm WARN optional dep failed, continuing fsevents@0.3.6 marked@0.3.3 node_modules/marked

jquery@2.1.4 node_modules/jquery

react-render@0.3.0 node_modules/react-render └── lodash@3.9.3

etc (others are good).

When running the npm test, it looks good and concludes with: 59 passing (9s)

However when I run python example.py I get the same errormessage as before...

markfinger commented 9 years ago

That's strange.

npm test runs a battery of tests over the js-host/bin/js-host.js file, so it's working as expected, but python and your shell get different results. Honestly, I've got no idea at this point.

Maybe the sudo npm install creates permission issues? Normally file systems throw errors in that case, and the interaction with that file checks both stdout and stderr - see: https://github.com/markfinger/python-js-host/blob/master/js_host/bin.py#L24-L26

musicformellons commented 9 years ago

Can you do npm install without sudo? Op 29 jun. 2015 01:15 schreef "Mark Finger" notifications@github.com:

That's strange.

npm test runs a battery of tests over the js-host/bin/js-host.js file, so it's working as expected, but python and your shell get different results. Honestly, I've got no idea at this point.

Maybe the sudo npm install creates permission issues? Normally file systems throw errors in that case, and the interaction with that file checks both stdout and stderr - see: https://github.com/markfinger/python-js-host/blob/master/js_host/bin.py#L24-L26

— Reply to this email directly or view it on GitHub https://github.com/markfinger/python-react/issues/43#issuecomment-116359149 .

markfinger commented 9 years ago

Yeah, you should be able to. The normal behaviour is to use it without.

We've had issues in the past where apt-get and other package managers have installed it with the wrong permissions. I don't remember the solution, but you should be able to Google it.

markfinger commented 9 years ago

Latest release removes js-host. Should be easier to debug

musicformellons commented 9 years ago

Ah, thx. I will check later!

2015-07-13 4:58 GMT+02:00 Mark Finger notifications@github.com:

Latest release removes js-host. Should be easier to debug

— Reply to this email directly or view it on GitHub https://github.com/markfinger/python-react/issues/43#issuecomment-120792673 .