Chief executive viper function
977807
public function parse() {
		/** @noinspection PhpParamsInspection */
		return $this -> execute(Util::cache(
			$this -> file,
			$this -> raw,
			'viper',
			function($data): NodeCollection {
				$tokens = $this -> tokenize($data);
				return $this -> formLogicalTree($tokens);
			}
		), $this -> data);
	}
1305341
public function main()
    {
        $this->info('Task: import system roles');
        $this->hr();

        $roles = Configure::read('RolesCapabilities.Roles');
        if (empty($roles)) {
            $this->warn("No roles configured for importing.  Nothing to do.");

            return true;
        }

        /**
         * @var \RolesCapabilities\Model\Table\RolesTable $table
         */
        $table = TableRegistry::get('RolesCapabilities.Roles');

        foreach ($roles as $role) {
            if (empty($role['name'])) {
                $this->warn("Skipping role without a name.");
                continue;
            }

            if ($table->exists(['name' => $role['name']])) {
                $this->warn("Role [" . $role['name'] . "] already exists. Skipping.");
                continue;
            }

            $this->info("Role [" . $role['name'] . "] does not exist. Creating.");
            $entity = $table->newEntity();
            $entity = $table->patchEntity($entity, $role);

            $group = $this->getGroupByRoleName($entity->get('name'));
            if (empty($group)) {
                $this->abort("Failed to fetch group [" . $entity->get('name') . "]");
            }

            $result = $table->save($entity);
            if (!$result) {
                $this->err("Errors: \n" . implode("\n", $this->getImportErrors($entity)));
                $this->abort("Failed to create role [" . $entity->get('name') . "]");
            }

            $msg = 'Role [' . $entity->get('name') . '] imported';
            // associate imported role with matching group
            if ($table->Groups->link($entity, [$group])) {
                $msg .= ' and associated with group [' . $group->get('name') . ']';
            }
            $msg .= ' successfully';

            $this->info($msg);
        }

        $this->success('System roles imported successfully');
    }
543888
def exec(self, record):
		
		watchdog_cls = self.watchdog_class()
		watchdog = watchdog_cls.create(record, self)
		watchdog.start()
		watchdog.start_event().wait(self.__watchdog_startup_timeout__)
		self.__running_registry.append(watchdog)
216380
public function run()
    {
        // roles
        $roles = [
            [ 
                'name'          => 'Administrators',
                'slug'          => 'admin',
                'description'   => 'Have all access to all areas',
                'special'       => 'all-access',
            ],

            [
                'name'          => 'Moderators',
                'slug'          => 'moderator',
                'description'   => 'Some admin area access',
                'special'       => null,
            ],

            [
                'name'          => 'General Users',
                'slug'          => 'user',
                'description'   => 'No admin access',
                'special'       => null,
            ],

            [
                'name'          => 'Banned',
                'slug'          => 'banned',
                'description'   => 'Have no access to any areas',
                'special'       => 'no-access',
            ]
        ];
        
        // insert roles
        DB::table('roles')->insert($roles);

        // is there a user
        $any = DB::table('users')->get();
        if ( empty($any) ) {
            DB::table('users')
                ->insert( [ 
                    'name' => 'admin',
                    'email' => 'admin@change.me',
                    'password' => bcrypt('password')
                ]
            );
        }

        //associate first user with admin role
        DB::table('role_user')->insert( ['role_id' => 1, 'user_id'=> 1] );

         // permissions
        $permissions = [
            [ 
                'name'          => 'Show Watchtower Dashboard',
                'slug'          => 'show.watchtower.index',
                'description'   => 'View the watchtower dashboard shortcuts page'
            ],

            [ 
                'name'          => 'Show user list',
                'slug'          => 'show.user.index',
                'description'   => 'Can show the user list on the index page'
            ],

            [ 
                'name'          => 'Create user',
                'slug'          => 'create.user',
                'description'   => 'Create a user'
            ],

            [ 
                'name'          => 'View user',
                'slug'          => 'show.user',
                'description'   => 'See an individual user info'
            ],

            [ 
                'name'          => 'Edit user',
                'slug'          => 'edit.user',
                'description'   => 'Edit an existing user'
            ],

            [ 
                'name'          => 'Destroy user',
                'slug'          => 'destroy.user',
                'description'   => 'Remove a user permanently'
            ],

            [ 
                'name'          => 'Synchronize users with roles',
                'slug'          => 'sync.user.roles',
                'description'   => 'Used for both the user matrix and user role pages.'
            ],

            [ 
                'name'          => 'User search',
                'slug'          => 'search.user',
                'description'   => 'Able to search users'
            ],

            [ 
                'name'          => 'Show role list',
                'slug'          => 'show.role.index',
                'description'   => 'Can show the role list on the index page'
            ],

            [ 
                'name'          => 'Create role',
                'slug'          => 'create.role',
                'description'   => 'Create a role'
            ],

            [ 
                'name'          => 'View role',
                'slug'          => 'show.role',
                'description'   => 'See an individual role info'
            ],

            [ 
                'name'          => 'Edit role',
                'slug'          => 'edit.role',
                'description'   => 'Edit an existing role'
            ],

            [ 
                'name'          => 'Destroy role',
                'slug'          => 'destroy.role',
                'description'   => 'Remove a role permanently'
            ],

            [ 
                'name'          => 'Synchronize roles with users',
                'slug'          => 'sync.role.users',
                'description'   => 'Syncs a role with multiple users.'
            ],

            [ 
                'name'          => 'Synchronize roles with permissions',
                'slug'          => 'sync.role.permissions',
                'description'   => 'Used for both the role matrix and role permissions pages.'
            ],

            [ 
                'name'          => 'role search',
                'slug'          => 'search.role',
                'description'   => 'Able to search roles'
            ],

            [ 
                'name'          => 'Show permission list',
                'slug'          => 'show.permission.index',
                'description'   => 'Can show the permission list on the index page'
            ],

            [ 
                'name'          => 'Create permission',
                'slug'          => 'create.permission',
                'description'   => 'Create a permission'
            ],

            [ 
                'name'          => 'View permission',
                'slug'          => 'show.permission',
                'description'   => 'See an individual permission info'
            ],

            [ 
                'name'          => 'Edit permission',
                'slug'          => 'edit.permission',
                'description'   => 'Edit an existing permission'
            ],

            [ 
                'name'          => 'Destroy permission',
                'slug'          => 'destroy.permission',
                'description'   => 'Remove a permission permanently'
            ],

            [ 
                'name'          => 'Synchronize permissions with roles',
                'slug'          => 'sync.permission.roles',
                'description'   => 'Syncs a permission with multiple roles.'
            ],

            [ 
                'name'          => 'permission search',
                'slug'          => 'search.permission',
                'description'   => 'Able to search permissions'
            ],
        ];

        //insert permissions    
        DB::table('permissions')->insert($permissions);
    }
936353
protected function job(): void
    {
        $titles = $this->retrieve([
            'corporation_id' => $this->getCorporationId(),
        ]);

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

        collect($titles)->each(function ($title) {

            CorporationTitle::firstOrNew([
                'corporation_id' => $this->getCorporationId(),
                'title_id'       => $title->title_id,
            ])->fill([
                'name' => $title->name ?? sprintf('Untitled %d', (int) sqrt($title->title_id - 1)),
            ])->save();

            collect($this->types)->each(function ($type) use ($title) {

                if (! property_exists($title, $type))
                    return;

                collect($title->{$type})->each(function ($name) use ($title, $type) {

                    CorporationTitleRole::firstOrCreate([
                        'corporation_id' => $this->getCorporationId(),
                        'title_id'       => $title->title_id,
                        'type'           => $type,
                        'role'           => $name,
                    ]);
                });

                CorporationTitleRole::where('corporation_id', $this->getCorporationId())
                    ->where('title_id', $title->title_id)
                    ->where('type', $type)
                    ->whereNotIn('role', collect($title->{$type})->flatten()->all())
                    ->delete();

            });

            $this->known_titles->push($title->title_id);

        });

        CorporationTitle::where('corporation_id', $this->getCorporationId())
            ->whereNotIn('title_id', $this->known_titles->flatten()->all())
            ->delete();
    }
