mirror of
https://github.com/quantum5/cfwatch.git
synced 2025-04-24 11:31:58 -04:00
Change to load keys from environment variable
This commit is contained in:
parent
a4f45b1877
commit
69b735b9cb
10
README.rst
10
README.rst
|
@ -17,14 +17,11 @@ Usage
|
|||
|
||||
$ pip install cfwatch
|
||||
$ cfwatch --help
|
||||
usage: cfwatch.py [-h] [-l LOG] email token zone prefix [dir]
|
||||
usage: cfwatch.py [-h] [-l LOG] zone prefix [dir]
|
||||
|
||||
Purges CloudFlare on local file change.
|
||||
|
||||
positional arguments:
|
||||
email CloudFlare login email (e.g. user@example.com)
|
||||
token CloudFlare API key (e.g.
|
||||
c2547eb745079dac9320b638f5e225cf483cc5cfdda41)
|
||||
zone CloudFlare zone (e.g. example.com)
|
||||
prefix CloudFlare path prefix (e.g. http://example.com/)
|
||||
dir directory to watch, i.e. file.txt this directory is
|
||||
|
@ -34,5 +31,10 @@ Usage
|
|||
-h, --help show this help message and exit
|
||||
-l LOG, --log LOG log file
|
||||
|
||||
When running ``cfwatch``, you must set the following environment variables:
|
||||
|
||||
* ``CFWATCH_EMAIL`` to your CloudFlare login email (e.g. user@example.com)
|
||||
* ``CFWATCH_TOKEN`` to your CloudFlare API key
|
||||
|
||||
.. |pypi| image:: https://img.shields.io/pypi/v/cfwatch.svg
|
||||
:target: https://pypi.python.org/pypi/cfwatch
|
||||
|
|
20
cfwatch.py
20
cfwatch.py
|
@ -1,6 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from threading import Lock, Event, Thread
|
||||
|
||||
try:
|
||||
|
@ -138,8 +141,6 @@ def main():
|
|||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='Purges CloudFlare on local file change.')
|
||||
parser.add_argument('email', help='CloudFlare login email (e.g. user@example.com)')
|
||||
parser.add_argument('token', help='CloudFlare API key (e.g. c2547eb745079dac9320b638f5e225cf483cc5cfdda41)')
|
||||
parser.add_argument('zone', help='CloudFlare zone (e.g. example.com)')
|
||||
parser.add_argument('prefix', help='CloudFlare path prefix (e.g. http://example.com/)')
|
||||
parser.add_argument('dir', nargs='?', default='.',
|
||||
|
@ -151,7 +152,20 @@ def main():
|
|||
|
||||
logging.basicConfig(filename=args.log, format='%(asctime)-15s %(message)s', level=logging.INFO)
|
||||
|
||||
monitor = CloudFlareMonitorHandler(args.email, args.token, args.zone, args.prefix, args.dir)
|
||||
email = os.environ.get('CFWATCH_EMAIL')
|
||||
token = os.environ.get('CFWATCH_TOKEN')
|
||||
|
||||
if not email:
|
||||
print('CFWATCH_EMAIL environment variable must be set to CloudFlare login email '
|
||||
'(e.g. user@example.com)', file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
if not token:
|
||||
print('CFWATCH_TOKEN environment must set to CloudFlare API key '
|
||||
'(e.g. c2547eb745079dac9320b638f5e225cf483cc5cfdda41)', file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
monitor = CloudFlareMonitorHandler(email, token, args.zone, args.prefix, args.dir)
|
||||
monitor.run()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue