Skip to content

caioariede/pyintercept

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyintercept

Intercept function calls from Python scripts

Build Status

Installation

pip install pyintercept

Examples

Reading information from setup.py files

python -m pyintercept setup.py setuptools.setup --args=install --handler=pyintercept.print
{"name": "pyintercept", "license": "MIT", "author": "Caio Ariede", "author_email": "caio.ariede gmail.com", "include_package_data": true, "url": "http://github.com/caioariede/pyintercept", "version": "0.1", "zip_safe": false, "platforms": ["any"], "install_requires": ["byteplay"], "packages": ["pyintercept", "pyintercept.handlers"], "classifiers": ["Intended Audience :: Developers", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4"], "description": "Intercept function calls from Python scripts"}

Intercepting functions with pdb

python -m pyintercept setup.py setuptools.setup --handler=pyintercept.pdb

This will call pdb before any calls to setuptools.setup

Writing your own interceptor

Let's print the settings file to be used in a Django project.

print_settings.py

def handler(origfn, *args, **kwargs):
    import os
    print(os.environ["DJANGO_SETTINGS_MODULE"])
python -m pyintercept manage.py django.core.management.execute_from_command_line --handler=print_settings.handler

License

MIT

About

Intercept function calls from Python scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages