summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ryuslash2010-02-09 01:35:17 +0100
committerGravatar ryuslash2010-02-09 01:35:17 +0100
commit91e0b5dc665679e30cfd2114a68adce9af04a3e9 (patch)
treef049587e5e5ff80dc5ee4d8f6b369dc77f3724ec
parent32c4471273097523d64ad0f7704861f211e78f72 (diff)
parentcc571e6d8096856c083a6909ba2fe7a600f166b3 (diff)
download4grab-91e0b5dc665679e30cfd2114a68adce9af04a3e9.tar.gz
4grab-91e0b5dc665679e30cfd2114a68adce9af04a3e9.zip
merged with commit from RAAM
-rw-r--r--config.py9
-rw-r--r--download.py2
2 files changed, 9 insertions, 2 deletions
diff --git a/config.py b/config.py
index 519a0b3..06cf0dc 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.set_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: "))
self.save()
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()