Ejemplo n.º 1
0
 def command(self):
     logging.config.fileConfig(self.path_to_ini_file)
     from pylons import config
     add_cache(config)
     engine = engine_from_config(config, 'sqlalchemy.db1.')
     init_model(engine)
     index_location = config['index_dir']
     repo_location = self.options.repo_location \
         if self.options.repo_location else RepoModel().repos_path
     repo_list = map(strip, self.options.repo_list.split(',')) \
         if self.options.repo_list else None
     repo_update_list = map(strip, self.options.repo_update_list.split(',')) \
         if self.options.repo_update_list else None
     load_rcextensions(config['here'])
     #======================================================================
     # WHOOSH DAEMON
     #======================================================================
     from rhodecode.lib.pidlock import LockHeld, DaemonLock
     from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
     try:
         l = DaemonLock(file_=jn(dn(dn(index_location)), 'make_index.lock'))
         WhooshIndexingDaemon(index_location=index_location,
                              repo_location=repo_location,
                              repo_list=repo_list,
                              repo_update_list=repo_update_list)\
             .run(full_index=self.options.full_index)
         l.release()
     except LockHeld:
         sys.exit(1)
Ejemplo n.º 2
0
 def command(self):
     logging.config.fileConfig(self.path_to_ini_file)
     from pylons import config
     add_cache(config)
     engine = engine_from_config(config, 'sqlalchemy.db1.')
     init_model(engine)
     index_location = config['index_dir']
     repo_location = self.options.repo_location \
         if self.options.repo_location else RepoModel().repos_path
     repo_list = map(strip, self.options.repo_list.split(',')) \
         if self.options.repo_list else None
     load_rcextensions(config['here'])
     #======================================================================
     # WHOOSH DAEMON
     #======================================================================
     from rhodecode.lib.pidlock import LockHeld, DaemonLock
     from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
     try:
         l = DaemonLock(file_=jn(dn(dn(index_location)), 'make_index.lock'))
         WhooshIndexingDaemon(index_location=index_location,
                              repo_location=repo_location,
                              repo_list=repo_list,)\
             .run(full_index=self.options.full_index)
         l.release()
     except LockHeld:
         sys.exit(1)
Ejemplo n.º 3
0
    def command(self):
        from pylons import config

        add_cache(config)

        db_uri = config['sqlalchemy.db1.url']

        dbmanage = DbManage(log_sql=True, dbconf=db_uri,
                            root=config['here'], tests=False)

        dbmanage.upgrade()
Ejemplo n.º 4
0
    def command(self):
        from pylons import config
        add_cache(config)
        self.logging_file_config(self.path_to_ini_file)

        db_uri = config['sqlalchemy.db1.url']
        dbmanage = DbManage(log_sql=True,
                            dbconf=db_uri,
                            root=config['here'],
                            tests=False,
                            cli_args=self.options.__dict__)
        dbmanage.upgrade()
Ejemplo n.º 5
0
    def command(self):
        from pylons import config

        add_cache(config)

        db_uri = config['sqlalchemy.db1.url']

        dbmanage = DbManage(log_sql=True,
                            dbconf=db_uri,
                            root=config['here'],
                            tests=False)

        dbmanage.upgrade()
Ejemplo n.º 6
0
    def command(self):
        logging.config.fileConfig(self.path_to_ini_file)
        from pylons import config

        #get to remove repos !!
        add_cache(config)
        engine = engine_from_config(config, 'sqlalchemy.db1.')
        init_model(engine)

        repos_location = RhodeCodeUi.get_repos_location()
        to_remove = []
        for dn, dirs, f in os.walk(safe_str(repos_location)):
            for loc in dirs:
                if REMOVED_REPO_PAT.match(loc):
                    to_remove.append([loc, self._extract_date(loc)])

        #filter older than (if present)!
        now = datetime.datetime.now()
        older_than = self.options.older_than
        if older_than:
            to_remove_filtered = []
            older_than_date = self._parse_older_than(older_than)
            for name, date_ in to_remove:
                repo_age = now - date_
                if repo_age > older_than_date:
                    to_remove_filtered.append([name, date_])

            to_remove = to_remove_filtered
            print >> sys.stdout, 'removing [%s] deleted repos older than %s[%s]' \
                % (len(to_remove), older_than, older_than_date)
        else:
            print >> sys.stdout, 'removing all [%s] deleted repos' \
                % len(to_remove)
        if self.options.dont_ask or not to_remove:
            # don't ask just remove !
            remove = True
        else:
            remove = ask_ok('are you sure to remove listed repos \n%s [y/n]?'
                            % ', \n'.join(['%s removed on %s'
                    % (safe_str(x[0]), safe_str(x[1])) for x in to_remove]))

        if remove:
            for name, date_ in to_remove:
                print >> sys.stdout, 'removing repository %s' % name
                shutil.rmtree(os.path.join(repos_location, name))
        else:
            print 'nothing done exiting...'
            sys.exit(0)
