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
|
$ pip install cfwatch
|
||||||
$ cfwatch --help
|
$ 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.
|
Purges CloudFlare on local file change.
|
||||||
|
|
||||||
positional arguments:
|
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)
|
zone CloudFlare zone (e.g. example.com)
|
||||||
prefix CloudFlare path prefix (e.g. http://example.com/)
|
prefix CloudFlare path prefix (e.g. http://example.com/)
|
||||||
dir directory to watch, i.e. file.txt this directory is
|
dir directory to watch, i.e. file.txt this directory is
|
||||||
|
@ -34,5 +31,10 @@ Usage
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-l LOG, --log LOG log file
|
-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
|
.. |pypi| image:: https://img.shields.io/pypi/v/cfwatch.svg
|
||||||
:target: https://pypi.python.org/pypi/cfwatch
|
:target: https://pypi.python.org/pypi/cfwatch
|
||||||
|
|
20
cfwatch.py
20
cfwatch.py
|
@ -1,6 +1,9 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from threading import Lock, Event, Thread
|
from threading import Lock, Event, Thread
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -138,8 +141,6 @@ def main():
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Purges CloudFlare on local file change.')
|
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('zone', help='CloudFlare zone (e.g. example.com)')
|
||||||
parser.add_argument('prefix', help='CloudFlare path prefix (e.g. http://example.com/)')
|
parser.add_argument('prefix', help='CloudFlare path prefix (e.g. http://example.com/)')
|
||||||
parser.add_argument('dir', nargs='?', default='.',
|
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)
|
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()
|
monitor.run()
|
||||||
|
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -8,7 +8,7 @@ with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='cfwatch',
|
name='cfwatch',
|
||||||
version='0.1.0',
|
version='0.2.0',
|
||||||
description="Automagically purges CloudFlare's cache when local files are updated.",
|
description="Automagically purges CloudFlare's cache when local files are updated.",
|
||||||
long_description=readme,
|
long_description=readme,
|
||||||
author='Quantum',
|
author='Quantum',
|
||||||
|
|
Loading…
Reference in a new issue