Starting point of this tool, which identifies changes and generates respective
        operations.
165813
def generate_sql_changes(self):
        
        from_keys = set(self.from_sql_graph.nodes.keys())
        to_keys = set(self.to_sql_graph.nodes.keys())
        new_keys = to_keys - from_keys
        delete_keys = from_keys - to_keys
        changed_keys = set()
        dep_changed_keys = []

        for key in from_keys & to_keys:
            old_node = self.from_sql_graph.nodes[key]
            new_node = self.to_sql_graph.nodes[key]

            # identify SQL changes -- these will alter database.
            if not is_sql_equal(old_node.sql, new_node.sql):
                changed_keys.add(key)

            # identify dependencies change
            old_deps = self.from_sql_graph.dependencies[key]
            new_deps = self.to_sql_graph.dependencies[key]
            removed_deps = old_deps - new_deps
            added_deps = new_deps - old_deps
            if removed_deps or added_deps:
                dep_changed_keys.append((key, removed_deps, added_deps))

        # we do basic sort here and inject dependency keys here.
        # operations built using these keys will properly set operation dependencies which will
        # enforce django to build/keep a correct order of operations (stable_topological_sort).
        keys = self.assemble_changes(new_keys, changed_keys, self.to_sql_graph)
        delete_keys = self.assemble_changes(delete_keys, set(), self.from_sql_graph)

        self._sql_operations = {}
        self._generate_reversed_sql(keys, changed_keys)
        self._generate_sql(keys, changed_keys)
        self._generate_delete_sql(delete_keys)
        self._generate_altered_sql_dependencies(dep_changed_keys)
355393
def main():
    """"""
    log = logging.getLogger('sip.mock_workflow_stage')

    if len(sys.argv) != 2:
        log.critical('Expecting JSON string as first argument!')
        return

    config = json.loads(sys.argv[1])
    log.info('Running mock_workflow_stage (version: %s).', __version__)
    log.info('Received configuration: %s', json.dumps(config))
    log.info('Starting task')

    i = 0
    start_time = time.time()
    duration = config.get('duration', 20)
    while time.time() - start_time <= duration:
        time.sleep(duration / 20)
        elapsed = time.time() - start_time
        log.info("  %s %2i / 20 (elapsed %.2f s)",
                 config.get('message', 'Progress '),
                 i + 1, elapsed)
        i += 1

    log.info('Task complete!')
42747
def main():
    """"""
    # Parse command line args.
    _parse_args()
    LOG.info("Starting: %s", __service_id__)

    # Subscribe to state change events.
    # FIXME(BMo) This API is unfortunate as it looks like we are only
    # subscribing to sdp_state events.
    LOG.info('Subscribing to state change events (subscriber = %s)',
             __service_name__)
    sdp_state = SDPState()
    _ = sdp_state.subscribe(subscriber=__service_name__)

    # Initialise the service.
    _ = _init(sdp_state)
    LOG.info('Finished initialising!')

    # Enter a pseudo event-loop (using Sched) to monitor for state change
    # events
    # (Also random set services into a fault or alarm state if enabled)
    LOG.info('Responding to state change events ...')
    try:
        _process_state_change_events()
    except ValueError as error:
        LOG.critical('Value error: %s', str(error))
    except KeyboardInterrupt as err:
        LOG.debug('Keyboard Interrupt %s', err)
    LOG.info('Exiting!')
565852
public function changeOrganizationAction()
    {
        if ($this->changeOrganizationSnippets) {
            $params = $this->_processParameters(
                    $this->changeOrganizationParameters +
                    $this->editParameters +
                    $this->createEditParameters +
                    ['createData' => false]);

            $this->addSnippets($this->changeOrganizationSnippets, $params);
        }
    }
1121154
def _analyze(self):
        

        self._pre_analysis()

        if self._graph_visitor is None:
            # There is no base graph that we can rely on. The analysis itself should generate successors for the
            # current job.
            # An example is the CFG recovery.

            self._analysis_core_baremetal()

        else:
            # We have a base graph to follow. Just handle the current job.

            self._analysis_core_graph()

        self._post_analysis()