Ejemplo n.º 7
0
    def command(self):
        logging.config.fileConfig(self.path_to_ini_file)
        from pylons import config

        #get to remove repos !!
        add_cache(config)
        engine = engine_from_config(config, 'sqlalchemy.db1.')
        init_model(engine)

        repo_update_list = map(string.strip,
                               self.options.repo_update_list.split(',')) \
                               if self.options.repo_update_list else None

        if repo_update_list:
            repo_list = Repository.query().filter(Repository.repo_name.in_(repo_update_list))
        else:
            repo_list = Repository.getAll()
        for repo in repo_list:
            last_change = repo.scm_instance.last_change
            repo.update_last_change(last_change)
Ejemplo n.º 8
0
from sqlalchemy import engine_from_config

from rhodecode.lib.utils import add_cache
from rhodecode.model import init_model
from rhodecode.model import meta
from rhodecode.model.db import User, Repository
from rhodecode.lib.auth import get_crypt_password

from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
from rhodecode.config.environment import load_environment

rel_path = dn(dn(dn(os.path.abspath(__file__))))
conf = appconfig('config:development.ini', relative_to=rel_path)
load_environment(conf.global_conf, conf.local_conf)

add_cache(conf)

USER = '******'
PASS = '******'
HOST = '127.0.0.1:5000'
DEBUG = True
log = logging.getLogger(__name__)


class Command(object):

    def __init__(self, cwd):
        self.cwd = cwd

    def execute(self, cmd, *args):
        """Runs command on the system with given ``args``.
Ejemplo n.º 9
0
from rhodecode.lib.vcs import get_backend

from rhodecode import CELERY_ON, CELERY_EAGER
from rhodecode.lib.utils2 import safe_str
from rhodecode.lib.celerylib import run_task, locked_task, dbsession, \
    str2bool, __get_lockkey, LockHeld, DaemonLock, get_session
from rhodecode.lib.helpers import person
from rhodecode.lib.rcmail.smtp_mailer import SmtpMailer
from rhodecode.lib.utils import add_cache, action_logger
from rhodecode.lib.compat import json, OrderedDict
from rhodecode.lib.hooks import log_create_repository

from rhodecode.model.db import Statistics, Repository, User
from rhodecode.model.scm import ScmModel

add_cache(config)

__all__ = [
    'whoosh_index', 'get_commits_stats', 'reset_user_password', 'send_email'
]


def get_logger(cls):
    if CELERY_ON:
        try:
            log = cls.get_logger()
        except:
            log = logging.getLogger(__name__)
    else:
        log = logging.getLogger(__name__)
Ejemplo n.º 10
0
from sqlalchemy import engine_from_config

from rhodecode.lib.utils import add_cache
from rhodecode.model import init_model
from rhodecode.model import meta
from rhodecode.model.db import User, Repository
from rhodecode.lib.auth import get_crypt_password

from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
from rhodecode.config.environment import load_environment

rel_path = dn(dn(dn(dn(os.path.abspath(__file__)))))
conf = appconfig('config:rc.ini', relative_to=rel_path)
load_environment(conf.global_conf, conf.local_conf)

add_cache(conf)

USER = '******'
PASS = '******'
HOST = 'rc.local'
METHOD = 'pull'
DEBUG = True
log = logging.getLogger(__name__)


class Command(object):
    def __init__(self, cwd):
        self.cwd = cwd

    def execute(self, cmd, *args):
        """Runs command on the system with given ``args``.
Ejemplo n.º 11
0
import logging

from celery.task import task
from pylons import config

import rhodecode
from rhodecode.lib.celerylib import (run_task, dbsession, __get_lockkey,
                                     LockHeld, DaemonLock, get_session,
                                     vcsconnection)
from rhodecode.lib.hooks_base import log_create_repository
from rhodecode.lib.rcmail.smtp_mailer import SmtpMailer
from rhodecode.lib.utils import add_cache, action_logger
from rhodecode.lib.utils2 import safe_int, str2bool
from rhodecode.model.db import Repository, User

add_cache(config)  # pragma: no cover


def get_logger(cls):
    if rhodecode.CELERY_ENABLED:
        try:
            log = cls.get_logger()
        except Exception:
            log = logging.getLogger(__name__)
    else:
        log = logging.getLogger(__name__)

    return log


@task(ignore_result=True)
Ejemplo n.º 12
0
from rhodecode.lib.vcs import get_backend

from rhodecode import CELERY_ON, CELERY_EAGER
from rhodecode.lib.utils2 import safe_str
from rhodecode.lib.celerylib import run_task, locked_task, dbsession, \
    str2bool, __get_lockkey, LockHeld, DaemonLock, get_session
from rhodecode.lib.helpers import person
from rhodecode.lib.rcmail.smtp_mailer import SmtpMailer
from rhodecode.lib.utils import add_cache, action_logger
from rhodecode.lib.compat import json, OrderedDict
from rhodecode.lib.hooks import log_create_repository

from rhodecode.model.db import Statistics, Repository, User


add_cache(config)

__all__ = ['whoosh_index', 'get_commits_stats',
           'reset_user_password', 'send_email']


def get_logger(cls):
    if CELERY_ON:
        try:
            log = cls.get_logger()
        except:
            log = logging.getLogger(__name__)
    else:
        log = logging.getLogger(__name__)

    return log