Пример #1
0
def main():
	# Run the app:
	with MyApp() as app:
		# Register custom app hooks
		hook.register('pre_close', my_cleanup_hook)

		# Add args to parser. These must not conflict with the controller's
		app.args.add_argument('-ll', '--llau', action='store', metavar='STR', help='The notorious Llau option')

		# Log stuff
		app.log.debug("Starting the app")

		try:
			app.run()
		except CaughtSignal as e:
			if(e.signum == signal.SIGTERM):
				print("Caught SIGTERM")
			elif(e.signum == signal.SIGINT):
				print("Caught SIGINT")

		except FrameworkError as fe:
			print("FrameworkError: %e" %fe)

		finally:
			if(app.debug):
				import traceback
				traceback.print_exc()

		if app.pargs.llau:
			app.log.info("Llau flag received: %s" % app.pargs.foo )
Пример #2
0
    def pyramid_app(self):
        self.log.debug("Bootstrapping pyramid application")
        # setup logging
        logger = logging.getLogger("mokacms")
        current_level = self.log.level()
        logger.setLevel(current_level)
        ch = logging.StreamHandler()
        formatter = logging.Formatter("%(levelname)s: [mokacms] %(message)s")
        ch.setLevel(current_level)
        ch.setFormatter(formatter)
        logger.addHandler(ch)

        try:
            env = bootstrap(self.pargs.ini)

        except:
            self.log.error("Cannot bootstrap application")
            raise

        def cleanup(_):
            self.log.debug("Calling pyramid app closer")
            env['closer']()

        hook.register("pre_close", cleanup)
        return env
Пример #3
0
def main():
    "Main entry point of application"
    global app

    # print('LOGGING_CFG[pid [%s] = %s'% (os.getpid(), os.environ.get('LOGGING_CFG')) )
    log.info('>>> LOGGING_CFG[pid [%s] = %s', os.getpid(),
             os.environ.get('LOGGING_CFG'))

    with SwarmForce() as app:
        try:
            hook.register('signal', my_signal_handler)
            app.run()

            app.daemonize()

            try:
                killtimeout = app.config.get('swarmforce', 'killtimeout')
                killtimeout = killtimeout and float(killtimeout)
                now = time.time()
                for i in xrange(100):
                    log.info('pid[%s] loop: %s' % (os.getpid(), i))

                    # print 'print: pid[%s] loop: %s' % (os.getpid(), i)
                    time.sleep(1)
                    if random.random() < 0.5:
                        app.layout.clean_dead()

                    if killtimeout and \
                       time.time() > now + killtimeout:
                        print "-Timeout-"
                        break

            except CaughtSignal as e:
                print(e)

        except CaughtSignal as e:
            # determine what the signal
            # and do something with it
            from signal import SIGINT, SIGABRT

            if e.signum == SIGINT:
                # do something... maybe change the exit code?
                app.exit_code = 110
            elif e.signum == SIGABRT:
                # do something else...
                app.exit_code = 111

        except FrameworkError as e:
            # do something when a framework error happens
            print("FrameworkError => %s" % e)

            # and maybe set the exit code to something unique as well
            app.exit_code = 300

        finally:
            # Maybe we want to see a full-stack trace for the above
            # exceptions, but only if --debug was passed?
            if app.debug:
                import traceback
                traceback.print_exc()
Пример #4
0
    def setup(self):
        # Add hooks
        hook.register('post_argument_parsing', hooks.pre_run_hook)

        # Add controllers
        controllers = [
            InitController,
            CreateController,
            EventsController,
            LogsController,
            PrintEnvController,
            DeployController,
            StatusController,
            TerminateController,
            ConfigController,
            SwapController,
            OpenController,
            ConsoleController,
            ScaleController,
            SSHController,
            UseController,
            SetEnvController,
            ListController,
            PlatformController,
            CloneController,
            UpgradeController,
            AbortController,
            LabsController,
            LocalController,
            HealthController,
            CodeSourceController,
        ]

        # register all controllers
        for c in controllers:
            c._add_to_handler(handler)

        # Add special controllers
        handler.register(CompleterController)

        super(EB, self).setup()

        #Register global arguments
        self.add_arg('-v',
                     '--verbose',
                     action='store_true',
                     help=flag_text['base.verbose'])
        self.add_arg('--profile', help=flag_text['base.profile'])
        self.add_arg('-r', '--region', help=flag_text['base.region'])
        self.add_arg('--endpoint-url', help=SUPPRESS)
        self.add_arg('--no-verify-ssl',
                     action='store_true',
                     help=flag_text['base.noverify'])
        self.add_arg(
            '--debugboto',  # show debug info for botocore
            action='store_true',
            help=SUPPRESS)

        ebglobals.app = self