652932
void setLeaderState(boolean isLeader)
    {
        m_isLeader = isLeader;
        // The leader doesn't truncate its own SP log; if promoted,
        // wipe out the SP portion of the existing log. This promotion
        // action always happens after repair is completed.
        if (m_isLeader) {
            if (!m_logSP.isEmpty()) {
                truncate(m_logSP.getLast().getHandle(), IS_SP);
            }
        }
    }
865479
@Override
	public void execute() {
		if (target instanceof WComponentGroup<?>) {
			for (WComponent component : ((WComponentGroup<WComponent>) target).getComponents()) {
				if (component instanceof SubordinateTarget) {
					applyAction((SubordinateTarget) component, value);
				}
			}
		} else {
			// Leaf.
			applyAction(target, value);
		}

	}
207721
def run(self):
        '''
        
        '''
        self._update_opts()
        cmd = self.opts['fun']

        veri = None
        ret = None
        try:
            if cmd in ('accept', 'reject', 'delete'):
                ret = self._run_cmd('name_match')
                if not isinstance(ret, dict):
                    salt.output.display_output(ret, 'key', opts=self.opts)
                    return ret
                ret = self._filter_ret(cmd, ret)
                if not ret:
                    self._print_no_match(cmd, self.opts['match'])
                    return
                print('The following keys are going to be {0}ed:'.format(cmd.rstrip('e')))
                salt.output.display_output(ret, 'key', opts=self.opts)

                if not self.opts.get('yes', False):
                    try:
                        if cmd.startswith('delete'):
                            veri = input('Proceed? [N/y] ')
                            if not veri:
                                veri = 'n'
                        else:
                            veri = input('Proceed? [n/Y] ')
                            if not veri:
                                veri = 'y'
                    except KeyboardInterrupt:
                        raise SystemExit("\nExiting on CTRL-c")
                # accept/reject/delete the same keys we're printed to the user
                self.opts['match_dict'] = ret
                self.opts.pop('match', None)
                list_ret = ret

            if veri is None or veri.lower().startswith('y'):
                ret = self._run_cmd(cmd)
                if cmd in ('accept', 'reject', 'delete'):
                    if cmd == 'delete':
                        ret = list_ret
                    for minions in ret.values():
                        for minion in minions:
                            print('Key for minion {0} {1}ed.'.format(minion,
                                                                     cmd.rstrip('e')))
                elif isinstance(ret, dict):
                    salt.output.display_output(ret, 'key', opts=self.opts)
                else:
                    salt.output.display_output({'return': ret}, 'key', opts=self.opts)
        except salt.exceptions.SaltException as exc:
            ret = '{0}'.format(exc)
            if not self.opts.get('quiet', False):
                salt.output.display_output(ret, 'nested', self.opts)
        return ret
