Skip to content
Permalink
Browse files

Clean up sys.path resolving in scripts.

  • Loading branch information
mxsasha committed Jan 16, 2019
1 parent 1776211 commit 48430b52c50fb260fb19ef94bbd29d13a3db6ba5
@@ -7,6 +7,7 @@
import signal
import yaml
from IPy import IP
from pathlib import Path
from typing import Any, List, Optional
import os

@@ -84,7 +85,7 @@ def __init__(self, user_config_path: Optional[str]=None):
If a logfile was specified, direct logs there.
"""
self.user_config_path = user_config_path if user_config_path else CONFIG_PATH_DEFAULT
default_config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'default_config.yaml')
default_config_path = str(Path(__file__).resolve().parents[0] / 'default_config.yaml')
default_config_yaml = yaml.safe_load(open(default_config_path))
self.default_config = DottedDict(default_config_yaml['irrd'])

@@ -12,6 +12,7 @@
import textwrap
import yaml
from alembic import command, config
from pathlib import Path

from irrd.conf import config_init, PASSWORD_HASH_DUMMY_VALUE
from irrd.utils.rpsl_samples import (SAMPLE_MNTNER, SAMPLE_PERSON, SAMPLE_KEY_CERT, SIGNED_PERSON_UPDATE_VALID,
@@ -22,7 +23,7 @@
from .constants import (EMAIL_SMTP_PORT, EMAIL_DISCARD_MSGS_COMMAND, EMAIL_RETURN_MSGS_COMMAND, EMAIL_SEPARATOR,
EMAIL_END)

IRRD_ROOT_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
IRRD_ROOT_PATH = str(Path(__file__).resolve().parents[2])
sys.path.append(IRRD_ROOT_PATH)

AS_SET_REFERRING_OTHER_SET = """as-set: AS-TESTREF
@@ -3,11 +3,11 @@
import sys

import argparse
import os
from alembic import command
from alembic.config import Config
from pathlib import Path

irrd_root = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
irrd_root = str(Path(__file__).resolve().parents[2])
sys.path.append(irrd_root)

from irrd.conf import config_init, CONFIG_PATH_DEFAULT
@@ -7,16 +7,16 @@

import argparse
import difflib
import os
import sys

import re
from IPy import IP
from orderedset import OrderedSet
from pathlib import Path
from typing import Optional


sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
sys.path.append(str(Path(__file__).resolve().parents[2]))

from irrd.rpsl.rpsl_objects import rpsl_object_from_text
from irrd.utils.text import splitline_unicodesafe, split_paragraphs_rpsl
@@ -5,12 +5,13 @@
insert it into the database.
"""
import argparse
import os
import sys

from pathlib import Path
from typing import Set


sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
sys.path.append(str(Path(__file__).resolve().parents[2]))

from irrd.conf import CONFIG_PATH_DEFAULT, config_init
from irrd.storage.database_handler import DatabaseHandler
@@ -12,11 +12,11 @@
be sent to a user by e-mail.
"""
import argparse
import os
import sys

from pathlib import Path

sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
sys.path.append(str(Path(__file__).resolve().parents[2]))

from irrd.conf import config_init, CONFIG_PATH_DEFAULT
from irrd.updates.handler import ChangeSubmissionHandler
@@ -2,9 +2,10 @@
# flake8: noqa: E402
import argparse
import logging
import os
import sys

from pathlib import Path

"""
Submit a raw e-mail message, i.e. with e-mail headers.
The message is always read from stdin.
@@ -13,8 +14,7 @@
"""

logger = logging.getLogger(__name__)

sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
sys.path.append(str(Path(__file__).resolve().parents[2]))

from irrd.conf import config_init, CONFIG_PATH_DEFAULT
from irrd.updates.email import handle_email_submission
@@ -3,9 +3,10 @@
import sys

from alembic import context
from pathlib import Path
from sqlalchemy import create_engine

sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))))
sys.path.append(str(Path(__file__).resolve().parents[3]))

from irrd.conf import get_setting, config_init, is_config_initialised
from irrd.storage.models import Base
@@ -2,14 +2,15 @@
import sys

import os
from pathlib import Path
from twisted.application import internet, service
from twisted.application.service import IServiceMaker
from twisted.plugin import IPlugin
from twisted.python import usage
from twisted.python.log import PythonLoggingObserver, ILogObserver
from zope.interface import implementer

sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
sys.path.append(str(Path(__file__).resolve().parents[1]))

from irrd.conf import config_init, get_setting, CONFIG_PATH_DEFAULT
from irrd.mirroring.scheduler import MirrorScheduler

0 comments on commit 48430b5

Please sign in to comment.
You can’t perform that action at this time.