Пример #5
0
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(SSSStackController)
    handler.register(SSSStackMigrateController)
    handler.register(SSSStackStatusController)
    handler.register(SSSStackUpgradeController)
    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', sss_stack_hook)
Пример #6
0
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(SSSStackController)
    handler.register(SSSStackMigrateController)
    handler.register(SSSStackStatusController)
    handler.register(SSSStackUpgradeController)
    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', sss_stack_hook)
Пример #7
0
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(SSSSiteController)
    handler.register(SSSSiteCreateController)
    handler.register(SSSSiteEditController)
    handler.register(SSSSiteDeleteController)
    handler.register(SSSSiteListController)
    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', sss_site_hook)
Пример #8
0
def main():
    # Squash cement logging
    ######
    for d, k in iteritems(logging.Logger.manager.loggerDict):
        if d.startswith('cement') and isinstance(k, logging.Logger):
            k.setLevel('ERROR')
    #######

    app = EB()
    hook.register('post_argument_parsing', hooks.pre_run_hook)

    try:
        app.setup()
        app.run()

    # Handle General Exceptions
    except CaughtSignal:
        io.echo()
        app.close(code=5)
    except NoEnvironmentForBranchError:
        pass
    except InvalidStateError:
        io.log_error(strings['exit.invalidstate'])
        app.close(code=3)
    except NotInitializedError:
        io.log_error(strings['exit.notsetup'])
        app.close(code=126)
    except NoSourceControlError:
        io.log_error(strings['sc.notfound'])
        app.close(code=3)
    except NoRegionError:
        io.log_error(strings['exit.noregion'])
        app.close(code=3)
    except ConnectionError:
        io.log_error(strings['connection.error'])
        app.close(code=2)
    except EBCLIException as e:
        if app.pargs.debug:
            raise

        message = next(io._convert_to_strings([e]))

        if app.pargs.verbose:
            io.log_error(e.__class__.__name__ + " - " + message)
        else:
            io.log_error(message)
        app.close(code=4)
    except Exception as e:
        # Generic catch all
        if app.pargs.debug:
            raise

        message = next(io._convert_to_strings([e]))
        io.log_error(e.__class__.__name__ + " :: " + message)
        app.close(code=10)
    finally:
        app.close()
Пример #9
0
def load():
    # register hook
    hook.register('pre_setup', init_configuration_file)

    # register controllers
    # handler.define(IRESTApi)

    handler.register(P4CMInfoController)
    handler.register(P4CMConfigController)
Пример #10
0
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(SSSSiteController)
    handler.register(SSSSiteCreateController)
    handler.register(SSSSiteEditController)
    handler.register(SSSSiteDeleteController)
    handler.register(SSSSiteListController)
    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', sss_site_hook)
Пример #11
0
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(EELogController)
    handler.register(EELogShowController)
    handler.register(EELogResetController)
    handler.register(EELogGzipController)
    handler.register(EELogMailController)
    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', ee_log_hook)
Пример #12
0
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(EELogController)
    handler.register(EELogShowController)
    handler.register(EELogResetController)
    handler.register(EELogGzipController)
    handler.register(EELogMailController)
    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', ee_log_hook)
