-
Notifications
You must be signed in to change notification settings - Fork 0
/
local.py
39 lines (32 loc) · 1.05 KB
/
local.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Standard library
import json
import logging
import os
import sys
# Local
from InputBlobTrigger import main
logging.basicConfig(
datefmt=r"%Y-%m-%d %H:%M:%S",
format="{asctime:s} {levelname:<8s} {module:>10s}.{funcName:<25s} {message:s}",
level=logging.INFO,
style="{",
)
class FileSystemBlob:
def __init__(self, filename):
self.name = filename
self.length = 0
def read(self):
return open(self.name, "rb").read()
if __name__ == "__main__":
settings = json.load(open(os.path.join(sys.path[0], "local.settings.json"), "r"))
if len(sys.argv) > 1:
filename = sys.argv[1]
os.environ["PSQL_HOST"] = os.getenv(
"PSQL_HOST", settings["Values"]["PSQL_HOST"]
)
os.environ["PSQL_DB"] = os.getenv("PSQL_DB", settings["Values"]["PSQL_DB"])
os.environ["PSQL_USER"] = os.getenv(
"PSQL_USER", settings["Values"]["PSQL_USER"]
)
os.environ["PSQL_PWD"] = os.getenv("PSQL_PWD", settings["Values"]["PSQL_PWD"])
main(FileSystemBlob(filename))