labteral / safemode

Launch a shell if any key is pressed during a grace period

Home Page:https://pypi.org/project/safemode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

safemode

Replace the Python process with a shell when starting up if a key is pressed during a grace period.

Install

pip install safemode

Usage

Just import the library in the first line of your Python script. The grace period can be configured through the SAFEMODE_GRACE_PERIOD environment variable. The default value is 5 seconds.

main.py

import safemode
print('Hello World')

Safe mode:

$ python main.py
[safemode] To start a shell, press any key before 5 seconds...
$

Normal execution:

$ python main.py
[safemode] To start a shell, press any key before 5 seconds...
[safemode] Starting up normally...
Hello World

About

Launch a shell if any key is pressed during a grace period

https://pypi.org/project/safemode

License:GNU General Public License v3.0


Languages

Language:Python 97.1%Language:Shell 2.9%