Skip to content

Commit

Permalink
Merge pull request #68 from plone/improve-pdb-experience
Browse files Browse the repository at this point in the history
Improve debugging of run scripts
  • Loading branch information
mauritsvanrees authored Jan 23, 2019
2 parents acaa2cf + fe6972e commit 9c3ec8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
6.1.1 (unreleased)
------------------

- Improve debugging of run scripts by providing the source code for the
debugger.
[icemac]

- log level for Plone WSGI logger changed to INFO making the logging less
verbose
[ajung]
Expand Down
20 changes: 14 additions & 6 deletions src/plone/recipe/zope2instance/ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,14 +739,22 @@ def do_run(self, arg):

# Remove -c and add script as sys.argv[0]
script = tup[0]
cmd = 'import sys; sys.argv.pop(); sys.argv.append(%r); ' % script
cmd = [
"import sys",
"sys.argv.pop()",
"sys.argv.append(%r)" % script,
]
if len(tup) > 1:
argv = tup[1:]
cmd += '[sys.argv.append(x) for x in %s]; ' % argv
cmd += (
"f = open(%r); src = f.read(); f.close(); exec(src)"
) % script
cmdline = self.get_startup_cmd(self.options.python, cmd)
cmd.append('[sys.argv.append(x) for x in %s]' % argv)
cmd.extend([
"f = open(%r)" % script,
"src = f.read()",
"f.close()",
"code = compile(src, filename=%r, mode='exec')" % script,
"exec(code)",
])
cmdline = self.get_startup_cmd(self.options.python, "; ".join(cmd))

self._exitstatus = os.system(cmdline)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ skip_missing_interpreters = False
[testenv]
usedevelop = true
commands =
coverage run {envbindir}/zope-testrunner --test-path=src
coverage run {envbindir}/zope-testrunner --test-path=src []
extras = test
deps =
-r https://zopefoundation.github.io/Zope/releases/4.0b7/requirements-full.txt
Expand Down

0 comments on commit 9c3ec8a

Please sign in to comment.