Skip to content

Commit

Permalink
BF: revert options.py b/c they break existing configurations!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
anwarnunez committed Oct 19, 2017
1 parent 6d4c2f0 commit f164371
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions cottoncandy/options.py
Expand Up @@ -61,14 +61,12 @@ def generate_AES_key(bytes = 32):
usercfg = os.path.join(userdir, "options.cfg")

config = configparser.ConfigParser()
try:
config.read_file(open(os.path.join(cwd, 'defaults.cfg')))
except AttributeError as e:
config.readfp(open(os.path.join(cwd, 'defaults.cfg')))
config.readfp(open(os.path.join(cwd, 'defaults.cfg')))



# case no user config file
if not os.path.exists(usercfg):
if len(config.read(usercfg)) == 0:
if not os.path.exists(userdir):
os.makedirs(userdir)

Expand Down Expand Up @@ -99,14 +97,8 @@ def generate_AES_key(bytes = 32):
try: # encryption section
aesKey = config.get('encryption', 'key')
if aesKey == 'auto':
key = 'key'
aesKey = str(b64encode(generate_AES_key()))

if sys.version[0] == '2':
key = key.decode('utf8')
aesKey = aesKey.decode('utf8')

config.set("encryption", key, aesKey)
config.set("encryption", 'key', aesKey)
needs_update = True
except configparser.NoSectionError:
config.add_section('encryption')
Expand All @@ -125,6 +117,6 @@ def generate_AES_key(bytes = 32):
config.set('gdrive', 'credentials', 'credentials.txt')
needs_update = True

if needs_update :
if needs_update:
with open(usercfg, 'w') as configfile:
config.write(configfile)

0 comments on commit f164371

Please sign in to comment.