check if pg_rewind executable is there and that pg_controldata indicates
            we have either wal_log_hints or checksums turned on
323356
def can_rewind(self):
        
        # low-hanging fruit: check if pg_rewind configuration is there
        if not self.config.get('use_pg_rewind'):
            return False

        cmd = [self._pgcommand('pg_rewind'), '--help']
        try:
            ret = subprocess.call(cmd, stdout=open(os.devnull, 'w'), stderr=subprocess.STDOUT)
            if ret != 0:  # pg_rewind is not there, close up the shop and go home
                return False
        except OSError:
            return False
        return self.configuration_allows_rewind(self.controldata())
824994
def checksums(self, install):
        
        check_md5(pkg_checksum(install, self.repo), self.tmp_path + install)
844150
def getXlogStatus(self):
        
        inRecovery = None
        if self.checkVersion('9.0'):
            inRecovery = self._simpleQuery("SELECT pg_is_in_recovery();")
        cur = self._conn.cursor()
        if inRecovery:
            cols = ['pg_last_xlog_receive_location()', 
                    'pg_last_xlog_replay_location()',]
            headers = ['xlog_receive_location',
                       'xlog_replay_location',]
            if self.checkVersion('9.1'):
                cols.extend(['pg_last_xact_replay_timestamp()',
                             'pg_is_xlog_replay_paused()',])
                headers.extend(['xact_replay_timestamp', 
                                'xlog_replay_paused',])
            cur.execute("""SELECT %s;""" % ','.join(cols))
            headers = ('xlog_receive_location', 'xlog_replay_location')
        else:
            cur.execute("""SELECT
                pg_current_xlog_location(), 
                pg_xlogfile_name(pg_current_xlog_location());""")
            headers = ('xlog_location', 'xlog_filename')
        row = cur.fetchone()
        info_dict = dict(zip(headers, row))
        if inRecovery is not None:
            info_dict['in_recovery'] = inRecovery
        return info_dict