320996
def bootstrap_executive_office(self, election):
        
        division = election.race.office.jurisdiction.division
        content_type = ContentType.objects.get_for_model(election.race.office)
        PageContent.objects.get_or_create(
            content_type=content_type,
            object_id=election.race.office.pk,
            election_day=election.election_day,
            division=division,
        )
        if division.level == self.NATIONAL_LEVEL:
            self.bootstrap_executive_office_states(election)
        else:
            # Create state governor page type
            page_type, created = PageType.objects.get_or_create(
                model_type=ContentType.objects.get(
                    app_label="government", model="office"
                ),
                election_day=election.election_day,
                division_level=self.STATE_LEVEL,
            )
            PageContent.objects.get_or_create(
                content_type=ContentType.objects.get_for_model(page_type),
                object_id=page_type.pk,
                election_day=election.election_day,
            )

            generic_state_page_type, created = PageType.objects.get_or_create(
                model_type=ContentType.objects.get(
                    app_label="geography", model="division"
                ),
                election_day=election.election_day,
                division_level=DivisionLevel.objects.get(
                    name=DivisionLevel.STATE
                ),
            )
            PageContent.objects.get_or_create(
                content_type=ContentType.objects.get_for_model(
                    generic_state_page_type
                ),
                object_id=generic_state_page_type.pk,
                election_day=election.election_day,
            )

            PageContent.objects.get_or_create(
                content_type=ContentType.objects.get_for_model(division),
                object_id=division.pk,
                election_day=election.election_day,
                special_election=False,
            )
84741
protected function job(): void
    {
        while (true) {

            $customs_offices = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

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

            collect($customs_offices)->each(function ($customs_office) {

                CorporationCustomsOffice::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'office_id'      => $customs_office->office_id,
                ])->fill([
                    'system_id'                   => $customs_office->system_id,
                    'reinforce_exit_start'        => $customs_office->reinforce_exit_start,
                    'reinforce_exit_end'          => $customs_office->reinforce_exit_end,
                    'corporation_tax_rate'        => $customs_office->corporation_tax_rate ?? null,
                    'allow_alliance_access'       => $customs_office->allow_alliance_access,
                    'alliance_tax_rate'           => $customs_office->alliance_tax_rate ?? null,
                    'allow_access_with_standings' => $customs_office->allow_access_with_standings,
                    'standing_level'              => $customs_office->standing_level ?? null,
                    'excellent_standing_tax_rate' => $customs_office->excellent_standing_tax_rate ?? null,
                    'good_standing_tax_rate'      => $customs_office->good_standing_tax_rate ?? null,
                    'neutral_standing_tax_rate'   => $customs_office->neutral_standing_tax_rate ?? null,
                    'bad_standing_tax_rate'       => $customs_office->bad_standing_tax_rate ?? null,
                    'terrible_standing_tax_rate'  => $customs_office->terrible_standing_tax_rate ?? null,
                ])->save();

                $this->known_structures->push($customs_office->office_id);

            });

            if (! $this->nextPage($customs_offices->pages))
                break;
        }

        // Cleanup customs offices that were not in the response.
        CorporationCustomsOffice::where('corporation_id', $this->getCorporationId())
            ->whereNotIn('office_id', $this->known_structures->flatten()->all())
            ->delete();
    }
996293
def handle(self, **options):
        
        self.flushdb = options.get('flushdb')
        self._pre_tasks()
        self._create_users()
        self._create_badges()
        self._create_awards()