1086399
def on_ok(self):
        
        npyscreen.notify_wait('Deleting instances given...',
                              title='In progress')
        # keep track of number for shifting instances down for alignment
        shift_num = 1
        to_update = []
        for i, val in enumerate(self.del_instances.values):
            # clean all tools for renmaing and relabeling purposes
            t = val.split(':')
            section = self.display_to_section[val]
            prev_running = self.manifest.option(section, 'running')
            run = prev_running[0] and prev_running[1] == 'yes'
            if i in self.del_instances.value:
                if run:
                    # grab dependencies of tools that linked to previous one
                    if i == 0:
                        dependent_tools = [self.manifest.option(
                            section, 'link_name')[1]]
                        for dependency in Dependencies(dependent_tools):
                            self.clean(**dependency)
                            to_update.append(dependency)
                    self.clean(name=t[0], branch=t[1], version=t[2])
                self.manifest.del_section(section)
            else:
                try:
                    # update instances for tools remaining
                    section = self.display_to_section[val]
                    settings_dict = json.loads(self.manifest.option
                                               (section, 'settings')[1])
                    settings_dict['instances'] = self.new_instances
                    self.manifest.set_option(section, 'settings',
                                             json.dumps(settings_dict))
                    # check if tool name doesn't need to be shifted because
                    # it's already correct
                    identifier = str(shift_num) if shift_num != 1 else ''
                    new_section = section.rsplit(':', 2)
                    new_section[0] = re.sub(r'\d+$', identifier,
                                            new_section[0])
                    new_section = ':'.join(new_section)
                    if section != new_section:
                        # clean tool so that we can rename its container and
                        # labels with new information
                        self.clean(name=t[0], branch=t[1], version=t[2])
                        prev_name = self.manifest.option(section, 'name')[1]
                        new_name = re.split(r'[0-9]', prev_name)[0] + \
                            identifier
                        self.manifest.set_option(section, 'name', new_name)
                        # copy new contents into shifted version
                        self.manifest.add_section(new_section)
                        for val_pair in self.manifest.section(section)[1]:
                            self.manifest.set_option(new_section, val_pair[0],
                                                     val_pair[1])
                        self.manifest.del_section(section)
                        if run:
                            to_update.append({'name': new_name,
                                              'branch': t[1],
                                              'version': t[2]})
                    shift_num += 1
                except Exception as e:
                    npyscreen.notify_confirm('Trouble deleting tools'
                                             ' because ' + str(e))
        self.manifest.write_config()
        tool_d = {}
        for tool in to_update:
            tool_d.update(self.prep_start(**tool)[1])
        if tool_d:
            self.start_tools(tool_d)
        npyscreen.notify_confirm('Done deleting instances.',
                                 title='Finished')
        self.change_screens()
73577
def main():
    """"""
    last_known = '0'
    if os.path.isfile(metafile):
        with open(metafile) as fh:
            last_known = fh.read()

    import mbed_cloud
    current = mbed_cloud.__version__

    # how significant a change in version scheme should trigger a new changelog entry
    # (api major, api minor, sdk major, sdk minor, sdk patch)
    sigfigs = 4
    current_version = LooseVersion(current).version
    last_known_version = LooseVersion(last_known).version

    should_towncrier = current_version[:sigfigs] != last_known_version[:sigfigs]

    print('%s -- %s :: current vs previous changelog build' % (current, last_known))
    if should_towncrier:
        print('%s >> %s :: running changelog build' % (current, last_known))
        subprocess.check_call(
            ['towncrier', '--yes'],
            cwd=os.path.join(PROJECT_ROOT, 'docs', 'changelog')
        )
        with open(metafile, 'w') as fh:
            fh.write(current)
105222
private void processStateChanges(final Map<String, String> changes) {
        workflowEngine.event(WorkflowSystemEventType.WillProcessStateChange,
                             String.format("saw state changes: %s", changes), changes
        );

        workflowEngine.getState().updateState(changes);

        boolean update = Rules.update(workflowEngine.getRuleEngine(), workflowEngine.getState());
        workflowEngine.event(
                WorkflowSystemEventType.DidProcessStateChange,
                String.format(
                        "applied state changes and rules (changed? %s): %s",
                        update,
                        workflowEngine.getState()
                ),
                workflowEngine.getState()
        );
    }