1024374
def reload(self):
        """"""
        status = self.get_status()
        if status != 'running':
            raise ClusterError('cannot reload: cluster is not running')

        process = subprocess.run(
            [self._pg_ctl, 'reload', '-D', self._data_dir],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        stderr = process.stderr

        if process.returncode != 0:
            raise ClusterError(
                'pg_ctl stop exited with status {:d}: {}'.format(
                    process.returncode, stderr.decode()))
762431
def valid_replay(info, ping):
  """"""
  if (info.HasField("error") or
      info.base_build != ping.base_build or  # different game version
      info.game_duration_loops < 1000 or
      len(info.player_info) != 2):
    # Probably corrupt, or just not interesting.
    return False
  for p in info.player_info:
    if p.player_apm < 10 or p.player_mmr < 1000:
      # Low APM = player just standing around.
      # Low MMR = corrupt replay or player who is weak.
      return False
  return True
772044
def precheck():
    
    binaries = ['make']
    for bin in binaries:
        if not which(bin):
            msg = 'Dependency fail -- Unable to locate rquired binary: '
            stdout_message('%s: %s' % (msg, ACCENT + bin + RESET))
            return False
        elif not root():
            return False
    return True
716057
function _checkRootCA () {
  var caKeyFilePath = path.join(certDir, 'ca.key');
  var caCrtFilePath = path.join(certDir, 'ca.crt');

  var keysDir = path.join(__dirname, '..', 'keys');

  if (!fs.existsSync(caKeyFilePath) || !fs.existsSync(caCrtFilePath)) {
    log.debug('CA files do not exist');
    log.debug('Copy CA files');
    fse.copySync(path.join(keysDir, 'ca.key'), caKeyFilePath);
    fse.copySync(path.join(keysDir, 'ca.crt'), caCrtFilePath);
  }
}
1183030
def check(self, *args):
        

        ok = True
        msg = ''
        g = get_root(self).globals
        dtype = g.observe.rtype()
        expert = g.cpars['expert_level'] > 0

        if dtype == 'bias' or dtype == 'flat' or dtype == 'dark':
            self.pi.configure(state='disable')
            self.prog_ob.configure(state='disable')
            self.target.disable()
        else:
            if expert:
                self.pi.configure(state='normal')
                self.prog_ob.configure(state='normal')
                self.prog_ob.enable()
            else:
                self.prog_ob.configure(state='disable')
                self.pi.configure(state='disable')
                self.prog_ob.disable()
            self.target.enable()

        if g.cpars['require_run_params']:
            if self.target.ok():
                self.target.entry.config(bg=g.COL['main'])
            else:
                self.target.entry.config(bg=g.COL['error'])
                ok = False
                msg += 'Target name field cannot be blank\n'

            if dtype == 'data caution' or \
               dtype == 'data' or dtype == 'technical':

                if self.prog_ob.ok():
                    self.prog_ob.config(bg=g.COL['main'])
                else:
                    self.prog_ob.config(bg=g.COL['error'])
                    ok = False
                    msg += 'Programme or OB ID field cannot be blank\n'

                if self.pi.ok():
                    self.pi.config(bg=g.COL['main'])
                else:
                    self.pi.config(bg=g.COL['error'])
                    ok = False
                    msg += 'Principal Investigator field cannot be blank\n'

            if self.observers.ok():
                self.observers.config(bg=g.COL['main'])
            else:
                self.observers.config(bg=g.COL['error'])
                ok = False
                msg += 'Observers field cannot be blank'
        return (ok, msg)
517085
def OnApprove(self, event):
        """"""

        if not self.main_window.safe_mode:
            return

        msg = _(u"You are going to approve and trust a file that\n"
                u"you have not created yourself.\n"
                u"After proceeding, the file is executed.\n \n"
                u"It may harm your system as any program can.\n"
                u"Please check all cells thoroughly before\nproceeding.\n \n"
                u"Proceed and sign this file as trusted?")

        short_msg = _("Security warning")

        if self.main_window.interfaces.get_warning_choice(msg, short_msg):
            # Leave safe mode
            self.main_window.grid.actions.leave_safe_mode()

            # Display safe mode end in status bar

            statustext = _("Safe mode deactivated.")
            post_command_event(self.main_window, self.main_window.StatusBarMsg,
                               text=statustext)
1361115
function checkSpawnSuccess(command) {
  // spawn expects a command and a separate array containing each argument
  const parts = command.split(' ');
  return spawnSync(parts[0], parts.slice(1), {stdio: 'inherit'}).status === 0;
}
72967
def exec_pg_success(self, cmd):
        
        result = self.inner().exec_run(cmd, user='postgres')
        assert result.exit_code == 0, result.output.decode('utf-8')
        return result
405811
function checkGraphvizInstalled(config) {
	if (config.graphVizPath) {
		const cmd = path.join(config.graphVizPath, 'gvpr -V');
		return exec(cmd)
			.catch(() => {
				throw new Error('Could not execute ' + cmd);
			});
	}

	return exec('gvpr -V')
		.catch((error) => {
			throw new Error('Graphviz could not be found. Ensure that "gvpr" is in your $PATH.\n' + error);
		});
}
622598
def is_installed(prog):
    """"""
    with open(os.devnull, 'w') as devnull:
        try:
            if os.name == 'nt':
                retcode = subprocess.call(['where', prog], stdout=devnull)
            else:
                retcode = subprocess.call(['which', prog], stdout=devnull)
        except OSError as e:
            # If where or which doesn't exist, a "ENOENT" error will occur (The
            # FileNotFoundError subclass on Python 3).
            if e.errno != errno.ENOENT:
                raise
            retcode = 1

    return retcode == 0
329647
def is_executable(command):
    """"""

    paths = os.environ.get("PATH", "").split(os.path.pathsep)
    candidates = [command] + [os.path.join(p, command) for p in paths]
    return any(os.access(path, os.X_OK) for path in candidates)
448673
def _mysqld_process_checkpoint():
    '''
    '''
    try:
        subprocess.check_output("pgrep mysqld", shell=True)
    except Exception:
        logger.warning(
            'Your mysql server is offline, fake2db will try to launch it now!',
            extra=extra_information)
        # close_fds = True argument is the flag that is responsible
        # for Popen to launch the process completely independent
        subprocess.Popen("mysqld", close_fds=True, shell=True)
        time.sleep(3)
650959
def _check_pub_data(self, pub_data, listen=True):
        '''
        
        '''
        if pub_data == '':
            # Failed to authenticate, this could be a bunch of things
            raise EauthAuthenticationError(
                'Failed to authenticate! This is most likely because this '
                'user is not permitted to execute commands, but there is a '
                'small possibility that a disk error occurred (check '
                'disk/inode usage).'
            )

        # Failed to connect to the master and send the pub
        if 'error' in pub_data:
            print(pub_data['error'])
            log.debug('_check_pub_data() error: %s', pub_data['error'])
            return {}
        elif 'jid' not in pub_data:
            return {}
        if pub_data['jid'] == '0':
            print('Failed to connect to the Master, '
                  'is the Salt Master running?')
            return {}

        # If we order masters (via a syndic), don't short circuit if no minions
        # are found
        if not self.opts.get('order_masters'):
            # Check for no minions
            if not pub_data['minions']:
                print('No minions matched the target. '
                      'No command was sent, no jid was assigned.')
                return {}

        # don't install event subscription listeners when the request is asynchronous
        # and doesn't care. this is important as it will create event leaks otherwise
        if not listen:
            return pub_data

        if self.opts.get('order_masters'):
            self.event.subscribe('syndic/.*/{0}'.format(pub_data['jid']), 'regex')

        self.event.subscribe('salt/job/{0}'.format(pub_data['jid']))

        return pub_data
813798
def check (self):
        """"""
        if self.aggregate.config["trace"]:
            trace.trace_on()
        try:
            self.local_check()
        except (socket.error, select.error):
            # on Unix, ctrl-c can raise
            # error: (4, 'Interrupted system call')
            etype, value = sys.exc_info()[:2]
            if etype == errno.EINTR:
                raise KeyboardInterrupt(value)
            else:
                raise