Skip to content

labteral/safemode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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