Пример #1
0
Файл: web.py Проект: tkf/neorg
def update_system_info():
    """
    Check and update current system info if the stored one is old

    This function **fail** with RuntimeError if the version in the
    stored system info is newer than the current running one.

    .. warning::

       Do NOT use this in app.

    """
    from neorg.verutils import NEOrgVersion, current_version
    sysinfo = system_info()
    oldver = NEOrgVersion(sysinfo['version'])
    curver = current_version()
    if oldver == curver:
        pass
    elif oldver < curver:
        print "You updated NEOrg. Updating database..."
        with closing(connect_db()) as db:
            db.execute(
                'insert into system_info (version) values (?)',
                [str(curver)])
            db.commit()
        print "Finished."
    else:
        raise RuntimeError(
            'The old version ({0}) is newer than the version of the '
            'running version ({1}). Please install newer version'
            .format(oldver, curver))
Пример #2
0
def update_system_info():
    """
    Check and update current system info if the stored one is old

    This function **fail** with RuntimeError if the version in the
    stored system info is newer than the current running one.

    .. warning::

       Do NOT use this in app.

    """
    from neorg.verutils import NEOrgVersion, current_version
    sysinfo = system_info()
    oldver = NEOrgVersion(sysinfo['version'])
    curver = current_version()
    if oldver == curver:
        pass
    elif oldver < curver:
        print "You updated NEOrg. Updating database..."
        with closing(connect_db()) as db:
            db.execute('insert into system_info (version) values (?)',
                       [str(curver)])
            db.commit()
        print "Finished."
    else:
        raise RuntimeError(
            'The old version ({0}) is newer than the version of the '
            'running version ({1}). Please install newer version'.format(
                oldver, curver))
Пример #3
0
def init_db():
    """Creates the database tables."""
    from neorg.verutils import current_version
    curver = current_version()
    with closing(connect_db()) as db:
        with app.open_resource('schema.sql') as f:
            db.cursor().executescript(f.read())
        db.execute('insert into system_info (version) values (?)',
                   [str(curver)])
        db.commit()
Пример #4
0
Файл: web.py Проект: tkf/neorg
def init_db():
    """Creates the database tables."""
    from neorg.verutils import current_version
    curver = current_version()
    with closing(connect_db()) as db:
        with app.open_resource('schema.sql') as f:
            db.cursor().executescript(f.read())
        db.execute(
            'insert into system_info (version) values (?)',
            [str(curver)])
        db.commit()
Пример #5
0
Файл: setup.py Проект: tkf/neorg
from setuptools import setup
from distutils.command.build import build
from distutils.cmd import Command
from distutils import log
import os
import shutil
try:
    # check if BuildDoc is available
    from sphinx.setup_command import BuildDoc
    BUILD_SPHINX_AVAILABLE = True
except ImportError:
    BUILD_SPHINX_AVAILABLE = False
import neorg
from neorg.verutils import current_version

current_version()  # make sure current version is a valid version

data_list = ['schema.sql', 'templates/*.html'] + [
    os.path.join('%s' % d, '*.%s' % e)
    for e in ['css', 'html', 'ico', 'inv', 'js', 'png', 'gif', 'txt']
    for d in [
        'static',
        'static/help',
        'static/help/_source',
        'static/help/_static',
        'static/jslib/',
        'static/jslib/colorbox',
        'static/jslib/colorbox/images',
    ]
]
Пример #6
0
Файл: setup.py Проект: tkf/neorg
from setuptools import setup
from distutils.command.build import build
from distutils.cmd import Command
from distutils import log
import os
import shutil
try:
    # check if BuildDoc is available
    from sphinx.setup_command import BuildDoc
    BUILD_SPHINX_AVAILABLE = True
except ImportError:
    BUILD_SPHINX_AVAILABLE = False
import neorg
from neorg.verutils import current_version

current_version()  # make sure current version is a valid version

data_list = ['schema.sql', 'templates/*.html'] + [
    os.path.join('%s' % d, '*.%s' % e)
    for e in ['css', 'html', 'ico', 'inv', 'js', 'png', 'gif', 'txt']
    for d in ['static', 'static/help',
              'static/help/_source', 'static/help/_static',
              'static/jslib/',
              'static/jslib/colorbox',
              'static/jslib/colorbox/images',
              ]]


def mkdir(path):
    if not os.path.exists(path):
        os.mkdir(path)