set permission bits if needed using python API os.chmod

        :return: None
438644
def _set_mode(self):
        
        if self.mode is not None:
            logger.debug("changing permission bits of %s to %s", self.path, oct(self.mode))
            os.chmod(self.path, self.mode)
646561
private void visit_OP_SET_PERMISSIONS() throws IOException {
    visitTxId();
    v.visitStringUTF8( EditsElement.PATH);
    v.visitShort(      EditsElement.FS_PERMISSIONS);
  }
551162
def cli(env, identifier, enable, permission, from_user):
    """"""
    mgr = SoftLayer.UserManager(env.client)
    user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
    result = False
    if from_user:
        from_user_id = helpers.resolve_id(mgr.resolve_ids, from_user, 'username')
        result = mgr.permissions_from_user(user_id, from_user_id)
    elif enable:
        result = mgr.add_permissions(user_id, permission)
    else:
        result = mgr.remove_permissions(user_id, permission)

    if result:
        click.secho("Permissions updated successfully: %s" % ", ".join(permission), fg='green')
    else:
        click.secho("Failed to update permissions: %s" % ", ".join(permission), fg='red')
329717
def safeMkdir(p, permissions = permissions755):
	''''''
	try:
		os.mkdir(p)
	except OSError:
		pass
	os.chmod(p, permissions)
436152
def permission_required_or_403(perm, *args, **kwargs):
    
    kwargs['redirect_to_login'] = False
    return permission_required(perm, *args, **kwargs)
1304620
def require_x_permission(flag)
      if current_user && current_user_roles.any?{|ug| ug.admin?}
        # if role is admin, then ok
      elsif current_user && current_model_permissions.any?{|cp| cp.permitted?(flag)}
        # if enough permission, then ok
      else
        respond_to_permission_error
      end
    end
273589
def create_permission(self):
        """"""
        return Permission(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
10670
def chmod(path, mode):
    """"""
    import os, stat
    st = os.stat(path)
    return os.chmod(path, mode)
597231
def permissions(self, addr, permissions=None):
        

        if self.state.solver.symbolic(addr):
            raise SimMemoryError(
                "page permissions cannot currently be looked up for symbolic addresses")

        if isinstance(addr, claripy.ast.bv.BV):
            addr = self.state.solver.eval(addr)

        page_num = addr // self._page_size

        try:
            page = self._get_page(page_num)
        except KeyError:
            raise SimMemoryError("page does not exist at given address")

        # Set permissions for the page
        if permissions is not None:
            if isinstance(permissions, (int, long)):
                permissions = claripy.BVV(permissions, 3)

            if not isinstance(permissions, claripy.ast.bv.BV):
                raise SimMemoryError(
                    "Unknown permissions argument type of {0}.".format(
                        type(permissions)))

            page.permissions = permissions

        return page.permissions
1362535
def set_permissions(vhost, user, conf='.*', write='.*', read='.*', runas=None):
    '''
    
    '''
    if runas is None and not salt.utils.platform.is_windows():
        runas = salt.utils.user.get_user()
    res = __salt__['cmd.run_all'](
        [RABBITMQCTL, 'set_permissions', '-p',
         vhost, user, conf, write, read],
        reset_system_locale=False,
        runas=runas,
        python_shell=False)
    msg = 'Permissions Set'
    return _format_response(res, msg)
48290
def _apply_unix_permissions(self, request: Request, response: Response):
        '''
        '''
        files = yield from self._fetch_parent_path(request)

        if not files:
            return

        filename = posixpath.basename(request.file_path)

        for file_entry in files:
            if file_entry.name == filename and file_entry.perm:
                _logger.debug(
                    'Set chmod {} o{:o}.',
                    response.body.name, file_entry.perm
                )
                os.chmod(response.body.name, file_entry.perm)
1040459
def get_permission_required(cls):
        
        if cls.permission_required is None:
            raise ImproperlyConfigured(
                "{0} is missing the permission_required attribute. "
                "Define {0}.permission_required, or override "
                "{0}.get_permission_required().".format(cls.__name__)
            )
        if isinstance(cls.permission_required, six.string_types):
            if cls.permission_required != "":
                perms = (cls.permission_required,)
            else:
                perms = ()
        else:
            perms = cls.permission_required

        return perms
242759
def chmod(self, mode):
        
        if isinstance(mode, str):
            mask = _multi_permission_mask(mode)
            mode = mask(self.stat().st_mode)
        os.chmod(self, mode)
        return self
1351427
def revoke_access(self):
        """"""
        reading = PERMISSIONS['user']['execute'] + PERMISSIONS['group']['execute'] + PERMISSIONS['other']['execute']
        os.chmod(self.file_path, reading)
116683
def _create_permissions(**kwargs):
    
    from django.contrib.contenttypes.models import ContentType

    object_tools.autodiscover()
    tools = object_tools.tools._registry

    # This will hold the permissions we're looking for as
    # (content_type, (codename, name))
    searched_perms = list()
    # The codenames and ctypes that should exist.
    ctypes = set()
    for model, tools in tools.items():
        ctype = ContentType.objects.get_for_model(model)
        ctypes.add(ctype)
        for perm in _get_all_permissions(model._meta, tools):
            searched_perms.append((ctype, perm))

    # Find all the Permissions that have a context_type for a model we're
    # looking for.  We don't need to check for codenames since we already have
    # a list of the ones we're going to create.
    all_perms = set(auth_app.Permission.objects.filter(
        content_type__in=ctypes,
    ).values_list(
        "content_type", "codename"
    ))

    for ctype, (codename, name) in searched_perms:
        # If the permissions exists, move on.
        if (ctype.pk, codename) in all_perms:
            continue
        p = auth_app.Permission.objects.create(
            codename=codename,
            name=name,
            content_type=ctype
        )
        if kwargs.get("verbosity", 2) >= 2:
            print("Adding permission '%s'" % p)
1313246
def add_permission(self, perm):
        
        self.Permissions(permission=perm)
        PermissionCache.flush()
        self.save()
871762
def assign_contributor_permissions(obj, contributor=None):
    """"""
    for permission in get_all_perms(obj):
        assign_perm(permission, contributor if contributor else obj.contributor, obj)