Machine

@return void
772516
private function _machine()
    {
        if ($lines = $this->_get_buildprop()) {
            $buf = "";
            if (preg_match('/^ro\.product\.manufacturer=([^\n]+)/m', $lines, $ar_buf) && (trim($ar_buf[1]) !== "unknown")) {
                $buf .= ' '.trim($ar_buf[1]);
            }
            if (preg_match('/^ro\.product\.model=([^\n]+)/m', $lines, $ar_buf) && (trim($ar_buf[1]) !== trim($buf))) {
                $buf .= ' '.trim($ar_buf[1]);
            }
            if (preg_match('/^ro\.semc\.product\.name=([^\n]+)/m', $lines, $ar_buf)) {
                $buf .= ' '.trim($ar_buf[1]);
            }
            if (trim($buf) != "") {
                $this->sys->setMachine(trim($buf));
            }
        }
    }
905151
def add_machine(self, machine):
        """"""
        self._logger.debug('Adding machine {} to driver'.format(machine.id))
        machine._driver = self
        machine._reset()
        if machine.id is not None:
            # TODO warning when STM already registered
            Driver._stms_by_id[machine.id] = machine
            self._add_event(event_id=None, args=[], kwargs={}, stm=machine)
186119
public function run(): void
    {
        pcntl_async_signals(true);

        $this->makeSocket();

        [$pid, $master, $workers] = $this->spawn();

        if ($pid) {
            fclose($this->socket);
            $this->workerPids = $workers;
            $this->handleSignals();

            (new Master($workers, $this->unixConnector, $this->exchangeWorkersData))->dispatch();
        } else {
            if ($this->useConnector) {
                fclose($this->unixConnector);
            }

            (new $this->handler($this->socket, $master))->handle();
        }
    }
785379
public function (): void
    {
        $local_pids = $this->getLocalWorkerPids();
        $workers = $this->getAllWorkerIds();

        foreach ($workers as $worker) {
            [$host, $pid] = explode(':', $worker, 3);

            if ($host !== $this->hostname || in_array($pid, $local_pids, false) || $pid === getmypid()) {
                continue;
            }
            $this->log->debug(sprintf('Pruning dead worker: %s', $worker));

            $this->unregisterWorker($worker);
        }
    }
70461
public static function reset(IStateMachine $machine)
    {
        $machineHash = sha1(json_encode($machine->getConfig()->__toArray()));
        static::$statesTries[$machineHash] = [];
    }
904113
public function index() {
		$queueProcesses = $this->paginate();

		$this->set(compact('queueProcesses'));
		$this->helpers[] = 'Tools.Format';
		$this->helpers[] = 'Tools.Time';
		$this->helpers[] = 'Shim.Configure';
	}
945487
public function main()
    {
        $logger = Log::engine($this->params['logger']);
        $engine = $this->getEngine($logger);
        $worker = $this->getWorker($engine, $logger);
        $worker->work();
    }
672916
public function run()
    {
        factory(Term::class, 20)->create()->each(function ($u) {
            $u->taxonomy()->saveMany(factory(Taxonomy::class, 1)->make());
        });
    }