549758
function setAccountQuorum (commandOptions, { accountId, quorum }) {
  return command(
    commandOptions,
    txHelper.addCommand(
      txHelper.emptyTransaction(),
      'setAccountQuorum',
      {
        accountId,
        quorum
      }
    )
  )
}
674
protected function job(): void
    {
        CorporationDivision::where('corporation_id', $this->getCorporationId())->get()
            ->each(function ($division) {

                // retrieve last known entry for the current division and active corporation
                $last_known_entry = CorporationWalletJournal::where('corporation_id', $this->getCorporationId())
                                                            ->where('division', $division->division)
                                                            ->orderBy('date', 'desc')
                                                            ->first();

                $this->last_known_entry_id = is_null($last_known_entry) ? 0 : $last_known_entry->id;

                // Perform a journal walk backwards to get all of the
                // entries as far back as possible. When the response from
                // ESI is empty, we can assume we have everything.
                while (true) {

                    $journal = $this->retrieve([
                        'corporation_id' => $this->getCorporationId(),
                        'division'       => $division->division,
                    ]);

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

                    $entries = collect($journal);

                    // If we have no more entries, break the loop.
                    if ($entries->count() === 0)
                        break;

                    $entries->chunk(1000)->each(function ($chunk) use ($division) {

                        // if we've reached the last known entry - abort the process
                        if ($this->at_last_entry)
                            return false;

                        // if we have reached the last known entry, exclude all entries which are lower or equal to the
                        // last known entry and flag the reached status.
                        if ($chunk->where('id', $this->last_known_entry_id)->isNotEmpty()) {
                            $chunk = $chunk->where('id', '>', $this->last_known_entry_id);

                            $this->at_last_entry = true;
                        }

                        $records = $chunk->map(function ($entry, $key) use ($division) {

                            return [
                                'corporation_id'  => $this->getCorporationId(),
                                'division'        => $division->division,
                                'id'              => $entry->id,
                                'date'            => carbon($entry->date),
                                'ref_type'        => $entry->ref_type,
                                'first_party_id'  => $entry->first_party_id ?? null,
                                'second_party_id' => $entry->second_party_id ?? null,
                                'amount'          => $entry->amount ?? null,
                                'balance'         => $entry->balance ?? null,
                                'reason'          => $entry->reason ?? null,
                                'tax_receiver_id' => $entry->tax_receiver_id ?? null,
                                'tax'             => $entry->tax ?? null,
                                // introduced in v4
                                'description'     => $entry->description,
                                'context_id'      => $entry->context_id ?? null,
                                'context_id_type' => $entry->context_id_type ?? null,
                                'created_at'      => carbon(),
                                'updated_at'      => carbon(),
                            ];
                        });

                        CorporationWalletJournal::insertIgnore($records->toArray());
                    });

                    // in case the last known entry has been reached or we non longer have pages, terminate the job.
                    if (! $this->nextPage($journal->pages) || $this->at_last_entry)
                        break;
                }

                // Reset the page for the next wallet division.
                $this->page = 1;

                // Reset the last known entry for the next wallet division.
                $this->last_known_entry_id = 0;

                // Reset the last known entry status for the next wallet division.
                $this->at_last_entry = false;
            });
    }
1258
def execute(self):
        
        r = self._s.execute()
        r._faceted_search = self
        return r
1111201
protected function job(): void
    {
        $customs_offices = CorporationCustomsOffice::where('corporation_id', $this->getCorporationId())->get();

        collect($customs_offices)->chunk(1000)->each(function ($chunk) {

            $this->request_body = $chunk->map(function ($office) {

                return $office->office_id;
            })->flatten()->toArray();

            $locations = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

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

            collect($locations)->each(function ($location) use ($chunk) {

                $nearest_celestial = $this->find_nearest_celestial(
                    $chunk->firstWhere('office_id', $location->item_id)->system_id,
                    $location->position->x,
                    $location->position->y,
                    $location->position->z
                );

                CorporationCustomsOffice::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'office_id'      => $location->item_id,
                ])->fill([
                    'x'           => $location->position->x,
                    'y'           => $location->position->y,
                    'z'           => $location->position->z,
                    'location_id' => $nearest_celestial['map_id'],
                ])->save();

            });

        });
    }
430282
function (cmd, cb) {
  var internalCmd = internalCommand(cmd);
  if (internalCmd) {
    return cb(['info', internalCmd]);
  }
  $document.trigger('console:run', cmd);
}
1301719
def execute(self):
        
        if not hasattr(self, 'riskinputs'):  # in the reportwriter
            return
        res = Starmap.apply(
            self.core_task.__func__,
            (self.riskinputs, self.riskmodel, self.param, self.monitor()),
            concurrent_tasks=self.oqparam.concurrent_tasks or 1,
            weight=get_weight
        ).reduce(self.combine)
        return res