class UpgradeDb(BasePasterCommand): """Command used for paster to upgrade our database to newer version """ max_args = 1 min_args = 1 usage = "CONFIG_FILE" summary = "Upgrades current db to newer version given configuration file" group_name = "RhodeCode" parser = Command.standard_parser(verbose=True) 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() def update_parser(self): self.parser.add_option( '--sql', action='store_true', dest='just_sql', help="Prints upgrade sql for further investigation", default=False)
class MakeIndex(BasePasterCommand): max_args = 1 min_args = 1 usage = "CONFIG_FILE" summary = "Creates index for full text search given configuration file" group_name = "RhodeCode" takes_config_file = -1 parser = Command.standard_parser(verbose=True) 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) def update_parser(self): self.parser.add_option( '--repo-location', action='store', dest='repo_location', help="Specifies repositories location to index OPTIONAL", ) self.parser.add_option( '--index-only', action='store', dest='repo_list', help="Specifies a comma separated list of repositores " "to build index on OPTIONAL", ) self.parser.add_option( '-f', action='store_true', dest='full_index', help="Specifies that index should be made full i.e" " destroy old and build from scratch", default=False)
class CeleryEventCommand(CeleryCommand): """Celery event command. Capture celery events. """ usage = 'CONFIG_FILE [celeryev options...]' summary = __doc__.splitlines()[0] description = "".join(__doc__.splitlines()[2:]) parser = Command.standard_parser(quiet=True) celery_command = celeryev.EvCommand
class CAMQPAdminCommand(CeleryCommand): """CAMQP Admin CAMQP celery admin tool. """ usage = 'CONFIG_FILE [camqadm options...]' summary = __doc__.splitlines()[0] description = "".join(__doc__.splitlines()[2:]) parser = Command.standard_parser(quiet=True) celery_command = camqadm.AMQPAdminCommand
class CeleryBeatCommand(CeleryCommand): """Start the celery beat server Starts the celery beat server using a paste.deploy configuration file. """ usage = 'CONFIG_FILE [celerybeat options...]' summary = __doc__.splitlines()[0] description = "".join(__doc__.splitlines()[2:]) parser = Command.standard_parser(quiet=True) celery_command = celerybeat.BeatCommand
class CeleryDaemonCommand(CeleryCommand): """Start the celery worker Starts the celery worker that uses a paste.deploy configuration file. """ usage = 'CONFIG_FILE [celeryd options...]' summary = __doc__.splitlines()[0] description = "".join(__doc__.splitlines()[2:]) parser = Command.standard_parser(quiet=True) celery_command = celeryd.WorkerCommand
class UpgradeDb(BasePasterCommand): """Command used for paster to upgrade our database to newer version """ max_args = 1 min_args = 1 usage = "CONFIG_FILE" summary = "Upgrades current db to newer version" group_name = "RhodeCode" parser = Command.standard_parser(verbose=True) 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() def update_parser(self): self.parser.add_option( '--sql', action='store_true', dest='just_sql', help="Prints upgrade sql for further investigation", default=False) self.parser.add_option('--force-yes', action='store_true', dest='force_ask', default=None, help='Force yes to every question') self.parser.add_option('--force-no', action='store_false', dest='force_ask', default=None, help='Force no to every question')
class MakeRcExt(BasePasterCommand): max_args = 1 min_args = 1 usage = "CONFIG_FILE" summary = "Creates additional extensions for rhodecode" group_name = "RhodeCode" takes_config_file = -1 parser = Command.standard_parser(verbose=True) def command(self): logging.config.fileConfig(self.path_to_ini_file) from pylons import config def _make_file(ext_file): bdir = os.path.split(ext_file)[0] if not os.path.isdir(bdir): os.makedirs(bdir) with open(ext_file, 'wb') as f: f.write(tmpl) log.info('Writen new extensions file to %s' % ext_file) here = config['here'] tmpl = pkg_resources.resource_string( 'rhodecode', jn('config', 'rcextensions', '__init__.py') ) ext_file = jn(here, 'rcextensions', '__init__.py') if os.path.exists(ext_file): msg = ('Extension file already exists, do you want ' 'to overwrite it ? [y/n]') if ask_ok(msg): _make_file(ext_file) else: log.info('nothing done...') else: _make_file(ext_file) def update_parser(self): pass