355557
public function main()
    {
        $options = (array)$this->params;
        $destination = normalizePath("{$options['destination']}/");

        if (is_string($options['tables'])) {
            $options['tables'] = explode(',', $options['tables']);
        }

        if (is_string($options['no-data'])) {
            $options['no-data'] = explode(',', $options['no-data']);
        }

        if (file_exists($destination)) {
            $dst = new Folder($destination);
            $dst->delete();
            $this->out(__d('system', 'Removing existing directory: {0}', $destination), 1, Shell::VERBOSE);
        } else {
            new Folder($destination, true);
            $this->out(__d('system', 'Creating directory: {0}', $destination), 1, Shell::VERBOSE);
        }

        $db = ConnectionManager::get('default');
        $db->connect();
        $schemaCollection = $db->schemaCollection();
        $tables = $schemaCollection->listTables();

        foreach ($tables as $table) {
            if (!empty($options['tables']) && !in_array($table, $options['tables'])) {
                $this->out(__d('system', 'Table "{0}" skipped', $table), 1, Shell::VERBOSE);
                continue;
            }

            $Table = TableRegistry::get($table);
            $Table->behaviors()->reset();
            $fields = [
                '_constraints' => [],
                '_indexes' => [],
                '_options' => (array)$Table->schema()->options(),
            ];
            $columns = $Table->schema()->columns();
            $records = [];
            $primaryKeys = [];

            foreach ($Table->schema()->indexes() as $indexName) {
                $index = $Table->schema()->index($indexName);
                if (!empty($index['columns'])) {
                    $fields['_indexes']["{$table}_{$indexName}_index"] = $index;
                }
            }

            foreach ($columns as $column) {
                $fields[$column] = $Table->schema()->column($column);
            }

            foreach ($Table->schema()->constraints() as $constraint) {
                $constraintName = in_array($constraint, $columns) ? Inflector::underscore("{$table}_{$constraint}") : $constraint;
                $fields['_constraints'][$constraintName] = $Table->schema()->constraint($constraint);
                if (isset($fields['_constraints']['primary']['columns'])) {
                    $primaryKeys = $fields['_constraints']['primary']['columns'];
                }
            }

            foreach ($fields as $column => $info) {
                if (isset($info['length']) &&
                    in_array($column, $primaryKeys) &&
                    isset($info['autoIncrement']) &&
                    $info['autoIncrement'] === true
                ) {
                    unset($fields[$column]['length']);
                }
            }

            // FIX: We need RAW data for time instead of Time Objects
            $originalTypes = [];
            foreach ($Table->schema()->columns() as $column) {
                $type = $Table->schema()->columnType($column);
                $originalTypes[$column] = $type;
                if (in_array($type, ['date', 'datetime', 'time'])) {
                    $Table->schema()->columnType($column, 'string');
                }
            }

            if ($options['mode'] === 'full') {
                foreach ($Table->find('all') as $row) {
                    $row = $row->toArray();
                    if ($this->params['no-id'] && isset($row['id'])) {
                        unset($row['id']);
                    }
                    $records[] = $row;
                }
            }

            $className = Inflector::camelize($table) . 'Fixture';
            if ($options['fixture'] && in_array($className, ['AcosFixture', 'UsersFixture'])) {
                $records = [];
            }

            // undo changes made by "FIX"
            foreach ($originalTypes as $column => $type) {
                $fields[$column]['type'] = $type;
            }

            if (empty($fields['_indexes'])) {
                unset($fields['_indexes']);
            }

            $fields = $this->_arrayToString($fields);
            $records = in_array($table, $options['no-data']) ? '[]' : $this->_arrayToString($records);

            $fixture = $this->_classFileHeader($className);
            $fixture .= "{\n";
            $fixture .= "\n";
            $fixture .= "    /**\n";
            $fixture .= "     * Table name.\n";
            $fixture .= "     *\n";
            $fixture .= "     * @var string\n";
            $fixture .= "     */\n";
            $fixture .= "    public \$table = '{$table}';\n";
            $fixture .= "\n";
            $fixture .= "    /**\n";
            $fixture .= "     * Table columns.\n";
            $fixture .= "     *\n";
            $fixture .= "     * @var array\n";
            $fixture .= "     */\n";
            $fixture .= "    public \$fields = {$fields};\n";
            $fixture .= "\n";
            $fixture .= "    /**\n";
            $fixture .= "     * Table records.\n";
            $fixture .= "     *\n";
            $fixture .= "     * @var array\n";
            $fixture .= "     */\n";
            $fixture .= "    public \$records = {$records};\n";
            $fixture .= "}\n";

            $file = new File(normalizePath("{$destination}/{$className}.php"), true);
            $file->write($fixture, 'w', true);
            $this->out(__d('system', 'Table "{0}" exported!', $table), 1, Shell::VERBOSE);
        }

        $this->out(__d('system', 'Database exported to: {0}', $destination));

        return true;
    }
