TaIos / comitee

Task from NI-PYT at FIT CTU
MIT License
0 stars 0 forks source link

NI-PYT: task 2 help with pythonanwhere #2

Closed TaIos closed 3 years ago

TaIos commented 4 years ago

Got stuck at this error from pythonanywhere (most likely):

unable to load configuration from committee.cfg

Error is produced here to stderr after GitHub sends payload with push event.

Application otherwise works as expected: http://talos.pythonanywhere.com/ Running application at localhost and mocking GitHub payloads works without this error and sets correct status.

MarekSuchanek commented 3 years ago

My guess is that you use some relative path for config file... maybe even just "committee.cfg"? And the, because you are using (surprisingly) subprocess it is launched in different directory then you expect.

It is over-complicated solution (and potentially also slow as you spawn sequentially subprocesses for each pushed commit, load configuration again, etc.), why you don't just make and re-use a function for processing a single commit?

hroncok commented 3 years ago

See also:

https://github.com/TaIos/comitee/blob/1518f427b01fecca4ebefbc78d1474edcd03e189/committee.py#L200

Yet the function reuses app.config['config_path'] instead of os.path.abspath(...).

As @MarekSuchanek says, calling the CLI tool via subprocess from the Flask response is a tad creepy.

TaIos commented 3 years ago

Solved by not using subprocess in pythonanywhere environment. Closing issue.

TL;DR @MarekSuchanek

My guess is that you use some relative path for config file...

After changing all relative paths to absolute, error changed to unable to load configuration from /home/talos/comitee/committee.cfg.

Mayby the problem was caused by sys.executable in subprocess, which is translated to /usr/local/bin/uwsgi ? https://github.com/TaIos/comitee/blob/1518f427b01fecca4ebefbc78d1474edcd03e189/committee.py#L157