Hook into Gunicorn to display message after launching.

    This mimics the behaviour of Django's stock runserver command.
486309
def post_worker_init(worker):
    
    quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C'
    sys.stdout.write(
        "Django version {djangover}, Gunicorn version {gunicornver}, "
        "using settings {settings!r}\n"
        "Starting development server at {urls}\n"
        "Quit the server with {quit_command}.\n".format(
            djangover=django.get_version(),
            gunicornver=gunicorn.__version__,
            settings=os.environ.get('DJANGO_SETTINGS_MODULE'),
            urls=', '.join('http://{0}/'.format(b) for b in worker.cfg.bind),
            quit_command=quit_command,
        ),
    )
759245
def launch_server():
    
    print(os.path.dirname(os.path.abspath(__file__)))
    cur_dir = os.getcwd()
    path = os.path.dirname(os.path.abspath(__file__))
    run = True
    os.chdir(path)
    os.system('python manage.py runserver --nostatic')
    os.chdir(cur_dir)
720431
def launch(run=True, **args):
    """"""

    verbosity['console'] = args['log'] if not args['quiet'] else 100
    verbosity['global'] = min(args['log'], args['logfileverbosity'])
    verbosity['file'] = args['logfileverbosity'] if args['dolog'] else 100
    set_logfile(args['logfilepath'], args['instance'])

    if args['livelog'] is True:
        from hfos import logger
        logger.live = True

    hfoslog("Running with Python", sys.version.replace("\n", ""),
            sys.platform, lvl=debug, emitter='CORE')
    hfoslog("Interpreter executable:", sys.executable, emitter='CORE')
    if args['cert'] is not None:
        hfoslog("Warning! Using SSL without nginx is currently not broken!",
                lvl=critical, emitter='CORE')

    hfoslog("Initializing database access", emitter='CORE', lvl=debug)
    initialize(args['dbhost'], args['dbname'], args['instance'])

    server = construct_graph(args)
    if run and not args['norun']:
        server.run()

    return server
1027276
def eventloop(self, *args, **kwargs):
        

        # Setting status
        status = None

        # Starting the clock
        start = time.time()

        first_loop = True
        # loop running target, maybe more than once
        while not self.exit.is_set():

            if first_loop:
                first_loop = False
                # signalling startup only the first time, just after having check for exit request.
                # We need to return control before starting, but after entering context...
                self.started.set()
                # TODO : check if better outside of loop maybe ??
                # It will change semantics, but might be more intuitive...

            # time is ticking
            # TODO : move this out of here. this class should require only generic interface to any method.
            now = time.time()
            timedelta = now - start
            start = now

            # replacing the original Process.run() call, passing arguments to our target
            if self._target:
                # bwcompat
                kwargs['timedelta'] = timedelta

                # TODO : use return code to determine when/how we need to run this the next time...
                # Also we need to keep the exit status to be able to call external process as an update...

                logging.debug(
                    "[{self.name}] calling {self._target.__name__} with args {args} and kwargs {kwargs}...".format(
                        **locals()))
                status = self._target(*args, **kwargs)

            if status is not None:
                break

        if self.started.is_set() and status is None and self.exit.is_set():
            # in the not so special case where we started, we didnt get exit code and we exited,
            # this is expected as a normal result and we set an exitcode here of 0
            # As 0 is the conventional success for unix process successful run
            status = 0

        return status
436211
def post_command_event(target, msg_cls, **kwargs):
    

    msg = msg_cls(id=-1, **kwargs)
    wx.PostEvent(target, msg)
944837
def post_exec_hook(hook):
    
    #post_setupnode hook
    module_name = '.'.join([env.project_package_name,'deploy'])
    funcs_run = []
    try:
        imported = import_module(module_name)
        func = vars(imported).get(hook)
        if func:
            func()
            funcs_run.append(func)
    except ImportError:
        return

   #run per app
    for app in env.INSTALLED_APPS:
        if app == 'woven': continue
        module_name = '.'.join([app,'deploy'])
        try:
            imported = import_module(module_name)
            func = vars(imported).get(hook)
            if func and func not in funcs_run:
                func()
                funcs_run.append(func)
        except ImportError:
            pass
    import woven.deploy
    func = vars(woven.deploy).get(hook)
    if func and func not in funcs_run: func()
