Skip to main content

zc.monitorpdb

zc.montorpdb is a small plugin for the (very) lightweight zc.monitor system. It allows a user to telnet to a monitor port and invoke a Python debugger (PDB) prompt.

To use it, one must first register the command so zc.monitor is aware of it.

>>> import zc.monitorpdb
>>> import zope.component
>>> import zc.monitor.interfaces
>>> zope.component.provideUtility(zc.monitorpdb.command,
...     zc.monitor.interfaces.IMonitorPlugin, 'pdb')

Since zc.monitor is implemented with zc.ngi, we can use zc.ngi’s testing helpers.

>>> import zc.ngi.testing
>>> connection = zc.ngi.testing.TextConnection()
>>> server = zc.monitor.Server(connection)

If we invoke the command, we’ll get the appropriate prompt.

>>> connection.test_input('pdb\n')
(Pdb)

Now we can do normal pdb things like list the code being executed.

>>> connection.test_input('l\n')
 34             global fakeout
 35
 36             fakeout = FakeStdout(connection.connection)
 37             debugger = pdb.Pdb(stdin=None, stdout=fakeout)
 38             debugger.reset()
 39  ->         debugger.setup(sys._getframe(), None)
 40
 41
 42         def command(connection, *args):
 43             global debugger
 44             global fakeout
(Pdb)

As well as go “up” in the function call stack.

>>> connection.test_input('u\n')
>   /graphted-storage/workspace/zc.monitorpdb/src/zc/monitorpdb/__init__.py(48)command()
-> reset(connection)
(Pdb)

There is a “reset” command that gives us a fresh debugger (just in case something bad happend to ours and we don’t want to restart the host process). Here we go from the current location being one thing (the result of the previous “u” command) to another.

>>> connection.test_input('l\n')
 57                 return zc.monitor.QUIT_MARKER
 58             else:
 59                 debugger.onecmd(' '.join(args))
 60
 61             connection.write(debugger.prompt)
 62  ->         return zc.monitor.MORE_MARKER
[EOF]
(Pdb)
>>> connection.test_input('reset\n')
(Pdb)
>>> connection.test_input('l\n')
 34             global fakeout
 35
 36             fakeout = FakeStdout(connection.connection)
 37             debugger = pdb.Pdb(stdin=None, stdout=fakeout)
 38             debugger.reset()
 39  ->         debugger.setup(sys._getframe(), None)
 40
 41
 42         def command(connection, *args):
 43             global debugger
 44             global fakeout
(Pdb)

Some features don’t work, however.

>>> connection.test_input('debug 1+1\n')
the "debug" command is not supported
(Pdb)

Once we’re done, we ask to be let go.

>>> connection.test_input('quit\n')
-> CLOSE

Metadata

Release files for zc.monitorpdb 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zc.monitorpdb 1.0.0
File Size Uploaded Provenance Actions
zc.monitorpdb-1.0.0.tar.gz 3.6 kB Without provenance Details for zc.monitorpdb-1.0.0.tar.gz

Release files / zc.monitorpdb-1.0.0.tar.gz

Download URL zc.monitorpdb-1.0.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5ca84dd05e30cf8485c922526442cf701fee9e67349dd469efdd85040d9f6a55
BLAKE2b-256 checksum
How to use checksums
8fe993db80c1bcdcf849e5aa0e6781c68ad85f4411416badf743593f26d80896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for zc.monitorpdb 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page