Пример #13
0
def main():
    # Squash cement logging
    ######
    for d, k in iteritems(logging.Logger.manager.loggerDict):
        if d.startswith('cement') and isinstance(k, logging.Logger):
            k.setLevel('ERROR')
    #######

    app = EB()
    hook.register('post_argument_parsing', hooks.pre_run_hook)

    try:
        app.setup()
        app.run()

    # Handle General Exceptions
    except CaughtSignal:
        io.echo()
        app.close(code=5)
    except NoEnvironmentForBranchError:
        pass
    except InvalidStateError:
        io.log_error(strings['exit.invalidstate'])
        app.close(code=3)
    except NotInitializedError:
        io.log_error(strings['exit.notsetup'])
        app.close(code=126)
    except NoSourceControlError:
        io.log_error(strings['sc.notfound'])
        app.close(code=3)
    except NoRegionError:
        io.log_error(strings['exit.noregion'])
        app.close(code=3)
    except ConnectionError:
        io.log_error(strings['connection.error'])
        app.close(code=2)
    except EBCLIException as e:
        if app.pargs.debug:
            raise

        message = next(io._convert_to_strings([e]))

        if app.pargs.verbose:
            io.log_error(e.__class__.__name__ + " - " + message)
        else:
            io.log_error(message)
        app.close(code=4)
    except Exception as e:
        # Generic catch all
        if app.pargs.debug:
            raise

        message = next(io._convert_to_strings([e]))
        io.log_error(e.__class__.__name__ + " :: " + message)
        app.close(code=10)
    finally:
        app.close()
Пример #14
0
def main():
	app = DigitalOceanApp()
	handler.register(ApiController)
	hook.register('post_argument_parsing', token_check_hook, weight=0)
	hook.register('post_argument_parsing', setup_manager_hook, weight=1)
	try:
		app.setup()
		app.run()
	finally:
		app.close()
Пример #15
0
def load():
    # Subcontrollers for each functional component
    handler.register(cli.cloudlet.NephoCloudletController)
    handler.register(cli.blueprint.NephoBlueprintController)
    handler.register(cli.stack.NephoStackController)
    handler.register(cli.parameter.NephoParameterController)
    handler.register(cli.scope.NephoScopeController)

    hook.register('post_argument_parsing', cli.hooks.set_scope)
    hook.register('post_setup', cli.hooks.process_config)
Пример #16
0
    def test_signal_handling(self):
        self.app.setup()
        hook.register('pre_reload_config', bogus_hook_func)
        hook.register('post_reload_config', bogus_hook_func)
        self.app.run()

        sleep(1)
        try:
            ext_reload_config.signal_handler(signal.SIGINT, None)
        finally:
            self.app.close()
Пример #17
0
    def setup(self):
        # Add hooks
        hook.register('post_argument_parsing', hooks.pre_run_hook)

        # Add controllers
        controllers = [
            InitController,
            CreateController,
            EventsController,
            LogsController,
            PrintEnvController,
            DeployController,
            StatusController,
            TerminateController,
            ConfigController,
            SwapController,
            OpenController,
            ConsoleController,
            ScaleController,
            SSHController,
            UseController,
            SetEnvController,
            ListController,
            PlatformController,
            CloneController,
            UpgradeController,
            AbortController,
            LabsController,
            LocalController,
            HealthController,
        ]

        # register all controllers
        for c in controllers:
            c._add_to_handler(handler)

        # Add special controllers
        handler.register(CompleterController)

        super(EB, self).setup()

        #Register global arguments
        self.add_arg('-v', '--verbose',
                     action='store_true', help=flag_text['base.verbose'])
        self.add_arg('--profile', help=flag_text['base.profile'])
        self.add_arg('-r', '--region', help=flag_text['base.region'])
        self.add_arg('--endpoint-url', help=SUPPRESS)
        self.add_arg('--no-verify-ssl',
                     action='store_true', help=flag_text['base.noverify'])
        self.add_arg('--debugboto',  # show debug info for botocore
                     action='store_true', help=SUPPRESS)

        ebglobals.app = self
Пример #18
0
    def setup(self):
        ebglobals.app = self

        # Add hooks
        hook.register('post_argument_parsing', hooks.pre_run_hook)

        platform_controllers = [
            EBPEventsController,
            EBPListController,
            EBPStatusController,
            EBPUseController,
            EBPCreateController,
            EBPDeleteController,
            EBPLogsController,
        ]

        workspace_type = fileoperations.get_workspace_type(None)

        # Only load this if the the directory has not ben intialized or if it is a platform workspace
        if not fileoperations.get_workspace_type(
                None) or Constants.WorkSpaceTypes.PLATFORM == workspace_type:
            EBPInitController._add_to_handler(handler)

        if Constants.WorkSpaceTypes.APPLICATION == workspace_type:
            raise ApplicationWorkspaceNotSupportedError(
                strings['exit.applicationworkspacenotsupported'])
            # raise RuntimeError("Foo")
        elif Constants.WorkSpaceTypes.PLATFORM == workspace_type:
            for c in platform_controllers:
                c._add_to_handler(handler)
                pass

        # Add special controllers
        handler.register(CompleterController)

        super(EBP, self).setup()

        #Register global arguments
        self.add_arg('-v',
                     '--verbose',
                     action='store_true',
                     help=flag_text['base.verbose'])
        self.add_arg('--profile', help=flag_text['base.profile'])
        self.add_arg('-r', '--region', help=flag_text['base.region'])
        self.add_arg('--endpoint-url', help=SUPPRESS)
        self.add_arg('--no-verify-ssl',
                     action='store_true',
                     help=flag_text['base.noverify'])
        self.add_arg(
            '--debugboto',  # show debug info for botocore
            action='store_true',
            help=SUPPRESS)
Пример #19
0
    def setup(self):
        # always run core setup first
        super(shEventEngine, self).setup()

        self.log.debug('setup()')

        self._loop = asyncio.get_event_loop()

        # Create a ThreadPool with 2 threads
        self._thread = ThreadPoolExecutor(2)

        hook.register('post_run', self._post_run, weight=-1)
        hook.register('pre_close', self._pre_close, weight=-1)
Пример #20
0
    def setup(self):
        # always run core setup first
        super(shEventEngine, self).setup()

        self.log.debug('setup()')

        self._loop = asyncio.get_event_loop()

        # Create a ThreadPool with 2 threads
        self._thread = ThreadPoolExecutor(2)

        hook.register('post_run', self._post_run, weight=-1)
        hook.register('pre_close', self._pre_close, weight=-1)
Пример #21
0
def load():
    """Called by the framework when the extension is 'loaded'."""
    hook.register('post_setup', add_drmaa_option)
    hook.register('post_setup', add_sbatch_option)
    hook.register('post_setup', add_shared_distributed_options)
    hook.register('pre_run', set_distributed_handler)
    handler.register(DistributedCommandHandler)
Пример #22
0
def load():
    """Called by the framework when the extension is 'loaded'."""
    hook.register('post_setup', add_drmaa_option)
    hook.register('post_setup', add_sbatch_option)
    hook.register('post_setup', add_shared_distributed_options)
    hook.register('pre_run', set_distributed_handler)
    handler.register(DistributedCommandHandler)
Пример #23
0
def main_1():
    s_time = datetime.utcnow()

    app = MyApp(APP_NAME)

    hook.register('post_argument_parsing', hook_post_argument_parsing)
    hook.register('pre_close', hook_pre_close)

    try:
        app.setup()
        app.run()
    finally:
        e_time = datetime.utcnow()
        t_time = (e_time - s_time)
        app.log_notice("Done.(%s)" % (str(t_time)))
        app.close()
Пример #24
0
    def test_reload_config(self):
        self.app.setup()
        hook.register('pre_reload_config', bogus_hook_func)
        hook.register('post_reload_config', bogus_hook_func)
        self.app.run()
        self.eq(self.app.config.get(APP, 'foo'), 'bar1')

        f = open(self.tmp_file, 'w')
        f.write(CONFIG2)
        f.close()

        sleep(1)

        try:
            self.eq(self.app.config.get(APP, 'foo'), 'bar2')
        finally:
            self.app.close()
Пример #25
0
def load():
    """Called by the framework when the extension is 'loaded'."""
    if not os.getenv("DRMAA_LIBRARY_PATH"):
        LOG.debug("No environment variable $DRMAA_LIBRARY_PATH: loading {} failed".format(__name__))
        return
    hook.register('post_setup', add_drmaa_option)
    hook.register('post_setup', add_shared_distributed_options)
    hook.register('pre_run', set_distributed_handler)
    hook.register('post_run', run_batch_command)
    handler.register(DistributedCommandHandler)
