protect main

This commit is contained in:
Dima Gerasimov 2019-04-30 12:53:59 +02:00
parent a0916ed6bd
commit 22c06a48e1

View file

@ -5,12 +5,13 @@ from location import get_logger, get_locations, iter_locations, get_groups
from kython.klogging import setup_logzero from kython.klogging import setup_logzero
logger = get_logger() def main():
setup_logzero(logger, level=logging.INFO) logger = get_logger()
setup_logzero(logger, level=logging.INFO)
if len(sys.argv) > 1: if len(sys.argv) > 1:
cmd = sys.argv[1] cmd = sys.argv[1]
if cmd == "update_cache": if cmd == "update_cache":
from location import update_cache, get_locations from location import update_cache, get_locations
@ -18,7 +19,10 @@ if len(sys.argv) > 1:
get_locations(cached=True) get_locations(cached=True)
else: else:
raise RuntimeError(f"Unknown command {cmd}") raise RuntimeError(f"Unknown command {cmd}")
else: else:
for p in get_groups(cached=True): for p in get_groups(cached=True):
print(p) print(p)
# TODO need datetime! # TODO need datetime!
if __name__ == '__main__':
main()