namesilo_api can also be set in settings.conf #1

Merged
sipp11 merged 1 commits from conf into master 5 years ago
  1. 3
      README.md
  2. 12
      update.py

3
README.md

@ -2,13 +2,14 @@
## Prerequisite
`NAMESILO_API` in environment variable
`NAMESILO_API` in environment variable or in `settings.conf`
`settings.conf` in the same directory
[default]
domain=example.com
subdomain=dynamic
namesilo_api=SECRET_KEY
### Python3 library

12
update.py

@ -62,15 +62,17 @@ def update_namesilo_data(key, domain, rrid, subdomain, new_value):
def main():
api_key = os.environ['NAMESILO_API']
if not api_key:
print('NAMESILO_API in env is not found.')
sys.exit()
print('KEY: {}...'.format(api_key[:3]))
config = configparser.ConfigParser()
config.read('settings.conf')
domain = config['default']['domain']
subdomain = config['default']['subdomain']
api_key = os.environ.get('NAMESILO_API', None)
if not api_key:
if 'namesilo_api' not in config['default']:
print('NAMESILO_API not found.')
sys.exit()
api_key = config['default']['namesilo_api']
print('KEY: {}...'.format(api_key[:3]))
target = '{}.{}'.format(subdomain, domain)
print('TARGET: {}'.format(target))
public_ip = get_public_ip()

Loading…
Cancel
Save