Exemple #1
0
 def test_get_config(self):
     config = db.get_config(self.data_class)
     dict_intersection = {
         key: config[key]
         for key in set(config) & set(self.config)
         if self.config[key] == config[key]
     }
     assert dict_intersection == self.config
Exemple #2
0
parser_restart = subparsers.add_parser(MODE_RESTART, description='restart a remote problem')
parser_restart.set_defaults(mode=MODE_RESTART)

parser_restart_all = subparsers.add_parser(MODE_RESTART_ALL, description='restart all remote problems')
parser_restart_all.set_defaults(mode=MODE_RESTART_ALL)

# download remote problem binary
parser_download = subparsers.add_parser(MODE_DOWNLOAD, description='download remote problem binary')
parser_download.set_defaults(mode=MODE_DOWNLOAD)

args = parser.parse_args()


# check db is existing
if args.mode != MODE_INIT:
    if db.get_config('initialized') is None:
        prompt.fail('Please initialize database first (soma init)')
        exit(1)


if args.mode == MODE_INIT:
    if db.get_config('initialized') is not None:
        prompt.fail('Database is already initialized!')
        exit(1)
    else:
        try:
            current_user = pwd.getpwuid(os.getuid()).pw_name
            soma_user = prompt.string('Please provide soma master username (blank to use `%s`): ' % current_user, default=current_user, pattern=prompt.Validators.username)
            soma_path = prompt.directory('Directory to create problems (blank to use `/home`): ', default='/home')
            db.create_db(soma_user, soma_path)
            prompt.success('Database is successfully initialized')
 def config(self):
     return db.get_config(self)
 def test_get_config(self):
     config = db.get_config(self.data_class)
     dict_intersection = {
         key: config[key] for key in set(config) & set(self.config) if self.config[key] == config[key]
     }
     assert dict_intersection == self.config
Exemple #5
0
from flask.ext.cache import Cache
from flask.ext.mongo_sessions import MongoDBSessionInterface


app = Flask(__name__)
app.debug = True
app.config.from_pyfile("../config.py")

# Cache
cache = Cache(app, config={"CACHE_TYPE": "memcached", "CACHE_MEMCACHED_SERVERS": ["127.0.0.1:11211"]})
cache.init_app(app)

# Bootstrap
bootstrap = Bootstrap(app)

# SimpleAuth
basic_auth = BasicAuth(app)

mongo = PyMongo(app)

# Sessions and Configuration
import db

with app.app_context():
    app.session_interface = MongoDBSessionInterface(app, mongo.db, "flasksessions")
    app.config.update(db.get_config())

import webapp.views
import webapp.api
import webapp.oparl
app = Flask(__name__)
app.config.from_pyfile('../config.py')

# Cache
cache = Cache(app,
              config={
                  'CACHE_TYPE': 'memcached',
                  'CACHE_MEMCACHED_SERVERS': ['127.0.0.1:11211']
              })
cache.init_app(app)

# Bootstrap
bootstrap = Bootstrap(app)

# SimpleAuth
basic_auth = BasicAuth(app)

# Database + Search Server
mongo = PyMongo(app)
es = FlaskElasticsearch(app)

# Sessions and Configuration
import db
with app.app_context():
    app.session_interface = MongoDBSessionInterface(app, mongo.db,
                                                    'flasksessions')
    app.config.update(db.get_config())

import webapp.views
import webapp.api
import webapp.oparl