Skip to content

Commit

Permalink
Move configs to examples (PokemonGoF#1574)
Browse files Browse the repository at this point in the history
* .gitignore doesn't ignore these because they exist
* move them to example files that users can copy to non-example
  files which gitignore will now ignore
* if the user didn't copy and modify them before running the app,
  do the the courtesy of copying the configs in for them
  • Loading branch information
invisiblek authored and MonkeyLeeT committed Jul 23, 2016
1 parent 96bb0ca commit 41353ac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions pogom/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@
from datetime import datetime, timedelta
import ConfigParser
import platform
import logging
import shutil

from . import config

from exceptions import APIKeyException

DEFAULT_THREADS = 1

logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(module)11s] [%(levelname)7s] %(message)s')
log = logging.getLogger(__name__)

def parse_unicode(bytestring):
decoded_string = bytestring.decode(sys.getfilesystemencoding())
return decoded_string

def verify_config_file_exists(filename):
fullpath = os.path.join(os.path.dirname(__file__), filename)
if os.path.exists(fullpath) is False:
log.info("Could not find " + filename + ", copying default")
shutil.copy2(fullpath + '.example', fullpath)

def parse_config(args):
verify_config_file_exists('../config/config.ini')
Config = ConfigParser.ConfigParser()
Config.read(os.path.join(os.path.dirname(__file__), '../config/config.ini'))
args.auth_service = Config.get('Authentication', 'Service')
Expand All @@ -39,6 +51,7 @@ def parse_config(args):
return args

def parse_db_config(args):
verify_config_file_exists('../config/config.ini')
Config = ConfigParser.ConfigParser()
Config.read(os.path.join(os.path.dirname(__file__), '../config/config.ini'))
args.db_type = Config.get('Database','Type')
Expand Down Expand Up @@ -150,6 +163,7 @@ def get_pokemon_name(pokemon_id):
return get_pokemon_name.names[str(pokemon_id)]

def load_credentials(filepath):
verify_config_file_exists('../config/credentials.json')
try:
with open(filepath+os.path.sep+'/config/credentials.json') as file:
creds = json.load(file)
Expand Down

0 comments on commit 41353ac

Please sign in to comment.