예제 #1
0
파일: config.py 프로젝트: codekoala/wsgid
    def run(self, options, **kwargs):
        config_file = os.path.join(options.app_path, 'wsgid.json')
        f = self._open_config_file(config_file)
        s = f.read()
        cfg_values = {}
        if s:
            cfg_values = simplejson.loads(s)

        # Copy the values
        self._override_if_not_none('wsgi_app', cfg_values, options.wsgi_app)
        self._override_if_not_none('debug', cfg_values, options.debug)
        if options.workers > 1:
            self._override_if_not_none('workers', cfg_values, options.workers, convert_func=int)
        self._override_if_not_none('keep_alive', cfg_values, options.keep_alive)
        self._override_if_not_none('chroot', cfg_values, options.chroot)
        self._override_if_not_none('no_daemon', cfg_values, options.no_daemon)
        self._override_if_not_none('recv', cfg_values, options.recv)
        self._override_if_not_none('send', cfg_values, options.send)
        self._override_if_not_none('mongrel2_chroot', cfg_values, options.mongrel2_chroot)
        self._override_if_not_none('django', cfg_values, options.django)

        # Custom config command options
        if options.no_debug:
            cfg_values['debug'] = str((not options.no_debug))

        validate_input_params(send=cfg_values['send'], recv=cfg_values['recv'])
        # Rewrite the config file
        f.seek(0)
        f.truncate()
        simplejson.dump(cfg_values, f, indent="  ")
        f.close()
예제 #2
0
파일: cli_test.py 프로젝트: codekoala/wsgid
 def test_socket_validation(self):
     validate_input_params(app_path='/tmp', send='tcp://127.0.0.1:8800', recv='ipc:///tmp/sock')
     self.assertRaises(Exception, validate_input_params, app_path='/tmp', send='invalid://127.0.0.1:88')
     self.assertRaises(Exception, validate_input_params, app_path='/tmp', recv='tcp://127.0.0.1:89')
     self.assertRaises(Exception, validate_input_params, app_path='/tmp', recv='tcp://127.0.0.1', \
             send='ipc:///tmp/sock')
     self.assertRaises(Exception, validate_input_params, app_path='/tmp', recv='tcp://127.0.0.1:89', \
             send='invalid://127.0.0.1:88')