229995
public function _run()
	{
		echo $this->_engine->get(
			$this->getTemplateFile(func_get_arg(0)),
			$this->getDataProvider(),
			$this->getCompiler()
		);
	}
1234496
protected function assemble()
    {
        $this->push('UPDATE');
        $this->pushTable();
        $this->push('SET');
        $this->pushValues();
        $this->pushWhere();
        $this->pushOrder();
        $this->pushLimit();
    }
470140
public function register() {
        $this->registerFilesystemProvider();
        $this->registerDatabaseProvider();
        $this->registerCompressorProvider();
        $this->registerShellProcessor();
        $this->registerArtisanCommands();
    }
840233
protected function job(): void
    {
        $divisions = $this->retrieve([
            'corporation_id' => $this->getCorporationId(),
        ]);

        if ($divisions->isCachedLoad()) return;

        if (property_exists($divisions, 'hangar'))

            collect($divisions->hangar)->each(function ($hangar) {

                CorporationDivision::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'type'           => 'hangar',
                    'division'       => $hangar->division,
                ])->fill([
                    'name' => $hangar->name ?? null,
                ])->save();
            });

        if (property_exists($divisions, 'wallet'))

            collect($divisions->wallet)->each(function ($wallet) {

                CorporationDivision::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'type'           => 'wallet',
                    'division'       => $wallet->division,
                ])->fill([
                    'name' => $wallet->name ?? null,
                ])->save();
            });
    }
300373
protected function job(): void
    {
        $mining_extractions = $this->retrieve([
            'corporation_id' => $this->getCorporationId(),
        ]);

        if ($mining_extractions->isCachedLoad()) return;

        collect($mining_extractions)->each(function ($extraction) {

            CorporationIndustryMiningExtraction::firstOrNew([
                'corporation_id' => $this->getCorporationId(),
                'structure_id'   => $extraction->structure_id,
            ])->fill([
                'extraction_start_time' => carbon($extraction->extraction_start_time),
                'moon_id'               => $extraction->moon_id,
                'chunk_arrival_time'    => carbon($extraction->chunk_arrival_time),
                'natural_decay_time'    => carbon($extraction->natural_decay_time),
            ])->save();
        });
    }
1107010
public function load()
    {
        $this->outputTitle('Loading predefined workers');
        $debug = $this->debug;

        if (!isset($this->runtime['Queues']) || empty($this->runtime['Queues'])) {
            $this->output->outputLine("You have no configured workers to load.\n", 'failure');
        } else {
            $this->output->outputLine(sprintf('Loading %s workers', count($this->runtime['Queues'])));

            $config = $this->config;

            foreach ($this->runtime['Queues'] as $queue) {
                $queue['config'] = $config;
                $queue['debug'] = $debug;
                $this->loadSettings('load', $queue);
                $this->start($this->runtime);
            }
        }

        if ($this->runtime['Scheduler']['enabled'] === true) {
            $this->startscheduler(array('debug' => $debug));
        }

        $this->output->outputLine();
    }
255453
public function process()
    {
        if (!$this->io->inReadQueue()) {
            return;
        }

        $line = $this->handleMessage($this->io->pop());
        if ($line) {
            $this->io->push($line);
            $this->io->write();
        }

        $this->bot->removeConnection($this);
        $this->disconnect();
    }
191037
public function run()
    {
        $data       = $this->parseRequestUri();
        $controller = $data['controller'];
        $method     = $data['method'];
        $params     = $data['params'];

        $subModule  = $this->subModule;
        if ("" != $subModule) {
            $subModule = "\\" . $subModule;
        }

        $class      = sprintf("%s\\Controller%s\\%sController", $this->appNameSpace, $subModule, $controller);
        if (!(class_exists($class) && method_exists($class, $method))) {
            $this->fileNotFound();
        } else {
            $class  = new $class;
            $pipe = new Pipeline();
            $pipe->through($class->getMiddleWare())->then(function () use ($class, $method, $params) {
                call_user_func_array(array($class, $method), $params);
            });

            //call_user_func_array(array($class, $method), $params);
        }
    }