455870
def generate(self):
    
    self._setup()

    header_html = self._generate_header()
    footer_html = self._generate_footer()
    results_topbar_html = self._generate_topbar("results")
    summary_topbar_html = self._generate_topbar("summary")
    logs_topbar_html = self._generate_topbar("logs")
    diff_topbar_html = self._generate_topbar("diff")

    summary_body_html = self._generate_summary_body()
    diff_body_html = self._generate_diff_body()
    summary_html = header_html + summary_topbar_html + summary_body_html + footer_html
    diff_html = header_html + diff_topbar_html + diff_body_html+ footer_html
    Reporter._make_file(summary_html, self.report_info.home_page)
    Reporter._make_file(diff_html,self.report_info.diff_page)

    log_body_html = self._generate_log_body()
    log_html = header_html + logs_topbar_html + log_body_html+footer_html
    Reporter._make_file(log_html, self.report_info.log_page)

    for config_name in self.report_info.config_to_test_names_map.keys():
      config_dir = os.path.join(self.report_info.resource_dir, config_name)
      utils.makedirs(config_dir)

      config_body_html = self._generate_config_body(config_name)
      config_html = header_html + results_topbar_html + config_body_html + footer_html
      config_file = os.path.join(config_dir, config_name + self.report_info.report_file_sfx)
      Reporter._make_file(config_html, config_file)

      for test_name in self.data_source.get_test_names(config_name):
        test_body_html = self._generate_test_body(config_name, test_name)
        test_html = header_html + results_topbar_html + test_body_html + footer_html
        test_file = os.path.join(config_dir, test_name + self.report_info.report_file_sfx)
        Reporter._make_file(test_html, test_file)
491282
def main(self):
        
        parser = self.init_parser()
        self.args = parser.parse_args()

        if self.args.debug:
            coloredlogs.install(level=logging.DEBUG, fmt=LOG_FORMAT)

        self.work()
59596
def main():
    
    args = parse_args()
    logging.basicConfig(level=LOG_LEVELS[min(
        args.verbosity, len(LOG_LEVELS) - 1)])

    loop = asyncio.get_event_loop()
    loop.run_until_complete(_run(args))
21591
def create(self):
        
        self.add_handlers({'^Q': self.quit})
        self.add(npyscreen.TitleText,
                 name='Select which tools to add from each branch selected:',
                 editable=False)
        self.add(npyscreen.Textfield,
                 value='NOTE tools you have already installed will be ignored',
                 color='STANDOUT',
                 editable=False)

        i = 6
        for branch in self.parentApp.repo_value['versions']:
            self.tools_tc[branch] = {}
            self.add(npyscreen.TitleText,
                     name='Branch: ' + branch,
                     editable=False,
                     rely=i,
                     relx=5,
                     max_width=25)
            tools = self.repo_tools(branch)
            i += 1
            for tool in tools:
                value = True
                if tool.startswith('/dev'):
                    value = False
                # tool in base directory
                if tool == '' or tool.startswith(':'):
                    tool = '/' + tool
                self.tools_tc[branch][tool] = self.add(npyscreen.CheckBox,
                                                       name=tool,
                                                       value=value,
                                                       relx=10)
                i += 1
            i += 2
1019671
def run_on_changes(paths)
      validate_at_least_one_target('copy')
      with_all_target_paths(paths) do |from_path, to_path|
        to_dir = File.dirname(to_path)
        if !File.directory?(to_dir) && options[:mkpath]
          UI.info("creating directory #{to_dir}") if options[:verbose]
          FileUtils.mkpath(to_dir)
        end
        validate_to_path(to_path)
        UI.info("copying to #{to_path}") if options[:verbose]
        copy(from_path, to_path)
      end
    end
754892
def rerun(client, revision, roots, siblings, inputs, paths):
    """"""
    graph = Graph(client)
    outputs = graph.build(paths=paths, revision=revision)

    # Check or extend siblings of outputs.
    outputs = siblings(graph, outputs)
    output_paths = {node.path for node in outputs}

    # Normalize and check all starting paths.
    roots = {graph.normalize_path(root) for root in roots}
    assert not roots & output_paths, '--from colides with output paths'

    # Generate workflow and check inputs.
    # NOTE The workflow creation is done before opening a new file.
    workflow = inputs(
        client,
        graph.ascwl(
            input_paths=roots,
            output_paths=output_paths,
            outputs=outputs,
        )
    )

    # Make sure all inputs are pulled from a storage.
    client.pull_paths_from_storage(
        *(path for _, path in workflow.iter_input_files(client.workflow_path))
    )

    # Store the generated workflow used for updating paths.
    import yaml

    output_file = client.workflow_path / '{0}.cwl'.format(uuid.uuid4().hex)
    with output_file.open('w') as f:
        f.write(
            yaml.dump(
                ascwl(
                    workflow,
                    filter=lambda _, x: x is not None,
                    basedir=client.workflow_path,
                ),
                default_flow_style=False
            )
        )

    # Execute the workflow and relocate all output files.
    from ._cwl import execute
    # FIXME get new output paths for edited tools
    # output_paths = {path for _, path in workflow.iter_output_files()}
    execute(
        client,
        output_file,
        output_paths=output_paths,
    )