Пример #26
0
    def setup(self):
        ebglobals.app = self

        # Add hooks
        hook.register('post_argument_parsing', hooks.pre_run_hook)

        platform_controllers = [
            EBPEventsController,
            EBPListController,
            EBPStatusController,
            EBPUseController,
            EBPCreateController,
            EBPDeleteController,
            EBPLogsController,
        ]

        workspace_type = fileoperations.get_workspace_type(None)

        # Only load this if the the directory has not ben intialized or if it is a platform workspace
        if not fileoperations.get_workspace_type(None) or Constants.WorkSpaceTypes.PLATFORM == workspace_type:
            EBPInitController._add_to_handler(handler)

        if Constants.WorkSpaceTypes.APPLICATION == workspace_type:
            raise ApplicationWorkspaceNotSupportedError(strings['exit.applicationworkspacenotsupported'])
            # raise RuntimeError("Foo")
        elif Constants.WorkSpaceTypes.PLATFORM == workspace_type:
            for c in platform_controllers:
                c._add_to_handler(handler)
                pass

        # Add special controllers
        handler.register(CompleterController)

        super(EBP, self).setup()

        #Register global arguments
        self.add_arg('-v', '--verbose',
                     action='store_true', help=flag_text['base.verbose'])
        self.add_arg('--profile', help=flag_text['base.profile'])
        self.add_arg('-r', '--region', help=flag_text['base.region'])
        self.add_arg('--endpoint-url', help=SUPPRESS)
        self.add_arg('--no-verify-ssl',
                     action='store_true', help=flag_text['base.noverify'])
        self.add_arg('--debugboto',  # show debug info for botocore
                     action='store_true', help=SUPPRESS)
Пример #27
0
    def setup(self):
        ebglobals.app = self

        # Add hooks
        hook.register('post_argument_parsing', hooks.pre_run_hook)

        platform_controllers = [
            EBPInitController,
            EBPCreateController,
            EBPDeleteController,
            EBPEventsController,
            EBPListController,
            EBPLogsController,
            EBPStatusController,
            EBPUseController,
        ]

        [
            controller._add_to_handler(handler)
            for controller in platform_controllers
        ]

        # Add special controllers
        handler.register(CompleterController)

        super(EBP, self).setup()

        #Register global arguments
        self.add_arg('-v',
                     '--verbose',
                     action='store_true',
                     help=flag_text['base.verbose'])
        self.add_arg('--profile', help=flag_text['base.profile'])
        self.add_arg('-r', '--region', help=flag_text['base.region'])
        self.add_arg('--endpoint-url', help=SUPPRESS)
        self.add_arg('--no-verify-ssl',
                     action='store_true',
                     help=flag_text['base.noverify'])
        self.add_arg(
            '--debugboto',  # show debug info for botocore
            action='store_true',
            help=SUPPRESS)
Пример #28
0
def main():
    """
    Main entry point for command line interface.

    """
    app = SandglassCliApp()
    hook.register('post_argument_parsing', post_argument_parsing_hook)

    try:
        app.scan_commands()
        # Prepare application
        app.setup()
        # Add global application arguments
        app.args.add_argument('-c',
                              '--config',
                              action='store',
                              metavar='FILE',
                              help="sandglass config file",
                              default='sandglass.ini')
        # Execute command line application
        app.run()
    finally:
        app.close()
Пример #29
0
    def test_run(self):
        hook.register('nosetests_hook', cement_hook_one, weight=99)
        hook.register('nosetests_hook', cement_hook_two, weight=-1)
        hook.register('nosetests_hook', cement_hook_three, weight=-99)
        hook.register('nosetests_hook', cement_hook_six, weight=200)

        results = []
        for res in hook.run('nosetests_hook'):
            results.append(res)

        self.eq(results[0], 'kapla 3')
        self.eq(results[1], 'kapla 2')
        self.eq(results[2], 'kapla 1')
        self.eq(results[3], 'generator kapla 0')
        self.eq(results[4], 'generator kapla 1')
        self.eq(results[5], 'generator kapla 2')
Пример #30
0
    def test_run(self):
        hook.register('nosetests_hook', cement_hook_one, weight=99)
        hook.register('nosetests_hook', cement_hook_two, weight=-1)
        hook.register('nosetests_hook', cement_hook_three, weight=-99)
        hook.register('nosetests_hook', cement_hook_six, weight=200)

        results = []
        for res in hook.run('nosetests_hook'):
            results.append(res)

        self.eq(results[0], 'kapla 3')
        self.eq(results[1], 'kapla 2')
        self.eq(results[2], 'kapla 1')
        self.eq(results[3], 'generator kapla 0')
        self.eq(results[4], 'generator kapla 1')
        self.eq(results[5], 'generator kapla 2')
