No project description provided
Project description
BODY SCAN
EXAMPLE OUTPUT:
{
"PATHS": [
{
"PATH": "PATH_1_HEALTH.py",
"STATS": {
"PASSES": 2,
"ALARMS": 1
},
"CHECKS": [
{
"CHECK": "CHECK 1",
"PASSED": true,
"ELAPSED": [
5.320599666447379e-05,
"SECONDS"
]
},
{
"CHECK": "CHECK 2",
"PASSED": true,
"ELAPSED": [
1.0949999705189839e-05,
"SECONDS"
]
},
{
"CHECK": "CHECK 3",
"PASSED": false,
"EXCEPTION": "Exception('NOT 100%')",
"EXCEPTION TRACE": [
"Traceback (most recent call last):",
" File \"/REPTILIAN_CLIMATES/MODULES/BODY_SCAN/src/SCAN_PROC/KEG/SCAN.py\", line 69, in SCAN",
" CHECKS [ CHECK ] ()",
" File \"<string>\", line 24, in CHECK_3",
"Exception: NOT 100%"
]
}
]
},
{
"PATH": "PATH_2_HEALTH.py",
"EMPTY": true
}
],
"STATS": {
"EMPTY": 1,
"CHECKS": {
"PASSES": 2,
"ALARMS": 1
}
}
}
HOW TO WRITE CHECKS:
The "CHECKS" dictionary is retrieved with the python "exec" and then each "CHECK" in "CHECKS" is run.
These checks correspond to the example output shown above.
PATH_1_HEALTH.py
def CHECK_1 ():
print ("CHECK 1")
def CHECK_2 ():
print ("CHECK 2")
def CHECK_3 ():
raise Exception ("NOT 100%")
CHECKS = {
"CHECK 1": CHECK_1,
"CHECK 2": CHECK_2,
"CHECK 3": CHECK_3
}
PATH_2_HEALTH.py
#
# There isn't a "CHECKS" dictionary present,
# so the scanner reports:
#
# "EMPTY": true
#
HOW TO START THE BODY SCANNER
import BODY_SCAN
import pathlib
THIS_FOLDER = pathlib.Path (__file__).parent.resolve ()
from os.path import dirname, join, normpath
SEARCH = normpath (join (THIS_FOLDER, "MODULE"))
SCAN = BODY_SCAN.START (
#
# REQUIRED
# This is all the files that are sent to the scanner.
#
GLOB = SEARCH + '/**/*HEALTH.py',
#
# OPTIONAL
# These are the folders that are added to "sys.path"
#
MODULE_PATHS = [
normpath (join (SEARCH, "MODULES"))
],
#
# OPTIONAL
# This is the folder path to remove from the paths in the output.
#
RELATIVE_PATH = SEARCH
)
NOTES
Currently all the checks aren't run in parallel,
but sequential order of paths found in glob is not guaranteed.
Each check suite found by the glob is started by
a process with a flask API, that is opened on the first available port found.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
BODY_SCAN-0.0.18.tar.gz
(7.2 kB
view hashes)