Exemple #1
0
def run():

    # Special-case the --fork option so that it doesn't get exposed to users.
    # The idea is that --fork is an internal detail which shouldn't be visible
    # anywhere.
    if '--fork' in sys.argv:
        command, config_info = handle_fork(sys.argv)
    else:
        parser = get_parser()
        args = parser.parse_args()

        # Using a mutually exclusive group in 'get_parser' gurantees that we'll have
        # exactly one option to pick here.
        command, config_info = [(k, v) for k, v in args._get_kwargs() if v][0]

    if command == 'fork':
        config_dir, is_https = config_info
    else:
        config_dir = config_info
        is_https = None

    config_dir = os.path.abspath(config_dir)

    app_ctx = ApplicationContext(app_context.SecWallContext())

    handler_class = getattr(cli, command.capitalize())
    handler_class(config_dir, app_ctx, is_https).run()
Exemple #2
0
    def setUp(self):
        self.app_ctx = ApplicationContext(app_context.SecWallContext())
        self.test_dir = tempfile.mkdtemp(prefix='tmp-sec-wall-')
        cli.Init(self.test_dir, self.app_ctx, False).run()

        log_config = """

[loggers]
keys=root

[handlers]
keys=consoleHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)
"""

        self.log_file_config = os.path.join(self.test_dir, uuid.uuid4().hex)
        open(self.log_file_config, 'w').write(log_config)
Exemple #3
0
def prepare_config(target_dir, is_https):
    app_ctx = ApplicationContext(app_context.SecWallContext())
    start = Start(target_dir, app_ctx, is_https)
    start.prepare_config()
Exemple #4
0
 def setUp(self):
     self.app_ctx = ApplicationContext(app_context.SecWallContext())
     self.test_dir = tempfile.mkdtemp(prefix='tmp-sec-wall-')
Exemple #5
0
 def setUp(self):
     self.app_ctx = ApplicationContext(app_context.SecWallContext())
     self.test_dir = tempfile.mkdtemp(prefix=self.temp_dir_prefix)
     open(os.path.join(self.test_dir, '.sec-wall-config'), 'w')
     open(os.path.join(self.test_dir, 'config.py'), 'w')
     open(os.path.join(self.test_dir, 'zdaemon.conf'), 'w')