From b0faf809189399b919316184ca038506e5c275bc Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Sat, 21 Jun 2014 01:05:07 +0200 Subject: [PATCH] Create the Source configuration if not yet existent --- utils/configurator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/configurator.py b/utils/configurator.py index 2db7cdb..6a076b3 100644 --- a/utils/configurator.py +++ b/utils/configurator.py @@ -1,5 +1,6 @@ import ConfigParser import os +import shutil from scrapy.utils.project import get_project_settings @@ -70,6 +71,11 @@ class Configurator: current_dir = os.path.dirname(os.path.abspath(__file__)) config_path = current_dir + '/../sources.cfg' # [TODO]: location of sources.cfg should be softcoded eventually + if not os.path.isfile(config_path): + try: + shutil.copyfile(os.path.dirname(os.path.abspath(__file__)) + "/../sources.cfg.sample", config_path) + except IOError: + print "WARNING: Source configuration couldn't be found and couldn't be created." config = ConfigParser.ConfigParser() config.read(config_path) return config