Debugging Frappe with PyCharm

Hi Everyone
Trying to debug the Frappe for the first time, followed this link Pycharm Debugging - #5 by hpema108
put a line break in init.py. The complier breaks fine and I can step through the code. The problem is I am getting
Permission denied: ‘/home/frappeuser/frappe-bench/logs/bench.log’
when I run through __init__py, deleted bench.log and started again still to no avail.

Traceback (most recent call last):
File “/usr/lib/pycharm/helpers/pydev/pydevd.py”, line 1580, in
globals = debugger.run(setup[‘file’], None, None, is_module)
File “/usr/lib/pycharm/helpers/pydev/pydevd.py”, line 964, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/usr/bin/bench-repo/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1057, in invoke
Command.invoke(self, ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/usr/bin/bench-repo/bench/commands/init.py”, line 21, in bench_command
setup_logging(bench_path=bench_path)
File “/usr/bin/bench-repo/bench/utils.py”, line 265, in setup_logging
hdlr = logging.FileHandler(log_file)
File “/usr/lib/python2.7/logging/init.py”, line 903, in init
StreamHandler.init(self, self._open())
File “/usr/lib/python2.7/logging/init.py”, line 928, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: ‘/home/frappeuser/frappe-bench/logs/bench.log’
not sure why. Now I can run bench start fine from frappeuser folder.

OK I actually logged in as FrappeUser on my ubuntu desktop, configured PyCharm for the frappe user and ran debug bench and all started fine.
I want to step through more code, not sure which file I should place a breakpoint immediately after bench start. your help much appreciated.

Please refer 17/22 in the following thread, you may find it useful

Thanks Pawan, I made some progress using the link from Fellipeh in my original post. I am still trying to find my way through, looking for the entry point to Frappe just after bench start,

@CoffeeHolic,

check app.py, all the requests are processed by application method.

Thanks, Makarand

Thanks Makarand, finally I see some light at the end of the tunnel, spot on mate.
Actually these are my settings
script: /usr/local/bin/bench
params: start
python interpreter: python 2.7.6
working dir : /home/frappuser/frappe-bench
put break points in bench and cli.py and the compiler breaks HOWEVER, when I debug app.py it does not break. It goes past through and starts bench. I posted a screen shot of the break point in app.py - I added print ‘here’ in app.py,
http://imgur.com/a/ukAi9
I see it in the console log but IT DOES NOT BREAK. It is really a great start,

1 Like

@CoffeeHolic Have you made any progress here, I have the same issue exactly.
appreciate any help.

No I have not really. it does not seem to be possible with the new version
of ERPNext I have tried all threads in forum to no avail.

Thanks, I appreciate your response.