Check if the user has permissions to read from the given path.

    Args:
      gs_path: the GCS path to check if user is permitted to read.
    Raises:
      Exception if user has no permissions to read.
961674
def verify_permitted_to_read(gs_path):
    
    # TODO(qimingj): Storage APIs need to be modified to allow absence of project
    #                or credential on Objects. When that happens we can move the function
    #                to Objects class.
    from . import _bucket
    bucket, prefix = _bucket.parse_name(gs_path)
    credentials = None
    if google.datalab.Context._is_signed_in():
      credentials = google.datalab.Context.default().credentials
    args = {
        'maxResults': Api._MAX_RESULTS,
        'projection': 'noAcl'
    }
    if prefix is not None:
      args['prefix'] = prefix
    url = Api._ENDPOINT + (Api._OBJECT_PATH % (bucket, ''))
    try:
      google.datalab.utils.Http.request(url, args=args, credentials=credentials)
    except google.datalab.utils.RequestException as e:
      if e.status == 401:
        raise Exception('Not permitted to read from specified path. '
                        'Please sign in and make sure you have read access.')
      raise e
1360705
def is_readable(path):
    '''
    
    '''
    return os.access(os.path.abspath(path), os.R_OK)
1351173
protected function accessPathAccessFileManager($path)
    {
        $role_id = $this->getUser('role_id');
        $settings = $this->module->getSettings('file_manager');

        if (empty($settings['access'][$role_id])) {
            return true;
        }

        foreach ($settings['access'][$role_id] as $pattern) {
            if (gplcart_path_match($path, $pattern)) {
                return true;
            }
        }

        return false;
    }
1251741
def check_path(path):
    
    if path is None or path == b'' or path.startswith(b'/'):
        raise ValueError("illegal path '%s'" % path)

    if (
        (sys.version_info[0] >= 3 and not isinstance(path, bytes)) and
        (sys.version_info[0] == 2 and not isinstance(path, str))
    ):
        raise TypeError("illegale type for path '%r'" % path)

    return path
1044110
def has_role(self, role_s):
        
        if self.authorized:
            return self.security_manager.has_role(self.identifiers, role_s)
        msg = 'Cannot check permission when identifiers aren\'t set!'
        raise ValueError(msg)
1319371
def check_path(path, create=False):
    
    if not os.path.exists(path):
        if create:
            os.makedirs(path)
            return os.path.exists(path)
        else:
            return False

    return True
750893
def is_role(path):
    
    seems_legit = False
    for folder in c.ANSIBLE_FOLDERS:
        if os.path.exists(os.path.join(path, folder)):
            seems_legit = True

    return seems_legit
828195
def chmod(cls, path, permission_text):
        

        try:
            check_file_existence(path)
        except FileNotFoundError:
            _, e, _ = sys.exc_info()  # for python 2.5 compatibility
            logger.debug(e)
            return False

        logger.debug("chmod %s %s" % (path, permission_text))

        os.chmod(path, parseLsPermissionText(permission_text))
1079722
def check_path(file_path):
    '''
        
    '''
    directory = os.path.dirname(file_path)
    if directory != '':
        if not os.path.exists(directory):
            os.makedirs(directory, 0o775)
1303245
public boolean checkAccess(String path, boolean readOnly) {
        final FileServiceMXBean fileService = getFileService();
        if (readOnly) {
            //we can read from both the read and write list
            return (FileServiceUtil.isPathContained(fileService.getReadList(), path) || FileServiceUtil.isPathContained(fileService.getWriteList(), path));
        } else {
            //we can write only to the write list
            return FileServiceUtil.isPathContained(fileService.getWriteList(), path);
        }
    }
1254266
def check_file_path(self, path):
        
        if os.path.exists(path) is not True:
            msg = "File Not Found {}".format(path)
            raise OSError(msg)
20872
public static function permission($path, $full = false)
    {
        if (self::exists($path) === false) {
            return false;
        }

        $perms = fileperms($path);

        if ($full !== true) {
            return substr(sprintf('%o', $perms), -4);
        }

        if (($perms & 0xC000) === 0xC000) {
            $info = 's';
        } elseif (($perms & 0xA000) === 0xA000) {
            $info = 'l';
        } elseif (($perms & 0x8000) === 0x8000) {
            $info = '-';
        } elseif (($perms & 0x6000) === 0x6000) {
            $info = 'b';
        } elseif (($perms & 0x4000) === 0x4000) {
            $info = 'd';
        } elseif (($perms & 0x2000) === 0x2000) {
            $info = 'c';
        } elseif (($perms & 0x1000) === 0x1000) {
            $info = 'p';
        } else {
            $info = 'u';
        }

        $info .= $perms & 0x0100 ? 'r' : '-';
        $info .= $perms & 0x0080 ? 'w' : '-';
        $info .= $perms & 0x0040 ?
                    ($perms & 0x0800 ? 's' : 'x') :
                        ($perms & 0x0800 ? 'S' : '-');

        $info .= $perms & 0x0020 ? 'r' : '-';
        $info .= $perms & 0x0010 ? 'w' : '-';
        $info .= $perms & 0x0008 ?
                    ($perms & 0x0400 ? 's' : 'x') :
                        ($perms & 0x0400 ? 'S' : '-');

        $info .= $perms & 0x0004 ? 'r' : '-';
        $info .= $perms & 0x0002 ? 'w' : '-';
        $info .= $perms & 0x0001 ?
                    ($perms & 0x0200 ? 't' : 'x') :
                        ($perms & 0x0200 ? 'T' : '-');

        return $info;

    }
146525
def _is_svc(svc_path):
    '''
    
    '''
    run_file = os.path.join(svc_path, 'run')
    if (os.path.exists(svc_path)
         and os.path.exists(run_file)
         and os.access(run_file, os.X_OK)):
        return True
    return False
424554
def has_permissions(self, object, group, operations):
        ''''''
        if self.is_superuser:
            return 1
        else:
            models = self.session.router
            # valid permissions
            query = models.permission.for_object(object, operation=operations)
            objects = models[models.role.permissions.model]
            return objects.filter(role=self.role.query(),
                                  permission=query).count()
154921
def is_readable(fpath):
    
    return os.path.isfile(fpath) and os.access(fpath, os.R_OK)
1931
def read(in_path):
    
    assert os.path.exists(in_path), "The following GRP file can't be found. in_path: {}".format(in_path)

    with open(in_path, "r") as f:
        lines = f.readlines()
        # need the second conditional to ignore comment lines
        grp = [line.strip() for line in lines if line and not re.match("^#", line)]

    return grp
550008
def check_permissions():
    
    if (
        not grp.getgrnam('docker').gr_gid in os.getgroups()
        and not os.geteuid() == 0
    ):
        exitStr = """
        User doesn't have permission to use docker.
        You can do either of the following,
        1. Add user to the 'docker' group (preferred)
        2. Run command as superuser using either 'sudo' or 'su -c'
        """
        exit(exitStr)