|
1 |
| -# Script Name : env_check.py |
2 |
| -# Author : Craig Richards |
3 |
| -# Created : 14th May 2012 |
4 |
| -# Last Modified : |
5 |
| -# Version : 1.0 |
| 1 | +# Script Name : env_check.py |
| 2 | +# Author : Craig Richards |
| 3 | +# Created : 14th May 2012 |
| 4 | +# Last Modified : 14 February 2016 |
| 5 | +# Version : 1.0.1 |
6 | 6 |
|
7 |
| -# Modifications : |
| 7 | +# Modifications : 1.0.1 - Tidy up comments and syntax |
8 | 8 |
|
9 |
| -# Description : This script will check to see if all of the environment variables I require are set |
| 9 | +# Description : This script will check to see if all of the environment variables I require are set |
10 | 10 |
|
11 | 11 | import os
|
12 | 12 |
|
13 |
| -confdir = os.getenv("my_config") # Set the variable confdir from the OS environment variable |
14 |
| -conffile = 'env_check.conf' # Set the variable conffile |
15 |
| -conffilename=os.path.join(confdir, conffile) # Set the variable conffilename by joining confdir and conffile together |
| 13 | +confdir = os.getenv("my_config") # Set the variable confdir from the OS environment variable |
| 14 | +conffile = 'env_check.conf' # Set the variable conffile |
| 15 | +conffilename = os.path.join(confdir, conffile) # Set the variable conffilename by joining confdir and conffile together |
16 | 16 |
|
17 |
| -for env_check in open(conffilename): # Open the config file and read all the settings |
18 |
| - env_check = env_check.strip() # Set the variable as itsself, but strip the extra text out |
19 |
| - print '[{}]'.format(env_check) # Format the Output to be in Square Brackets |
20 |
| - newenv = os.getenv(env_check) # Set the variable newenv to get the settings from the OS what is currently set for the settings out the configfile |
21 |
| - if newenv is None: # If it doesn't exist |
22 |
| - print env_check, 'is not set' # Print it is not set |
23 |
| - else: # Else if it does exist |
| 17 | +for env_check in open(conffilename): # Open the config file and read all the settings |
| 18 | + env_check = env_check.strip() # Set the variable as itsself, but strip the extra text out |
| 19 | + print '[{}]'.format(env_check) # Format the Output to be in Square Brackets |
| 20 | + newenv = os.getenv(env_check) # Set the variable newenv to get the settings from the OS what is currently set for the settings out the configfile |
| 21 | + |
| 22 | + if newenv is None: # If it doesn't exist |
| 23 | + print env_check, 'is not set' # Print it is not set |
| 24 | + else: # Else if it does exist |
24 | 25 | print 'Current Setting for {}={}\n'.format(env_check, newenv) # Print out the details
|
0 commit comments