519144
@Override
    public void processConfigurationChanges() {
        // The monitor ID is used to determine who is called to process file events.
        for (ServiceReference<FileMonitor> fm : fileMonitors.keySet()) {
            String monitorId = (String) fm.getProperty(com.ibm.ws.kernel.filemonitor.FileMonitor.MONITOR_IDENTIFICATION_NAME);
            if (monitorId != null && monitorId.equals("com.ibm.ws.kernel.monitor.config")) {
                fileMonitors.get(fm).processFileRefresh(false, null);
            }
        }
    }
117327
def main():
    """"""
    parser = getBasicOptionParser()

    parser.add_argument("jobStore", type=str,
                        help="The location of a job store that holds the information about the "
                             "workflow whose status is to be reported on." + jobStoreLocatorHelp)

    parser.add_argument("--failIfNotComplete", action="store_true",
                        help="Return exit value of 1 if toil jobs not all completed. default=%(default)s",
                        default=False)

    parser.add_argument("--noAggStats", dest="stats", action="store_false",
                        help="Do not print overall, aggregate status of workflow.",
                        default=True)

    parser.add_argument("--printDot", action="store_true",
                        help="Print dot formatted description of the graph. If using --jobs will "
                             "restrict to subgraph including only those jobs. default=%(default)s",
                        default=False)

    parser.add_argument("--jobs", nargs='+',
                        help="Restrict reporting to the following jobs (allows subsetting of the report).",
                        default=None)

    parser.add_argument("--printPerJobStats", action="store_true",
                        help="Print info about each job. default=%(default)s",
                        default=False)

    parser.add_argument("--printLogs", action="store_true",
                        help="Print the log files of jobs (if they exist). default=%(default)s",
                        default=False)

    parser.add_argument("--printChildren", action="store_true",
                        help="Print children of each job. default=%(default)s",
                        default=False)

    parser.add_argument("--version", action='version', version=version)

    options = parseBasicOptions(parser)

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(0)

    config = Config()
    config.setOptions(options)

    try:
        status = ToilStatus(config.jobStore, options.jobs)
    except NoSuchJobStoreException:
        print('No job store found.')
        return
    except JobException:  # Workflow likely complete, user informed in ToilStatus()
        return

    jobStats = status.report_on_jobs()

    # Info to be reported.
    hasChildren = jobStats['hasChildren']
    readyToRun = jobStats['readyToRun']
    zombies = jobStats['zombies']
    hasServices = jobStats['hasServices']
    services = jobStats['services']
    hasLogFile = jobStats['hasLogFile']
    properties = jobStats['properties']
    childNumber = jobStats['childNumber']

    if options.printPerJobStats:
        status.printAggregateJobStats(properties, childNumber)
    if options.printLogs:
        status.printJobLog()
    if options.printChildren:
        status.printJobChildren()
    if options.printDot:
        status.print_dot_chart()
    if options.stats:
        print('Of the %i jobs considered, '
           'there are %i jobs with children, '
           '%i jobs ready to run, '
           '%i zombie jobs, '
           '%i jobs with services, '
           '%i services, '
           'and %i jobs with log files currently in %s.' %
            (len(status.jobsToReport), len(hasChildren), len(readyToRun), len(zombies),
             len(hasServices), len(services), len(hasLogFile), status.jobStore))

    if len(status.jobsToReport) > 0 and options.failIfNotComplete:
        # Upon workflow completion, all jobs will have been removed from job store
        exit(1)
651773
def genOutputs(self, code, match):
        

        out = sorted((k, match.output(m)) for (k, m) in
                     self.collectTriggers(match.match, code).items())
        out = list(map(lambda a: a[1], out))
        return out