Commit 234942a6 authored by Jonathan Michalon's avatar Jonathan Michalon
Browse files

import_config: disable bytecode writing in case directory is RO

parent d7d493c2
...@@ -12,7 +12,6 @@ import concurrent.futures ...@@ -12,7 +12,6 @@ import concurrent.futures
import signal import signal
import argparse import argparse
import logging import logging
import importlib
import sys import sys
import os import os
from time import sleep from time import sleep
...@@ -73,12 +72,17 @@ def parse_args(): ...@@ -73,12 +72,17 @@ def parse_args():
def import_config(configfile): def import_config(configfile):
# import config file module """ import config file module """
# narrow importlib usage and avoid bytecode writing to be able to use
# configfiles in RO directories
from importlib import import_module
sys.dont_write_bytecode = True
filename = os.path.basename(configfile)
base, ext = os.path.splitext(filename)
try: try:
sys.path.append(os.path.dirname(configfile)) import_module(base)
filename = os.path.basename(configfile)
base, ext = os.path.splitext(filename)
except ImportError as e: except ImportError as e:
logging.critical("Cannot load config from '%s': %s" % ( logging.critical("Cannot load config from '%s': %s" % (
args.config, str(e))) args.config, str(e)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment