simple check to see they are running a verify or run with an actual directory
481067
function checkSubmissionDir (mode, callback) {
  var exercise = this

  exercise.submission = this.args[0] // submission first arg obviously


  function failBadPath () {
    exercise.emit('fail', 'Submitted a readable directory path (please supply a path to your solution)')
    callback(null, false)
  }

  if (!exercise.submission)
    return failBadPath()

  fs.stat(exercise.submission, function (err, stat) {
    if (err)
      return failBadPath()

    if (!stat.isDirectory())
      return failBadPath()

    callback(null, true)
  })
}
1073260
def check_file_exists(self, remote_cmd="dir home"):
        """"""
        if self.direction == "put":
            remote_out = self.ssh_ctl_chan.send_command_expect(remote_cmd)
            search_string = r"Directory contents .*{}".format(self.dest_file)
            return bool(re.search(search_string, remote_out, flags=re.DOTALL))
        elif self.direction == "get":
            return os.path.exists(self.dest_file)
178330
def verify_path(self, courseid, taskid, path, new_path=False):
        
        task_fs = self.task_factory.get_task_fs(courseid, taskid)
        # verify that the dir exists
        if not task_fs.exists():
            return None

        # all path given to this part of the application must start with a "/", let's remove it
        if not path.startswith("/"):
            return None
        path = path[1:len(path)]

        if ".." in path:
            return None

        if task_fs.exists(path) == new_path:
            return None

        # do not allow touching the task.* file
        if os.path.splitext(path)[0] == "task" and os.path.splitext(path)[1][1:] in \
                self.task_factory.get_available_task_file_extensions():
            return None

        # do not allow hidden dir/files
        if path != ".":
            for i in path.split(os.path.sep):
                if i.startswith("."):
                    return None
        return path
792153
def isdir(self, path):
        
        try:
            self.remote_context.check_output(["test", "-d", path])
        except subprocess.CalledProcessError as e:
            if e.returncode == 1:
                return False
            else:
                raise
        return True
17491
def verify(opts):
    
    resources = _load(opts.resources, opts.output_dir)
    if opts.all:
        opts.resource_names = ALL
    invalid = _invalid(resources, opts.resource_names)
    if not invalid:
        if not opts.quiet:
            print("All resources successfully downloaded")
        return 0
    else:
        if not opts.quiet:
            print("Invalid or missing resources: {}".format(', '.join(invalid)))
        return 1
540108
def assert_script_in_current_directory():
  """"""

  script = sys.argv[0]
  assert os.path.abspath(os.path.dirname(script)) == os.path.abspath(
    '.'), f"Change into directory of script {script} and run again."
962303
def ensure_legal(self):
    """"""
    # Do our best to provide complete feedback, it's easy to imagine the frustration of flipping between error states.
    if self._results_dir:
      errors = ''
      if not os.path.islink(self._results_dir):
        errors += '\nThe results_dir is no longer a symlink:\n\t* {}'.format(self._results_dir)
      if not os.path.isdir(self._current_results_dir):
        errors += '\nThe current_results_dir directory was not found\n\t* {}'.format(self._current_results_dir)
      if errors:
        raise self.IllegalResultsDir(
          '\nThe results_dirs state should not be manually cleaned or recreated by tasks.\n{}'.format(errors)
        )
    return True
551496
def specific_path_check(path, opt):
    """"""
    if opt.exclude:
        if path in opt.exclude:
            return False

    if opt.include:
        if path not in opt.include:
            return False

    return True
1353049
function _ensureExists(dir, callback) {
    dir = path.resolve(dir); // make full path
    
    path.exists(dir, function(exists) {
        if (!exists) {
            // ensure that the parent dir exists
            _ensureExists(path.dirname(dir), function(err) {
                if (err) {
                    callback(err);
                    return;
                }
                
                // make the dir
                log.log('Creating ' + dir);
                fs.mkdir(dir, function(err) {
                    if (err) {
                        callback(err);
                        return;
                    }
                    
                    callback(null);
                });
            });
        }
        else {
            callback(null);
        }
    });
}
511097
public function verified() : bool
    {
        if ($this->verified !== null) {
            return $this->verified;
        }

        return $this->verified = is_dir($this->getPath());
    }
1219937
def is_valid_dir(path):
    '''  '''
    return os.path.exists(path) and os.path.isdir(path)
1222656
def _isRepositoryReady(self):
        """"""
        return os.path.exists(os.path.join(self._absWorkdir(), '.hg'))
1330749
def check_running(self):
        '''
        
        '''

        if self.check_pidfile():
            pid = self.get_pidfile()
            if not salt.utils.platform.is_windows():
                if self.check_pidfile() and self.is_daemonized(pid) and os.getppid() != pid:
                    return True
            else:
                # We have no os.getppid() on Windows. Use salt.utils.win_functions.get_parent_pid
                if self.check_pidfile() and self.is_daemonized(pid) and salt.utils.win_functions.get_parent_pid() != pid:
                    return True
        return False
