Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. def init_app():
  2.     '''
  3.    Method for reading the settings.ini file and get the useful information out of it
  4.    
  5.    Returns
  6.    -------
  7.    environment : str
  8.        String containing the environment we are using. (dev,qa,prd)
  9.    application : str
  10.        String containing the application we are using. (tips,achievements, etc..)
  11.    test_mode : int
  12.        (0,1), 1 if execution should be done in test mode, 0 if not (not implemented yet)
  13.    
  14.    '''
  15.     try:
  16.        
  17.         module_path = path.dirname(path.abspath(__file__))
  18.         config_file_path = module_path + '/settings.ini'
  19.         print("Script running on the production machine")
  20.     except NameError:
  21.         print("Script running on the sandbox machine")
  22.         config_file_path = "settings.ini"
  23.     config = configparser.ConfigParser()
  24.     config.read(config_file_path)
  25.     environment = config.get("App_info", "environment")
  26.     application = config.get("App_info", "application")
  27.     user = config.get("App_info", "user")
  28.     password = config.get("App_info", "password")
  29.     return environment,application,user,password
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement