Created
June 26, 2014 15:57
-
-
Save rez0n/c3281f52496ee931f864 to your computer and use it in GitHub Desktop.
Create config with default values in ConfigObj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import configobj | |
def default_config(): | |
config = configobj.ConfigObj('d:\\text.txt') | |
config['settings'] = {} | |
config['settings']['my_ip'] = None | |
config['settings']['rtsp_port'] = '5180' | |
config['settings']['http_port'] = '5081' | |
config.write() | |
try: | |
open('d:\\text.txt') | |
except IOError: | |
print("Config is epsent. Creating defaul") | |
default_config() | |
else: | |
print('Config good') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment