Archive lookup

4grab was saving the archived images to the wrong place, which is now fixed
This commit is contained in:
ryuslash 2010-04-08 15:14:12 +02:00
parent 9fb2b4ff58
commit 2db5555609
3 changed files with 13 additions and 11 deletions

View file

@ -20,15 +20,11 @@
import os import os
import ConfigParser import ConfigParser
import sys import sys
from util import homedir, confdir
# Get our reference point. preferably $HOME.
homedir = os.getenv("HOME")
if homedir is None:
homedir = os.path.dirname(sys.argv[0])
class _Configuration(object): class _Configuration(object):
def __init__(self, optioncreator): def __init__(self, optioncreator):
self.filename = os.path.join(os.path.join(homedir, ".4grab"), "config.cfg") self.filename = os.path.join(confdir, "config.cfg")
self.configparser = ConfigParser.RawConfigParser() self.configparser = ConfigParser.RawConfigParser()
self.optioncreator = optioncreator self.optioncreator = optioncreator

View file

@ -22,6 +22,7 @@ import os
import htmlparser import htmlparser
import config import config
import sys import sys
import backend
def get_savedir(): def get_savedir():
conf = config.Configuration() conf = config.Configuration()
@ -30,12 +31,10 @@ def get_savedir():
os.makedirs(savedir) os.makedirs(savedir)
return savedir return savedir
def check_archive(fullpath): def check_archive(fullpath):
conf = config.Configuration()
archive = conf.get_archive_location()
filename = os.path.basename(fullpath) filename = os.path.basename(fullpath)
archfile = os.path.join(archive, filename) be = backend.Backend()
#sys.stderr.write("%s %d\n" % (archfile, os.path.exists(archfile))) return be.check(filename)
return os.path.exists(archfile)
def write(message): def write(message):
sys.stdout.write(message) sys.stdout.write(message)
sys.stdout.flush() sys.stdout.flush()

7
util.py Normal file
View file

@ -0,0 +1,7 @@
import os
import sys
homedir = os.getenv("HOME")
if homedir is None:
homedir = os.path.dirname(sys.argv[0])
confdir = os.path.join(homedir, ".4grab")