escape python hell

This commit is contained in:
2025-10-28 05:15:22 -05:00
parent 18947b60c0
commit 648aa6472c
8 changed files with 124 additions and 59 deletions

1
skitter/__init__.py Normal file
View File

@@ -0,0 +1 @@
#!/usr/bin/env python3

38
skitter/__main__.py Normal file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python3
"""
yap yap yap
"""
import getopt
import sys
from skitter.usage import print_help
def main():
'''main'''
try:
opts, args = getopt.getopt(sys.argv[1:],
"hb:o:s:r:",
["help", "band=", "out-directory=", "squelch=", "rate="])
except getopt.GetoptError:
print_help()
sys.exit(2)
for o, a in opts:
if o in ('-h', '--help'):
print_help()
sys.exit()
if o in ('-b', '--band'):
print(f"band {a}") # debug
if o in ('-o', '--out-directory'):
print(f"dir {a}") # debug
if o in ('-s', '--squelch'):
print(f"squelch {a}") # debug
if o in ('-r', '--rate'):
print(f"rate {a}") # debug
if __name__ == '__main__':
main()

62
skitter/usage.py Normal file
View File

@@ -0,0 +1,62 @@
#!/usr/bin/env python3
"help page"
from os import getenv
def print_help():
"""print help"""
NAME = "skitter.py"
VERSION = "0.0.0"
BANNER = '''\x1b[34m
▗▖ █ ▄
▐▌ ▀ ▐▌ ▐▌ █
▗▟██▖▐▌▟▛ ██ ▐███ ▐███ ▟█▙ █▟█▌ █
▐▙▄▖▘▐▙█ █ ▐▌ ▐▌ ▐▙▄▟▌ █▘ █
▀▀█▖▐▛█▖ █ ▐▌ ▐▌ ▐▛▀▀▘ █ ▀
▐▄▄▟▌▐▌▝▙ ▗▄█▄▖ ▐▙▄ ▐▙▄ ▝█▄▄▌ █ ▄
▀▀▀ ▝▘ ▀▘▝▀▀▀▘ ▀▀ ▀▀ ▝▀▀ ▀ ▀
\x1b[0m'''
USAGE = f'''
SYNOPSIS
{NAME} [--band=|-b FREQ] [--out-directory=|-o DIR] [--squelch=|-s LEVEL] [--rate=|-r SPEED]
{NAME} [--help|-h]
--band
-b
Desired frequencies (list) to scan.
Skitter will sweep through these frequencies at a set rate.
--out-directory
-o
Output directory. Default: ./
Skitter will save its recordings in a single directory.
You might want to create a new directory for recordings.
--squelch
-s
Level at which to start listening, in decibels (dB).
Anything below this level will be ignored.
--rate
-r
Delay (in milliseconds) between changing channels.
Increase if your receiver cannot switch frequencies
quickly enough.
Default: UNSET
--help
-h
Print this message and exit.
Examples
{NAME} -r 300
Sweep through default range and change channels every 300 milliseconds.
{NAME} -o ~/Music/
Run with all default settings and send files to {getenv("HOME")}/Music
'''
print(BANNER)
print(f"skitter v\x1b[33m{VERSION}\x1b[0m")
print(USAGE)