From 7707d5d3c646a84c18704df97585e04e74565654 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 8 Feb 2010 01:24:18 +0100 Subject: Fixed in windows Windows was giving trouble with the os.getenv(HOME) which can be executed in the python shell and IDLE and will return C:\Documents and Settings\username\, but when running a script it will return None. If os.getenv(HOME) is None, then now the exec dir will be used instead --- .gitignore | 1 + config.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2f836aa..b04dcab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.pyc +.* \ No newline at end of file diff --git a/config.py b/config.py index 7110ce5..35ff5e4 100644 --- a/config.py +++ b/config.py @@ -1,9 +1,14 @@ import os import ConfigParser +import sys + +homedir = os.getenv("HOME") +if homedir is None: + homedir = os.path.dirname(sys.argv[0]) class _Configuration(object): def __init__(self): - self.filename = os.path.join(os.path.join(os.getenv("HOME"), ".4grab"), "config.cfg") + self.filename = os.path.join(os.path.join(homedir, ".4grab"), "config.cfg") self.configparser = ConfigParser.RawConfigParser() if not os.path.exists(self.filename): self.create_new() @@ -15,7 +20,7 @@ class _Configuration(object): self.configparser.set("settings", "category", self.raw_input_with_default("w", "Please enter which category you would like to download from: ")) self.configparser.add_section("locations") - self.configparser.set("locations", "download", self.raw_input_with_default(os.path.join(os.getenv("HOME"), "Pictures"), "Please enter where you would like the downloads to go: ")) + self.configparser.set("locations", "download", self.raw_input_with_default(os.path.join(homedir, "Pictures"), "Please enter where you would like the downloads to go: ")) #with open(self.filename) as configfile: # self.configparser.write(configfile) -- cgit v1.2.3-54-g00ecf From cc571e6d8096856c083a6909ba2fe7a600f166b3 Mon Sep 17 00:00:00 2001 From: ryuslash Date: Mon, 8 Feb 2010 01:48:12 +0100 Subject: Still wasn't working on windows if savedir did not exists, then downloading would never work. Now if it does not exist, it is created, or it crashes and burns if it isn't allowed. --- download.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/download.py b/download.py index e448fa0..003e718 100644 --- a/download.py +++ b/download.py @@ -6,6 +6,8 @@ import progressbar import config savedir = config.Configuration().get_download_location() +if not os.path.exists(savedir): + os.makedirs(savedir) def get_thread_links(baseurl): myparser = htmlparser.MyParser() -- cgit v1.2.3-54-g00ecf