Skip to content

Commit

Permalink
edited config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimivantang committed Aug 25, 2016
1 parent 3d5571d commit 489fb52
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ltadatamallcrawler/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from __future__ import print_function
import os, re, yaml
import sys


#define the regex pattern that the parser will use to 'implicitely' tag your node
Expand All @@ -20,10 +22,20 @@ def pathex_constructor(loader,node):
yaml.add_constructor('!pathex', pathex_constructor)


def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)


with open('settings.yaml', 'r') as stream:
try:
settings = yaml.load(stream)
except yaml.YAMLError as e:
print(e)
eprint(e)
settings = {}
except KeyError as e:
eprint("this will not work unless you set environment variable for %s" %(e.message))
if e.message == 'LTADATAMALLKEY':
eprint("e.g. echo 'export %s=%s'" %(e.message,"<INSERT YOUR LTA DATAMALL API KEY>"))
elif e.message =='LTADATAMALLGUUID':
eprint("e.g. echo 'export %s=%s'" %(e.message,"<INSERT YOUR LTA DATAMALL GUUID>"))
settings = {}

0 comments on commit 489fb52

Please sign in to comment.