Decoupled credentials from argparse into configuration file

Signed-off-by: Pierros Papadeas <pierros@papadeas.gr>
merge-requests/18/head
Pierros Papadeas 2019-05-10 10:20:47 +03:00
parent 02ec88ba03
commit 289bad05cb
No known key found for this signature in database
GPG Key ID: 8DB97129D9982991
7 changed files with 61 additions and 12 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
__pycache__/
*.py[cod]
*$py.class
.env

View File

@ -10,6 +10,11 @@ SatNOGS network. It uses code from the SatNOGS network scheduler. It requires
pip install -r requirements.txt
```
## Configuration
Copy the env-dist file to .env and set your legacy SatNOGS Network credentials.
## Usage
The following command will list all available command-line arguments:
@ -19,4 +24,4 @@ The following command will list all available command-line arguments:
## License
[![license](https://img.shields.io/badge/license-AGPL%203.0-6672D8.svg)](LICENSE)
Copyright 2018 - Cees Bassa, Fabian Schmidt, Pierros Papadeas
Copyright 2019 - Cees Bassa, Fabian Schmidt, Pierros Papadeas

5
env-dist 100644
View File

@ -0,0 +1,5 @@
# Copy this file to .env and complete the information needed
# Username and password to SatNOGS Network using the old authentication system
NETWORK_USERNAME = ''
NETWORK_PASSWORD = ''

View File

@ -3,3 +3,4 @@ satellitetle>=0.5.0
requests
lxml
tqdm
python-decouple

View File

@ -90,9 +90,6 @@ def main():
parser.add_argument("-w", "--wait",
help="Wait time between consecutive observations (for setup and slewing)" +
" [seconds; default: 0.0]", type=float, default=0)
parser.add_argument("-u", "--username",
help="old SatNOGS Network username (NOT the new Auth0 username)")
parser.add_argument("-p", "--password", help="old SatNOGS Network password")
parser.add_argument("-n", "--dryrun", help="Dry run (do not schedule passes)",
action="store_true")
parser.add_argument("-P", "--priorities", help="File with transmitter priorities. Should have" +
@ -124,8 +121,6 @@ def main():
if wait_time_seconds < 0:
wait_time_seconds = 0.0
cache_dir = "/tmp/cache"
username = args.username
password = args.password
schedule = not args.dryrun
search_transmitters = args.search_transmitters
priority_filename = args.priorities
@ -328,8 +323,8 @@ def main():
login_hidden_inputs = login_html.xpath(
r'//form//input[@type="hidden"]') # Get CSFR token
form = {x.attrib["name"]: x.attrib["value"] for x in login_hidden_inputs}
form["login"] = username
form["password"] = password
form["login"] = settings.NETWORK_USERNAME
form["password"] = settings.NETWORK_PASSWORD
# Login
result = session.post(loginUrl,

View File

@ -1,4 +1,11 @@
DB_BASE_URL = 'https://db.satnogs.org'
NETWORK_BASE_URL = 'https://network.satnogs.org'
CACHE_AGE = 24
MAX_NORAD_CAT_ID = 90000
from decouple import config
# Basic settings
DB_BASE_URL = config('DB_BASE_URL', default='https://db.satnogs.org')
NETWORK_BASE_URL = config('NETWORK_BASE_URL', default='https://network.satnogs.org')
CACHE_AGE = config('CACHE_AGE', default=24)
MAX_NORAD_CAT_ID = config('CACHE_AGE', default=90000)
# Credentials
NETWORK_USERNAME = config('NETWORK_USERNAME', default='')
NETWORK_PASSWORD = config('NETWORK_PASSWORD', default='')

35
setup.cfg 100644
View File

@ -0,0 +1,35 @@
[metadata]
name = satnogs-auto-scheduler
url = https://gitlab.com/librespacefoundation/satnogs/satnogs-auto-scheduler
author = SatNOGS project
author_email = dev@satnogs.org
license = AGPLv3
classifiers =
Development Status :: 4 - Beta
Environment :: Console
Intended Audience :: Telecommunications Industry
Intended Audience :: Science/Research
License :: OSI Approved :: GNU Affero General Public License v3
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 3.7
Topic :: Communications :: Ham Radio
description = SatNOGS Auto Scheduler
[options]
packages = find:
include_package_data = True
install_requires =
# Basic
requests
lxml
tqdm
python-decouple
# Astronomy
satellitetle~=0.6.0
ephem
[flake8]
max-complexity = 25
max-line-length = 100
ignore = F403,W504