Пример #31
0
    def test_run(self):
        hook.register("nosetests_hook", cement_hook_one, weight=99)
        hook.register("nosetests_hook", cement_hook_two, weight=-1)
        hook.register("nosetests_hook", cement_hook_three, weight=-99)

        results = []
        for res in hook.run("nosetests_hook"):
            results.append(res)

        self.eq(results[0], "kapla 3")
        self.eq(results[1], "kapla 2")
        self.eq(results[2], "kapla 1")
Пример #32
0
            sleep(1)


class Skynet(foundation.CementApp):
    class Meta:
        label = 'skynet'
        base_controller = SkynetBaseController
        config_defaults = defaults
        arguments_override_config = True
        meta_override = ['database']


# create the app
app = Skynet(extensions=['daemon'])

# Register our signal handling hook
hook.register('signal', skynet_signal_handler)

try:
    # setup the application
    app.setup()
    # Add arguments
    app.args.add_argument('--passwd', action='store', dest='passwd')
    # run the application
    app.run()
except exc.CaughtSignal as e:
    pass
finally:
    # close the app
    app.close()
Пример #33
0
    def setup(self):
        ebglobals.app = self

        # Add hooks
        hook.register('post_argument_parsing', hooks.pre_run_hook)

        environment_controllers = [
            InitController,
            PlatformController,
            LogsController,
            SSHController,
            ConfigController,
            CreateController,
            EventsController,
            PrintEnvController,
            StatusController,
            TerminateController,
            DeployController,
            SwapController,
            OpenController,
            ConsoleController,
            ScaleController,
            UseController,
            SetEnvController,
            ListController,
            CloneController,
            UpgradeController,
            AbortController,
            LabsController,
            LocalController,
            HealthController,
            CodeSourceController,
            RestoreController,
            AppVersionController,
            LifecycleController,
            TagsController,
        ]

        # eb <foo> commands supported in platform workspaces
        platform_controllers = [
            ConfigController,
            ConsoleController,
            EventsController,
            ListController,
            LogsController,
            HealthController,
            SSHController,
            StatusController,
            TerminateController,
            PlatformController,
            UpgradeController,
        ]

        if "modules" in self.argv:
            for c in environment_controllers:
                c._add_to_handler(handler)

        else:
            workspace_type = fileoperations.get_workspace_type(
                Constants.WorkSpaceTypes.APPLICATION)

            if Constants.WorkSpaceTypes.APPLICATION == workspace_type:
                for c in environment_controllers:
                    c._add_to_handler(handler)
            elif Constants.WorkSpaceTypes.PLATFORM == workspace_type:
                for c in platform_controllers:
                    c._add_to_handler(handler)

        # Add special controllers
        handler.register(CompleterController)

        super(EB, self).setup()

        # Register global arguments
        self.add_arg('-v',
                     '--verbose',
                     action='store_true',
                     help=flag_text['base.verbose'])
        self.add_arg('--profile', help=flag_text['base.profile'])
        self.add_arg('-r', '--region', help=flag_text['base.region'])
        self.add_arg('--endpoint-url', help=SUPPRESS)
        self.add_arg('--no-verify-ssl',
                     action='store_true',
                     help=flag_text['base.noverify'])
        self.add_arg(
            '--debugboto',  # show debug info for botocore
            action='store_true',
            help=SUPPRESS)
Пример #34
0
def load(app=None):
    handler.register(ScanController)
    longbox = Longbox()
    hook.register('post_setup', longbox._setup)
Пример #35
0
def load(app=None):
    handler.register(MatchHandler)
    hook.register('post_setup', MatchHandler()._setup)
Пример #36
0
def load():
    """Load controller into application"""
    LOG.debug("Loading bcbioadmin controller")
    hook.register('post_setup', add_shared_bcbio_options)
    hook.register('pre_run', set_collection_handler)
    handler.register(BcbioAdminController)
Пример #37
0
def load(app):
    handler.register(WOSecureController)
    hook.register('post_argument_parsing', wo_secure_hook)
