Exemple #1
0
def dev(port):
    """ Run development server
    """
    green("Starting development server")

    config_path = config.get_path()
    if config_path:
        green("Using config: %s" % config_path)
    else:
        yellow("Using default configuration")

    create_app().run(host="0.0.0.0", port=port, debug=True)
Exemple #2
0
def dev(port):
    """ Run development server
    """
    green("Starting development server")

    config_path = config.get_path()
    if config_path:
        green("Using config: %s" % config_path)
    else:
        yellow("Using default configuration")

    create_app().run(host="0.0.0.0",
                     port=port,
                     debug=True)
Exemple #3
0
def rebuild_index():
    """ Rebuild search index
    """
    app = create_app()

    if app.config.get('SEARCH_TYPE') == 'simple':
        click.echo("Search type is simple, try using elasticsearch.")
        return

    with app.app_context():
        # Wiki
        search.delete_index('wiki')
        wiki = Wiki(app.config['WIKI_PATH'])
        for entry in wiki.get_index():
            page = wiki.get_page(entry['name'])
            if not page:
                # Some non-markdown files may have issues
                continue
            name = filename_to_cname(page['name'])
            # TODO add email?
            body = dict(name=name,
                        content=page['data'],
                        message=page['info']['message'],
                        username=page['info']['author'],
                        updated_on=entry['mtime'],
                        created_on=entry['ctime'])
            search.index_wiki(name, body)
Exemple #4
0
 def create_app(self):
     app = create_app()
     app.config['TESTING'] = True
     app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
     app.config['WIKI_PATH'] = '/tmp/%s' % random_string(12)
     app.config['DB_URI'] = 'sqlite:////tmp/%s.db' % random_string(12)
     app.config.update(self.configure())
     return app
Exemple #5
0
 def create_app(self):
     app = create_app()
     app.config['TESTING'] = True
     app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
     app.config['WIKI_PATH'] = '/tmp/%s' % random_string(12)
     app.config['DB_URI'] = 'sqlite:////tmp/%s.db' % random_string(12)
     app.config.update(self.configure())
     return app
Exemple #6
0
 def create_app(self):
     self.tempdir = tempfile.mkdtemp()
     app = create_app()
     app.config['TESTING'] = True
     app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
     app.config['WIKI_PATH'] = os.path.join(self.tempdir, random_string(12))
     app.config['DB_URI'] = 'sqlite:///%s/%s.db' % (self.tempdir,
                                                    random_string(12))
     app.config.update(self.configure())
     return app
Exemple #7
0
 def create_app(self):
     self.tempdir = tempfile.mkdtemp()
     app = create_app()
     app.config['TESTING'] = True
     app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
     app.config['WIKI_PATH'] = os.path.join(self.tempdir, random_string(12))
     app.config['DB_URI'] = 'sqlite:///{0}/{1}.db'.format(self.tempdir, random_string(12))
     app.test_client_class = FlaskClient
     app.testing = True
     app.config.update(self.configure())
     return app
Exemple #8
0
 def create_app(self):
     self.tempdir = tempfile.mkdtemp()
     app = create_app()
     app.config['TESTING'] = True
     app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
     app.config['WIKI_PATH'] = os.path.join(self.tempdir, random_string(12))
     app.config['DB_URI'] = 'sqlite:///{0}/{1}.db'.format(
         self.tempdir, random_string(12))
     app.test_client_class = FlaskClient
     app.testing = True
     app.config.update(self.configure())
     return app
Exemple #9
0
from realms import config, create_app, db, __version__, flask_cli as cli
from realms.lib.util import random_string, in_virtualenv, green, yellow, red
from subprocess import call, Popen
from multiprocessing import cpu_count
import click
import json
import sys
import os
import pip
import time
import subprocess

# called to discover commands in modules
app = create_app()

def get_user():
    for name in ('SUDO_USER', 'LOGNAME', 'USER', 'LNAME', 'USERNAME'):
        user = os.environ.get(name)
        if user:
            return user


def get_pid():
    try:
        with file(config.PIDFILE) as f:
            return f.read().strip()
    except IOError:
        return None


def is_running(pid):
Exemple #10
0
from realms import config, create_app, db, __version__, flask_cli as cli
from realms.lib.util import random_string, in_virtualenv, green, yellow, red
from subprocess import call, Popen
from multiprocessing import cpu_count
import click
import json
import sys
import os
import pip
import time
import subprocess

# called to discover commands in modules
app = create_app()


def get_user():
    for name in ('SUDO_USER', 'LOGNAME', 'USER', 'LNAME', 'USERNAME'):
        user = os.environ.get(name)
        if user:
            return user


def get_pid():
    try:
        with file(config.PIDFILE) as f:
            return f.read().strip()
    except IOError:
        return None