I've got a bunch of Python webdriver runs that I've converted from Selenium IDE. These runs have 1 or 2 settings that I would like to be able to change using a configuration file that would be created by running a script that collects user input that would set these 2 variables.
Here is my attempt at using the ConfigParser
module:
import ConfigParser
file_path_input = raw_input("Enter path to 'webdriver' directory ex: '/home/user/': ")
print "you entered", file_path_input
url_input = raw_input("Enter url that the application will point to, ex: 172.31.13.56 or vtm55.example.com: ")
print "you entered", url_input
def createConfig(file_path_input):
"""
Create a config file
"""
config = ConfigParser.ConfigParser()
config.add_section("application_settings")
config.set("application_settings", "file_path_to_use", "file_path_input")
config.set("application_settings", "url_to_use", "url_input")
config.set("application_settings", "settings_info",
"Your application directory is in %(file_path_to_use)s and your application url is %(url_to_use)s")
with open(file_path_input, "wb") as config_file:
config.write(config_file)
The raw_input()
and print()
lines work, but the configuration file doesn't appear to be generated at all. Once the file has been created, I'd like to be able to insert the variables file_path_to_use
and url_to_use
in my various Python webdriver runs.