Пример #38
0
def load(ee):
    # register the controller with ee
    handler.register(samplePlugin4eeController)
    # register hook-functions with stack-hooks that are predefined in ee
    hook.register('stack_install_hook', sample_install_hookfunc)
    hook.register('stack_remove_hook', sample_remove_hookfunc)
    hook.register('stack_purge_hook', sample_purge_hookfunc)
    hook.register('stack_status_hook', sample_status_hookfunc)
    hook.register('stack_start_hook', sample_start_hookfunc)
    hook.register('stack_stop_hook', sample_stop_hookfunc)
    hook.register('stack_restart_hook', sample_reload_hookfunc)
    hook.register('stack_restart_hook', sample_restart_hookfunc)
    hook.register('stack_upgrade_hook', sample_upgrade_hookfunc)
Пример #39
0
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(EESecureController)
    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', ee_secure_hook)
Пример #40
0
 class Meta:
     label = 'myapp'
     base_controller = 'base'
     handlers = [MyBaseController, Post, Category]
     hook.register('pre_close', my_cleanup)
Пример #41
0
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(WOInfoController)

    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', wo_info_hook)
Пример #42
0
class Base(CementBaseController):
    class Meta:
        label = 'base'

    @expose(hide=True)
    def default(self):
        print('Inside Base.default()')

        # simulate a long running process
        while True:
            sleep(30)


class MyApp(CementApp):
    class Meta:
        label = 'myapp'
        base_controller = Base
        extensions = ['reload_config']


with MyApp() as app:
    # run this anytime the configuration has changed
    hook.register('post_reload_config', print_foo)

    try:
        app.run()
    except CaughtSignal as e:
        # maybe do something... but catch it regardless so app.close() is
        # called when exiting `with` cleanly.
        print(e)
Пример #43
0
def load(app):
    hook.register('process_event', process_event)

    app.log.info('Succeful Rules Plugin registration', __name__)
Пример #44
0
def load(app):
    hook.register('post_run', extend_app)
    hook.register('event_state', event_state)

    app.log.info('Succeful ISY Plugin registration', __name__)
Пример #45
0
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(EEImportslowlogController)

    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', ee_import_slow_log_hook)
def load(app):
    # register the plugin class.. this only happens if the plugin is enabled
    handler.register(SSSImportslowlogController)

    # register a hook (function) to run after arguments are parsed.
    hook.register('post_argument_parsing', sss_import_slow_log_hook)
Пример #47
0
def load(app=None):
    handler.register(FetchPulls)
    pulldb = PullDB()
    hook.register('post_setup', pulldb._setup)
Пример #48
0
def load():
    """Called by the framework when the extension is 'loaded'."""
    hook.register('post_setup', add_shared_couchdb_options)
Пример #49
0
import sys

from cement.core import hook
from openeye.oechem import OEChemIsLicensed

#@hook.register(name='cement_pre_run_hook')
def openeye_is_licensed_hook(app):
    """
    Check if a valid OpenEye license is present before running the application.
    """
    if hasattr(app.controller, 'Meta'):
        if app.controller.Meta.label == 'credo' and not OEChemIsLicensed():
            app.log.fatal("a valid OpenEye license is required for running credovi "
                          "with the 'credo' controller.")
            app.close()
hook.register('pre_run', openeye_is_licensed_hook)

#@hook.register(name='cement_post_run_hook')
def check_cmd_args_hook(app):
    """
    Check the combination of command line arguments that have been provided. Some
    are mutually exclusive and testing them through a hook seems to be the best
    solution.
    """
    controller = app.controller

    # no controller, nothing to check
    if not controller: return

    # get the controller command
    cmd = controller.command