1682
def main(overwrite):
    
    logger.debug("Checking existence of '%s'.", CONF_PATH)
    if not os.path.exists(CONF_PATH):
        logger.debug("Directory %s not found! Panicking..", CONF_PATH)
        raise UserWarning(
            "Can't find '%s' - it looks like ProFTPD is not installed!" % (
                CONF_PATH,
            )
        )

    # check existence of proftpd.conf
    logger.debug("Checking existence of configuration file '%s'.", CONF_FILE)
    if not os.path.exists(CONF_FILE):
        logger.debug("Configuration file not found, creating..")
        _write_conf_file()
    else:
        logger.debug("Found.")

        if not os.path.exists(CONF_FILE + "_"):
            logger.debug(
                "Backing up the configuration file '%s' -> '%s'.",
                CONF_FILE,
                CONF_FILE + "_"
            )
            shutil.copyfile(CONF_FILE, CONF_FILE + "_")
        else:
            logger.debug(
                "Backup already exists. '%s' will be overwritten.",
                CONF_FILE
            )
    if overwrite:
        logger.debug("--update switch not found, overwriting conf file")
        _write_conf_file()

    logger.debug("Checking existence of the '%s' file.", MODULES_FILE)
    if not os.path.exists(MODULES_FILE) and _is_deb_system():
        with open(MODULES_FILE, "w") as f:
            f.write(DEFAULT_MODULES_CONF)
            logger.debug("Modules file not found. Created '%s'.", MODULES_FILE)

    # create data directory, where the user informations will be stored
    logger.debug("Checking existence of user's directory '%s'.", DATA_PATH)
    if not os.path.exists(DATA_PATH):
        logger.debug("Directory '%s' not found, creating..", DATA_PATH)

        os.makedirs(DATA_PATH, 0777)

        logger.debug("Done. '%s' created.", DATA_PATH)

    # create user files if they doesn't exists
    logger.debug("Checking existence of passwd file '%s'.", LOGIN_FILE)
    if not os.path.exists(LOGIN_FILE):
        logger.debug("passwd file not found, creating..")

        open(LOGIN_FILE, "a").close()

        logger.debug("Done. '%s' created.")

    logger.debug("Setting permissions..")
    os.chown(LOGIN_FILE, get_ftp_uid(), -1)
    os.chmod(LOGIN_FILE, 0400)

    # load values from protpd conf file
    logger.debug("Switching and adding options..")
    data = ""
    with open(CONF_FILE) as f:
        data = f.read()

    # set path to passwd file
    logger.debug("\tAuthUserFile")
    data = add_or_update(
        data,
        "AuthUserFile",
        LOGIN_FILE
    )
    logger.debug("\tRequireValidShell")
    data = add_or_update(data, "RequireValidShell", "off")
    logger.debug("\tDefaultRoot")
    data = add_or_update(data, "DefaultRoot", "~")

    # http://www.proftpd.org/docs/modules/mod_log.html
    logger.debug("\tLogFormat")
    data = add_or_update(data, "LogFormat", 'paths "%f, %u, %m, %{%s}t"')
    logger.debug("\tExtendedLog")
    data = add_or_update(
        data,
        "ExtendedLog",
        LOG_FILE + " WRITE paths"
    )

    if not _is_deb_system():
        logger.debug("Detected non debian based linux. Aplying SUSE changes.")
        data = comment(data, "IdentLookups off")
        data = comment(data, "Include /etc/proftpd/modules.conf")
        data = add_or_update(data, "User", "ftp")

    # save changed file
    logger.debug("Saving into config file..")
    with open(CONF_FILE, "w") as f:
        f.write(data)
        logger.debug("Done.")

    logger.debug("Sending proftpd signal to reload configuration..")
    reload_configuration()
    logger.debug("Done.")
    logger.info("All set.")
1196629
def check_files(self, paths=None):
        """"""
        if paths is None:
            paths = self.paths
        report = self.options.report
        runner = self.runner
        report.start()
        try:
            for path in paths:
                if os.path.isdir(path):
                    self.input_dir(path)
                elif not self.excluded(path):
                    runner(path)
        except KeyboardInterrupt:
            print('... stopped')
        report.stop()
        return report
748617
def assure_directory_exists(path, is_file=False):
    """"""
    if is_file:
        path = osp.dirname(path)
    # END handle file
    if not osp.isdir(path):
        os.makedirs(path)
        return True
    return False
287195
def check_file_exists(self, remote_cmd=""):
        """"""
        if self.direction == "put":
            if not remote_cmd:
                remote_cmd = "dir {}{}".format(self.file_system, self.dest_file)
            remote_out = self.ssh_ctl_chan.send_command_expect(remote_cmd)
            search_string = r"{}.*Usage for".format(self.dest_file)
            if "No such file or directory" in remote_out:
                return False
            elif re.search(search_string, remote_out, flags=re.DOTALL):
                return True
            else:
                raise ValueError("Unexpected output from check_file_exists")
        elif self.direction == "get":
            return os.path.exists(self.dest_file)