If the server is non local raise an error if
    the path is outside project directories

    Raise a 403 in case of error
485536
def check_path_allowed(path):
    

    config = Config.instance().get_section_config("Server")

    project_directory = get_default_project_directory()
    if len(os.path.commonprefix([project_directory, path])) == len(project_directory):
        return

    if "local" in config and config.getboolean("local") is False:
        raise aiohttp.web.HTTPForbidden(text="The path is not allowed")
65163
function start(root, distPath) {
  return new Promise((resolve, reject) => {

    const dist = path.resolve(process.cwd(), distPath || 'dist');

    logger.info('Creating web server');
    app.use(cors());

    logger.info(`Exposing static directory: ${dist}`);
    app.use(express.static(dist));
    if (root) {
      logger.info(`Mapping server requests from ${root} to ${dist}`);
      app.use(root, express.static(dist));
    }

    const options = {
      cert: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.crt')),
      key: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.key'))
    };

    server = https.createServer(options, app);
    server.on('error', reject);

    logger.info('Requesting open port...');
    portfinder
      .getPortPromise()
      .then(port => {
        logger.info(`Open port found: ${port}`);
        logger.info('Starting web server...');
        server.listen(port, 'localhost', () => {
          logger.info('Web server running.');
          resolve(port);
        });
      })
      .catch(reject);
  });
}
1113404
def raise_os_error(_errno, path=None):
    

    msg = "%s: '%s'" % (strerror(_errno), path) if path else strerror(_errno)
    raise OSError(_errno, msg)
548982
def link(src, path):
    '''
    
    '''
    src = os.path.expanduser(src)

    if not os.path.isabs(src):
        raise SaltInvocationError('File path must be absolute.')

    try:
        os.link(src, path)
        return True
    except (OSError, IOError):
        raise CommandExecutionError('Could not create \'{0}\''.format(path))
    return False
1117213
function resolveLocal(success, fail, request, options) {
    var path = localPath + request.substring(8);
    resolve(success, fail, path, window.PERSISTENT, UNSANDBOXED, options);
}
438725
def ensure_private_dir_exists(app_name):
    
    path = private_dir_path(app_name)
    if not os.path.exists(path):
        os.makedirs(path)
    else:
        if not os.path.isdir(path):
            raise PrivateDirConflictError
659018
function(path, root) {
  return new P(function(resolve, reject) {
    if(isRelativePath(path)) {
      path = isUrl(root) ?
        url.resolve(root, path) :
        join(root, path);
    }

    if(isUrl(path)) {
      request.get(path, {encoding: null}, function(err, response, body) {
        if(err) { return reject(err); }
        return response.statusCode === 200 ?
          resolve(body) :
          reject(new Error('Got status ' + response.statusCode + ' fetching ' + path));
      });
    } else {
      fs.readFile(path, function(err, body) {
        return err ?
          reject(err) :
          resolve(body);
      });
    }
  });
}
732488
function parseError(error) {
  // If this file is at the root of your project
  var pathRegexp = new RegExp(__dirname, 'g');
  var display = '';
  if (error.code) { display += 'Error code: ' + error.code + '\n\n' };
  if (error.stack) { display += error.stack.replace(pathRegexp, ''); }
  if (!display) { display = error.toString(); }
  return display;
}
604
def raise_not_found(self, environ, msg):
        
        raise NotFound(response=self.rewriterapp._error_response(environ, msg))
17416
function localRequire(path) {
    var resolved = localRequire.resolve(path);
    return require(resolved, parent, path);
  }
1006383
function (path, callback) {
    var mkdir = child_process.spawn('mkdir', ['-p', path]);
    mkdir.on('error', function (err) {
        callback(err);
        callback = function(){};
    });
    mkdir.on('exit', function (code) {
        if (code === 0) callback();
        else callback(new Error('mkdir exited with code: ' + code));
    });
}
726728
def inside_project?
      project_found = false
      cwd = Pathname(Dir.pwd)
      home_directory = File.expand_path('~')
      cwd.ascend do |current_path|
        project_found = File.file?("#{current_path.to_s}/.bebox")
        self.project_root = current_path.to_s if project_found
        break if project_found || (current_path.to_s == home_directory)
      end
      project_found
    end
522701
def catch_all(path):
    
    return (dict(error='Invalid URL: /{}'.format(path),
                 links=dict(root='{}{}'.format(request.url_root, PREFIX[1:]))),
            HTTPStatus.NOT_FOUND)
1158972
function(callback) {
          ftpout.raw.pwd(function(err) {
            if (err && err.code === 530) {
              grunt.fatal('bad username or password');
            }
            callback(err);
          });
        }
783797
function PathNotFoundError(path, sympath){
  superError.call(
    this,
    'PathNotFoundError',
    util.format('Path was not found in the tree: %s', sympath)
  );

  this.arrayPath = path;
  this.sympath = sympath;
}
1030166
def _fix_path():
  """"""
  import os
  import sys
  all_paths = os.environ.get('PYTHONPATH').split(os.pathsep)
  for path_dir in all_paths:
    dev_appserver_path = os.path.join(path_dir, 'dev_appserver.py')
    if os.path.exists(dev_appserver_path):
      logging.debug('Found appengine SDK on path!')
      google_appengine = os.path.dirname(os.path.realpath(dev_appserver_path))
      sys.path.append(google_appengine)
      # Use the next import will fix up sys.path even further to bring in
      # any dependent lib directories that the SDK needs.
      dev_appserver = __import__('dev_appserver')
      sys.path.extend(dev_appserver.EXTRA_PATHS)
      return
458214
function handleEnoentError(opts, err) {
  console.log(chalk.red(
    '\nError: ' + err.name + '. "' + err.path + '" does not exist.\n'
  ));
}