From 3512290cc28c5b88feb687a0a815b6acb60e377d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sun, 1 Apr 2018 18:15:44 +0200 Subject: [PATCH] chg: Store the source files in the home directory --- bgpranking/libs/helpers.py | 3 +++ bin/archiver.py | 4 ++-- bin/fetcher.py | 4 ++-- bin/parser.py | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bgpranking/libs/helpers.py b/bgpranking/libs/helpers.py index bbfdfd3..2e5aa00 100644 --- a/bgpranking/libs/helpers.py +++ b/bgpranking/libs/helpers.py @@ -12,6 +12,9 @@ import time def get_config_path(): + if Path('bgpranking', 'config').exists(): + # Running from the repository + return Path('bgpranking', 'config') return Path(sys.modules['bgpranking'].__file__).parent / 'config' diff --git a/bin/archiver.py b/bin/archiver.py index eff4220..d235745 100755 --- a/bin/archiver.py +++ b/bin/archiver.py @@ -4,7 +4,7 @@ from bgpranking.archive import DeepArchive import logging from pathlib import Path -from bgpranking.libs.helpers import get_config_path, get_list_storage_path +from bgpranking.libs.helpers import get_config_path, get_homedir from pid import PidFile, PidFileError @@ -22,7 +22,7 @@ class ModulesArchiver(): if not config_dir: config_dir = get_config_path() if not storage_directory: - self.storage_directory = get_list_storage_path() + self.storage_directory = get_homedir() modules_config = config_dir / 'modules' modules_paths = [modulepath for modulepath in modules_config.glob('*.json')] self.modules = [DeepArchive(path, self.storage_directory, loglevel) for path in modules_paths] diff --git a/bin/fetcher.py b/bin/fetcher.py index 9ee38c7..0cd2992 100755 --- a/bin/fetcher.py +++ b/bin/fetcher.py @@ -8,7 +8,7 @@ import aiohttp from bgpranking.abstractmanager import AbstractManager from bgpranking.modulesfetcher import Fetcher -from bgpranking.libs.helpers import get_config_path, get_list_storage_path +from bgpranking.libs.helpers import get_config_path, get_homedir logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s:%(message)s', level=logging.INFO, datefmt='%I:%M:%S') @@ -21,7 +21,7 @@ class ModulesManager(AbstractManager): if not config_dir: config_dir = get_config_path() if not storage_directory: - storage_directory = get_list_storage_path() + storage_directory = get_homedir() modules_config = config_dir / 'modules' modules_paths = [modulepath for modulepath in modules_config.glob('*.json')] self.modules = [Fetcher(path, storage_directory, loglevel) for path in modules_paths] diff --git a/bin/parser.py b/bin/parser.py index 42a4431..59b3414 100755 --- a/bin/parser.py +++ b/bin/parser.py @@ -6,7 +6,7 @@ from pathlib import Path from bgpranking.abstractmanager import AbstractManager from bgpranking.parser import RawFilesParser -from bgpranking.libs.helpers import get_config_path, get_list_storage_path +from bgpranking.libs.helpers import get_config_path, get_homedir logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s:%(message)s', level=logging.INFO, datefmt='%I:%M:%S') @@ -19,7 +19,7 @@ class ParserManager(AbstractManager): if not config_dir: config_dir = get_config_path() if not storage_directory: - storage_directory = get_list_storage_path() + storage_directory = get_homedir() modules_config = config_dir / 'modules' modules_paths = [modulepath for modulepath in modules_config.glob('*.json')] self.modules = [RawFilesParser(path, storage_directory, loglevel) for path in modules_paths]