Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/bin/env python 

2# (c) Stefan Countryman, 2019 

3 

4""" 

5Launch the LLAMA GCN poller. 

6""" 

7 

8from argparse import ArgumentParser, RawDescriptionHelpFormatter 

9from time import sleep 

10import logging 

11from llama.poll.gracedb import ( 

12 GRACEDB_POLL_LOGFILE, 

13 LOGGER, 

14 LOOKBACK, 

15 fetch_recent, 

16 __doc__ as initdoc, 

17) 

18from llama.utils import ( 

19 __version__, 

20 LOG_FORMATTER, 

21) 

22 

23# TODO set up logger using daemonizing tools 

24 

25 

26def get_parser(): 

27 """Get CLI parser.""" 

28 parser = ArgumentParser(description=__doc__+initdoc, 

29 formatter_class=RawDescriptionHelpFormatter) 

30 return parser 

31 

32 

33def main(): 

34 """Run CLI.""" 

35 parser = get_parser() 

36 parser.parse_args() 

37 log_file = logging.FileHandler(GRACEDB_POLL_LOGFILE, 'a') 

38 log_file.setFormatter(LOG_FORMATTER) 

39 LOGGER.addHandler(log_file) 

40 LOGGER.info("Running GCN GraceDb poller. LLAMA version %s", __version__) 

41 while True: 

42 LOGGER.info("Fetching superevents from last %s seconds.", LOOKBACK) 

43 fetch_recent() 

44 LOGGER.info("Sleeping for 10 minutes...") 

45 sleep(10*60) 

46 

47 

48if __name__ == "__main__": 

49 main()