207119
def _runhook(ui, repo, hooktype, filename, kwargs):
    """"""
    hname = hooktype + ".autohooks." + os.path.basename(filename)
    if filename.lower().endswith(".py"):
        try:
            mod = mercurial.extensions.loadpath(filename,
                "hghook.%s" % hname)
        except Exception:
            ui.write(_("loading %s hook failed:\n") % hname)
            raise
        return mercurial.hook._pythonhook(ui, repo, hooktype, hname,
            getattr(mod, hooktype.replace("-", "_")), kwargs, True)
    elif filename.lower().endswith(".sh"):
        return mercurial.hook._exthook(ui, repo, hname, filename, kwargs, True)
    return False
190317
def run_hook(self, hook, *args, **kwargs):
        
        for plugin in self.raw_plugins:
            if hasattr(plugin, hook):
                self.logger.debug('Calling hook {0} in plugin {1}'.format(hook, plugin.__name__))
                getattr(plugin, hook)(*args, **kwargs)
272467
def run_hook(hook_name, project_dir, context):
    
    script = find_hook(hook_name)
    if script is None:
        logger.debug('No {} hook found'.format(hook_name))
        return
    logger.debug('Running hook {}'.format(hook_name))
    run_script_with_context(script, project_dir, context)
14140
def handle(self, targetdir, app=None, **options):
        
        translation.activate(settings.LANGUAGE_CODE)
        if app:
            unpack = app.split('.')

            if len(unpack) == 2:
                models = [get_model(unpack[0], unpack[1])]
            elif len(unpack) == 1:
                models = get_models(get_app(unpack[0]))
        else:
            models = get_models()
        
        messagemaker = MakeModelMessages(targetdir)
        
        for model in models:
            if hasattr(model, 'localized_fields'):
                for instance in model.objects.all():
                    messagemaker(instance)
1302858
def handle(self, *args, **opt):
        
        d1_gmn.app.management.commands.util.util.log_setup(opt["debug"])
        logging.info(
            "Running management command: {}".format(
                __name__
            )  # util.get_command_name())
        )
        d1_gmn.app.management.commands.util.util.exit_if_other_instance_is_running(
            __name__
        )
        self._opt = opt
        try:
            # profiler = profile.Profile()
            # profiler.runcall(self._handle)
            # profiler.print_stats()
            self._handle()
        except d1_common.types.exceptions.DataONEException as e:
            logging.error(str(e))
            raise django.core.management.base.CommandError(str(e))
        self._events.dump_to_log()
1261740
async def __run_listen(self):
        
        while True:
            message = await ZMQUtils.recv(self.__backend_socket)
            await self.__handle_backend_message(message)
558781
def _mq_callback(self, message):
        
        while threading.active_count() > settings.settings['bash_runnable_count'] + self.initial_thread_count:
            time.sleep(0.1)

        t = BashRunnable(self.logger, message, self.consumer, self.performance_tracker)
        t.daemon = True
        t.start()
328623
public function hookDisplayAdminNavBarBeforeEnd()
    {
        if (!$this->onBoarding->isFinished()) {
            $this->onBoarding->showModuleContentForNavBar($this->context->link);
        }
    }
789464
def main(argv=None):
    
    parser = argparse.ArgumentParser(
        description='Event storage and event proxy.',
        usage='%(prog)s <configfile>'
    )
    parser.add_argument('--exit-codeword', metavar="MSG", dest="exit_message",
                        default=None, help="An incoming message that makes"
                                           " Rewind quit. Used for testing.")
    parser.add_argument('configfile')

    args = argv if argv is not None else sys.argv[1:]
    args = parser.parse_args(args)

    config = configparser.SafeConfigParser()
    with open(args.configfile) as f:
        config.readfp(f)

    exitcode = run(config, args.exit_message)
    return exitcode
729237
def fire_running(self, running):
        '''
        
        '''
        load = {'id': self.opts['id'],
                'events': [],
                'cmd': '_minion_event'}
        for stag in sorted(
                running,
                key=lambda k: running[k].get('__run_num__', 0)):
            if running[stag]['result'] and not running[stag]['changes']:
                continue
            tag = 'state_{0}_{1}'.format(
                six.text_type(running[stag]['result']),
                'True' if running[stag]['changes'] else 'False')
            load['events'].append({
                'tag': tag,
                'data': running[stag],
            })
        channel = salt.transport.client.ReqChannel.factory(self.opts)
        try:
            channel.send(load)
        except Exception:
            pass
        finally:
            channel.close()
        return True
201876
def launch(self, args=None):
        
        self.options = self.parse_args(args)
        if self.options.saveinputmeta:
            # save original input options
            self.save_input_meta()
        if self.options.inputmeta:
            # read new options from JSON file
            self.options = self.get_options_from_file(self.options.inputmeta)
        self.run(self.options)
        # if required save meta data for the output after running the plugin app
        if self.options.saveoutputmeta:
            self.save_output_meta()