octogit icon indicating copy to clipboard operation
octogit copied to clipboard

stop crashing if only config file is missing

Open viraptor opened this issue 13 years ago • 6 comments

viraptor avatar Apr 21 '12 21:04 viraptor

how do I produce the bug you are trying to fix here?

myusuf3 avatar Apr 24 '12 00:04 myusuf3

Delete the config file, but not the directory that contained it.

viraptor avatar Apr 24 '12 00:04 viraptor

Excellent what would make this better is to include the default creation of the config file, instead of it silently failing, there is a format to the standard config file it isn't just about creating a file in that location.

myusuf3 avatar May 06 '12 23:05 myusuf3

@myusuf3 looking at the diff, it appears the file is created if it doesn't exist, and it's also setup with the default section, username, and password. What do you think is missing from @viraptor's commit?

pthrasher avatar May 14 '12 15:05 pthrasher

This change looks good to me - the os.makedirs call is just to ensure the directory exists, it's allowed to fail silently (the config file is created regardless)

Pedantically I'd put a else: pass to make that clear, like:

try:
    os.makedirs(os.path.dirname(CONFIG_FILE))
except OSError as e:
    if e.errno != os.errno.EEXIST:
        raise
    else:
        pass # Directory already exists

..but it should be perfectly clear without it

dbr avatar Sep 07 '12 21:09 dbr

@viraptor if suggestions by @dbr i will gladly merge in the change here. You are totally correct guys. I was smoking dope.

myusuf3 avatar Sep 07 '12 21:09 myusuf3