Пример #50
0
    def setup(self):
        ebglobals.app = self

        # Add hooks
        hook.register('post_argument_parsing', hooks.pre_run_hook)

        environment_controllers = [
            InitController,
            PlatformController,
            LogsController,
            SSHController,
            ConfigController,
            CreateController,
            EventsController,
            PrintEnvController,
            StatusController,
            TerminateController,
            DeployController,
            SwapController,
            OpenController,
            ConsoleController,
            ScaleController,
            UseController,
            SetEnvController,
            ListController,
            CloneController,
            UpgradeController,
            AbortController,
            LabsController,
            LocalController,
            HealthController,
            CodeSourceController,
            RestoreController,
            AppVersionController,
            LifecycleController,
            TagsController,
        ]

        # eb <foo> commands supported in platform workspaces
        platform_controllers = [
            ConfigController,
            ConsoleController,
            EventsController,
            ListController,
            LogsController,
            HealthController,
            SSHController,
            StatusController,
            TerminateController,
            PlatformController,
            UpgradeController,
        ]

        if "--modules" in self.argv:
            for c in environment_controllers:
                c._add_to_handler(handler)

        else:
            workspace_type = fileoperations.get_workspace_type(Constants.WorkSpaceTypes.APPLICATION)

            if Constants.WorkSpaceTypes.APPLICATION == workspace_type:
                for c in environment_controllers:
                    c._add_to_handler(handler)
            elif Constants.WorkSpaceTypes.PLATFORM == workspace_type:
                for c in platform_controllers:
                    c._add_to_handler(handler)

        # Add special controllers
        handler.register(CompleterController)

        super(EB, self).setup()

        # Register global arguments
        self.add_arg('-v', '--verbose',
                     action='store_true', help=flag_text['base.verbose'])
        self.add_arg('--profile', help=flag_text['base.profile'])
        self.add_arg('-r', '--region', help=flag_text['base.region'])
        self.add_arg('--endpoint-url', help=SUPPRESS)
        self.add_arg('--no-verify-ssl',
                     action='store_true', help=flag_text['base.noverify'])
        self.add_arg('--debugboto',  # show debug info for botocore
                     action='store_true', help=SUPPRESS)
Пример #51
0
 def test_hooks_registered(self):
     hook.register('nosetests_hook', cement_hook_one, weight=99)
     hook.register('nosetests_hook', cement_hook_two, weight=-1)
     hook.register('some_bogus_hook', cement_hook_three, weight=-99)
     self.eq(len(backend.__hooks__['nosetests_hook']), 2)
Пример #52
0
 def test_hooks_registered(self):
     hook.register('nosetests_hook', cement_hook_one, weight=99)
     hook.register('nosetests_hook', cement_hook_two, weight=-1)
     hook.register('some_bogus_hook', cement_hook_three, weight=-99)
     self.eq(len(backend.__hooks__['nosetests_hook']), 2)
Пример #53
0
    def test_framework_hooks(self):
        app = self.make_app(APP, argv=['--quiet'])
        hook.register('pre_setup', cement_hook_one)
        hook.register('post_setup', cement_hook_one)
        hook.register('pre_run', cement_hook_one)
        hook.register('post_run', cement_hook_one)
        hook.register('pre_argument_parsing', cement_hook_one)
        hook.register('post_argument_parsing', cement_hook_one)
        hook.register('pre_close', cement_hook_one)
        hook.register('post_close', cement_hook_one)
        hook.register('signal', cement_hook_one)
        hook.register('pre_render', cement_hook_one)
        hook.register('pre_render', cement_hook_five)
        hook.register('post_render', cement_hook_one)
        hook.register('post_render', cement_hook_five)
        app.setup()
        app.run()
        app.render(dict(foo='bar'))
        app.close()

        # this is where cement_signal_hook is run
        try:
            frame = sys._getframe(0)
            foundation.cement_signal_handler(signal.SIGTERM, frame)
        except exc.CaughtSignal as e:
            pass
Пример #54
0
    def test_framework_hooks(self):
        app = self.make_app('myapp', argv=['--quiet'])
        hook.register('pre_setup', cement_hook_one)
        hook.register('post_setup', cement_hook_one)
        hook.register('pre_run', cement_hook_one)
        hook.register('post_run', cement_hook_one)
        hook.register('pre_close', cement_hook_one)
        hook.register('post_close', cement_hook_one)
        hook.register('signal', cement_hook_one)
        hook.register('pre_render', cement_hook_one)
        hook.register('pre_render', cement_hook_five)
        hook.register('post_render', cement_hook_one)
        hook.register('post_render', cement_hook_five)
        app.setup()
        app.run()
        app.render(dict(foo='bar'))
        app.close()

        # this is where cement_signal_hook is run
        try:
            foundation.cement_signal_handler(signal.SIGTERM, 5)
        except exc.CaughtSignal as e:
            pass
Пример #55
0
def load(app=None):
    transmission_handler = TransmissionClient()
    hook.register('post_setup', transmission_handler._setup)
    hook.register('post_argument_parsing',
                  transmission_handler._register_client)
Пример #56
0
def load(app):
    hook.register('pre_run', extend_app)