add chdir command line argument

This commit is contained in:
kviktor 2016-12-02 17:08:41 +01:00
parent fd83678276
commit 8907d8355c

View File

@ -114,6 +114,12 @@ class CommandLineInterface(object):
default=False, default=False,
action='store_true', action='store_true',
) )
self.parser.add_argument(
'--chdir',
dest='chdir',
help='chdir to specified directory before apps loading',
default=".",
)
self.server = None self.server = None
@ -150,7 +156,7 @@ class CommandLineInterface(object):
elif args.verbosity >= 1: elif args.verbosity >= 1:
access_log_stream = sys.stdout access_log_stream = sys.stdout
# Import channel layer # Import channel layer
sys.path.insert(0, ".") sys.path.insert(0, args.chdir)
module_path, object_path = args.channel_layer.split(":", 1) module_path, object_path = args.channel_layer.split(":", 1)
channel_layer = importlib.import_module(module_path) channel_layer = importlib.import_module(module_path)
for bit in object_path.split("."): for bit in object_path.split("."):