Get it all working

This commit is contained in:
Reid 'arrdem' McKenzie 2021-05-08 19:33:37 -06:00
parent 0654ae2847
commit b7e35bcc2a
9 changed files with 43 additions and 23 deletions

1
.gitignore vendored
View file

@ -10,3 +10,4 @@
bazel-*
tmp/
public/
projects/public-dns/config.yml

View file

@ -1,10 +1,12 @@
package(default_visibility = ["//visibility:public"])
py_library(
name = "gandi",
src = globs(["src/python/**/*.py"]),
srcs = glob(["src/python/gandi/client.py"], []),
imports = [
"src/python"
],
deps = [
py_requirement("requests"),
]
],
)

View file

@ -1,7 +0,0 @@
python_library(
name="gandi",
sources=globs("*.py"),
dependencies=[
"//3rdparty/python:requests",
]
)

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

View file

@ -1,6 +1,8 @@
aiohttp==3.7.4.post0
alabaster==0.7.12
anosql==1.0.2
appdirs==1.4.4
async-timeout==3.0.1
attrs==20.3.0
autoflake==1.4
Babel==2.9.0
@ -24,7 +26,9 @@ livereload==2.6.3
lxml==4.6.3
m2r==0.2.1
MarkupSafe==1.1.1
meraki==1.7.2
mistune==0.8.4
multidict==5.1.0
mypy-extensions==0.4.3
openapi-schema-validator==0.1.5
openapi-spec-validator==0.3.0
@ -45,6 +49,7 @@ pytest-pudb==0.7.0
pytz==2021.1
PyYAML==5.4.1
recommonmark==0.7.1
redis==3.5.3
regex==2021.4.4
requests==2.25.1
six==1.15.0
@ -70,3 +75,4 @@ urllib3==1.26.4
urwid==2.1.2
wcwidth==0.2.5
yamllint==1.26.1
yarl==1.6.3