Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added separate config #4793

Merged
merged 2 commits into from
Aug 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ configs/*
!configs/path.example.json
!config.json.cluster.example
!config.json.optimizer.example
!auth.json.example

# Virtualenv folders
bin/
Expand Down
11 changes: 11 additions & 0 deletions configs/auth.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"favorite_locations":[
{"name": "Milan", "coords": "45.472849,9.177567"}
],
"gmapkey": "GOOGLE_MAPS_API_KEY",
"encrypt_location": ""
}
9 changes: 0 additions & 9 deletions configs/config.json.cluster.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"favorite_locations":[
{"name": "Milan", "coords": "45.472849,9.177567"}
],
"gmapkey": "GOOGLE_MAPS_API_KEY",
"encrypt_location": "",
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
Expand Down
9 changes: 0 additions & 9 deletions configs/config.json.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"favorite_locations":[
{"name": "Milan", "coords": "45.472849,9.177567"}
],
"gmapkey": "GOOGLE_MAPS_API_KEY",
"encrypt_location": "",
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
Expand Down
9 changes: 0 additions & 9 deletions configs/config.json.map.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"favorite_locations":[
{"name": "Milan", "coords": "45.472849,9.177567"}
],
"gmapkey": "GOOGLE_MAPS_API_KEY",
"encrypt_location": "",
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
Expand Down
9 changes: 0 additions & 9 deletions configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"favorite_locations":[
{"name": "Milan", "coords": "45.472849,9.177567"}
],
"gmapkey": "GOOGLE_MAPS_API_KEY",
"encrypt_location": "",
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
Expand Down
9 changes: 0 additions & 9 deletions configs/config.json.path.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"favorite_locations":[
{"name": "Milan", "coords": "45.472849,9.177567"}
],
"gmapkey": "GOOGLE_MAPS_API_KEY",
"encrypt_location": "",
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
Expand Down
9 changes: 0 additions & 9 deletions configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"favorite_locations":[
{"name": "Milan", "coords": "45.472849,9.177567"}
],
"gmapkey": "GOOGLE_MAPS_API_KEY",
"encrypt_location": "",
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
Expand Down
23 changes: 13 additions & 10 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,19 @@ def _json_loader(filename):

# Select a config file code
parser.add_argument("-cf", "--config", help="Config File to use")
config_arg = parser.parse_known_args() and parser.parse_known_args()[0].config or None

if config_arg and os.path.isfile(config_arg):
_json_loader(config_arg)
config_file = config_arg
elif os.path.isfile(config_file):
logger.info('No config argument specified, checking for /configs/config.json')
_json_loader(config_file)
else:
logger.info('Error: No /configs/config.json or specified config')
parser.add_argument("-af", "--auth", help="Auth File to use")

for _config in ['auth', 'config']:
config_arg = parser.parse_known_args() and parser.parse_known_args()[0].__dict__[_config] or None

if config_arg and os.path.isfile(config_arg):
_json_loader(config_arg)
config_file = config_arg if _config == 'config' else config_file
elif os.path.isfile(config_file):
logger.info('No ' + _config + ' argument specified, checking for /configs/' + _config + '.json')
_json_loader(config_file)
else:
logger.info('Error: No /configs/config.json or specified config')

# Read passed in Arguments
required = lambda x: not x in load
Expand Down
3 changes: 2 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ read -p "Input gmapkey
[[ $auth = "2" || $auth = "ptc" ]] && auth="ptc" || auth="google"
sed -e "s/YOUR_USERNAME/$username/g" -e "s/YOUR_PASSWORD/$password/g" \
-e "s/SOME_LOCATION/$location/g" -e "s/GOOGLE_MAPS_API_KEY/$gmapkey/g" \
-e "s/google/$auth/g" configs/config.json.example > configs/config.json
-e "s/google/$auth/g" configs/auth.json.example > configs/auth.json
cp configs/config.json.example configs/config.json
echo "Edit ./configs/config.json to modify any other config."
}

Expand Down
3 changes: 2 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def get_fake_conf():
class ConfObj:
pass

conf_dict = json.load(open('configs/config.json.example'))
conf_dict = json.load(open('configs/auth.json.example'))
conf_dict.update(json.load(open('configs/config.json.example')))
conf_obj = ConfObj()
for key, value in conf_dict.items():
setattr(conf_obj, key, value)
Expand Down