Get it all working

This commit is contained in:
Reid 'arrdem' McKenzie 2021-05-08 19:33:37 -06:00
commit b7e35bcc2a
9 changed files with 43 additions and 23 deletions
projects/public-dns
BUILD
src/python/arrdem/updater

View file

@ -1,9 +1,10 @@
py_binary(
name = "updater",
entry_point = "src/python/arrdem/updater/__main__.py",
main = "src/python/arrdem/updater/__main__.py",
deps = [
"//projects/gandi",
py_requirement("jinja2"),
py_requirement("pyyaml"),
]
py_requirement("meraki"),
],
)

View file

@ -1,12 +0,0 @@
python_binary(
name='updater',
source='__main__.py',
dependencies=[
"//src/resources/zonefiles",
"//src/python/gandi",
"//3rdparty/python:requests",
"//3rdparty/python:jinja2",
"//3rdparty/python:PyYAML",
"//3rdparty/python:meraki",
]
)

View file

@ -2,6 +2,35 @@
A quick and dirty public DNS script, super tightly coupled to my infrastructure.
"""
import sys
import os
def module_not_found_helper(excepthook):
def _helper(type, value, traceback):
if isinstance(value, ModuleNotFoundError):
path_fragment = value.name.replace(".", os.path.sep)
flag = False
for e in sys.path:
init = os.path.join(e, path_fragment, "__init__.py")
namedfile = os.path.join(e, path_fragment + ".py")
if os.path.exists(init):
print(f"Found candidate {init}", file=sys.stderr)
flag |= True
else:
print(f"{init} does not exist")
if os.path.exists(namedfile):
print(f"Found candidate {namedfile}", file=sys.stderr)
flag |= True
else:
print(f"{namedfile} does not exist")
if not flag:
print(f"Found no candidates on the PYTHONPATH", file=sys.stderr)
excepthook(type, value, traceback)
return _helper
sys.excepthook = module_not_found_helper(sys.excepthook)
import argparse
import re
from pprint import pprint