当前位置: 首页>>代码示例>>Python>>正文


Python stat.S_IXGRP属性代码示例

本文整理汇总了Python中stat.S_IXGRP属性的典型用法代码示例。如果您正苦于以下问题:Python stat.S_IXGRP属性的具体用法?Python stat.S_IXGRP怎么用?Python stat.S_IXGRP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在stat的用法示例。


在下文中一共展示了stat.S_IXGRP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: gunzip_file

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def gunzip_file(gz_path, new_path):
  """Unzips from gz_path into new_path.

  Args:
    gz_path: path to the zipped file.
    new_path: path to where the file will be unzipped.
  """
  if tf.gfile.Exists(new_path):
    tf.logging.info("File %s already exists, skipping unpacking" % new_path)
    return
  tf.logging.info("Unpacking %s to %s" % (gz_path, new_path))
  # We may be unpacking into a newly created directory, add write mode.
  mode = stat.S_IRWXU or stat.S_IXGRP or stat.S_IRGRP or stat.S_IROTH
  os.chmod(os.path.dirname(new_path), mode)
  with gzip.open(gz_path, "rb") as gz_file:
    with tf.gfile.GFile(new_path, mode="wb") as new_file:
      for line in gz_file:
        new_file.write(line) 
开发者ID:akzaidi,项目名称:fine-lm,代码行数:20,代码来源:generator_utils.py

示例2: replace_gmsh

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def replace_gmsh():
    fn_gmsh = path2bin('gmsh')
    fn_gmsh_tmp = path2bin('gmsh_tmp')
    # move
    shutil.move(fn_gmsh, fn_gmsh_tmp)
    # replace
    if sys.platform == 'win32':
        fn_script = fn_gmsh[:4] + '.cmd'
        with open(fn_script, 'w') as f:
            f.write('echo "GMSH"')
    else:
        with open(fn_gmsh, 'w') as f:
            f.write('#! /bin/bash -e\n')
            f.write(f'"echo" "$@"')
        os.chmod(
            fn_gmsh,
            os.stat(fn_gmsh).st_mode |
            stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
        )
    yield
    shutil.move(fn_gmsh_tmp, fn_gmsh) 
开发者ID:simnibs,项目名称:simnibs,代码行数:23,代码来源:examples.py

示例3: chmod

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def chmod(path):
    os.chmod(path,
             # user
             stat.S_IRUSR |  # read
             stat.S_IWUSR |  # write
             stat.S_IXUSR |  # execute

             # group
             stat.S_IRGRP |  # read
             stat.S_IWGRP |  # write
             stat.S_IXGRP |  # execute

             # other
             stat.S_IROTH |  # read
             # stat.S_IWOTH | # write
             stat.S_IXOTH  # execute
             ) 
开发者ID:AdamGagorik,项目名称:pydarkstar,代码行数:19,代码来源:makebin.py

示例4: test_execute_bit_not_copied

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def test_execute_bit_not_copied(self):
        # Issue 6070: under posix .pyc files got their execute bit set if
        # the .py file had the execute bit set, but they aren't executable.
        oldmask = os.umask(022)
        sys.path.insert(0, os.curdir)
        try:
            fname = TESTFN + os.extsep + "py"
            f = open(fname, 'w').close()
            os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
                             stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
            __import__(TESTFN)
            fn = fname + 'c'
            if not os.path.exists(fn):
                fn = fname + 'o'
                if not os.path.exists(fn):
                    self.fail("__import__ did not result in creation of "
                              "either a .pyc or .pyo file")
            s = os.stat(fn)
            self.assertEqual(stat.S_IMODE(s.st_mode),
                             stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
        finally:
            os.umask(oldmask)
            remove_files(TESTFN)
            unload(TESTFN)
            del sys.path[0] 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:test_import.py

示例5: close

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def close(self):
        error_context.context(
            "Creating unattended install CD image %s" % self.path)
        if os.path.exists(os.path.join(self.mount, 'isolinux')):
            # bootable cdrom
            f = open(os.path.join(self.mount, 'isolinux', 'isolinux.cfg'), 'w')
            f.write('default /isolinux/vmlinuz append initrd=/isolinux/'
                    'initrd.img %s\n' % self.extra_params)
            f.close()
            boot = '-b isolinux/isolinux.bin'
        else:
            # Not a bootable CDROM, using -kernel instead (eg.: arm64)
            boot = ''

        m_cmd = ('mkisofs -o %s %s -c isolinux/boot.cat -no-emul-boot '
                 '-boot-load-size 4 -boot-info-table -f -R -J -V -T %s'
                 % (self.path, boot, self.mount))
        process.run(m_cmd)
        os.chmod(self.path, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP |
                 stat.S_IROTH | stat.S_IXOTH)
        cleanup(self.mount)
        cleanup(self.source_cdrom)
        logging.debug("unattended install CD image %s successfully created",
                      self.path) 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:26,代码来源:utils_disk.py

示例6: get_tmp_dir

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def get_tmp_dir(public=True):
    """
    Get the most appropriate tmp dir location.

    :param public: If public for all users' access
    """
    persistent_dir = settings.get_value('vt.common', 'tmp_dir',
                                        default="")
    if persistent_dir != "":
        return persistent_dir
    tmp_dir = None
    # apparmor deny /tmp/* /var/tmp/* and cause failure across tests
    # it is better to handle here
    if distro.detect().name == 'Ubuntu':
        tmp_dir = "/var/lib/libvirt/images"
        if not utils_path.usable_rw_dir(tmp_dir):
            logging.warning("Unable to write in '/var/lib/libvirt/images' "
                            "on Ubuntu, apparmor might complain...")
            tmp_dir = None
    tmp_dir = data_dir.get_tmp_dir(basedir=tmp_dir)
    if public:
        tmp_dir_st = os.stat(tmp_dir)
        os.chmod(tmp_dir, tmp_dir_st.st_mode | stat.S_IXUSR |
                 stat.S_IXGRP | stat.S_IXOTH | stat.S_IRGRP | stat.S_IROTH)
    return tmp_dir 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:27,代码来源:data_dir.py

示例7: special_to_letter

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def special_to_letter(mode):
    l = ''

    ALL_R = (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
    ALL_W = (stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)

    if mode & stat.S_ISGID:
        l += 'G'
    if mode & stat.S_ISUID:
        l += 'U'
    if mode & stat.S_ISVTX:
        l += 'T'
    if mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH):
        l += 'E'
    if ( mode & ALL_R ) == ALL_R:
        l += 'R'
    if ( mode & ALL_W ) == ALL_W:
        l += 'W'

    return l 
开发者ID:turingsec,项目名称:marsnake,代码行数:22,代码来源:lib.py

示例8: set_own_perm

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def set_own_perm(usr, dir_list):
    uid = pwd.getpwnam(usr).pw_uid
    gid = grp.getgrnam(usr).gr_gid
    perm_mask_rw = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP
    perm_mask_rwx = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP

    for cdir in dir_list:
        os.chown(cdir, uid, gid)
        os.chmod(cdir, perm_mask_rwx)
        for croot, sub_dirs, cfiles in os.walk(cdir):
            for fs_name in sub_dirs:
                os.chown(os.path.join(croot, fs_name), uid, gid)
                os.chmod(os.path.join(croot, fs_name), perm_mask_rwx)
            for fs_name in cfiles:
                os.chown(os.path.join(croot, fs_name), uid, gid)
                os.chmod(os.path.join(croot, fs_name), perm_mask_rw) 
开发者ID:hyperledger,项目名称:indy-node,代码行数:18,代码来源:1_2_188_to_1_2_189.py

示例9: set_bad_file_permissions

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def set_bad_file_permissions(context):
    if 'chmod' in context.call_function_name:
        if context.call_args_count == 2:
            mode = context.get_call_arg_at_position(1)

            if (mode is not None and isinstance(mode, int) and
                    (mode & stat.S_IWOTH or mode & stat.S_IXGRP)):
                # world writable is an HIGH, group executable is a MEDIUM
                if mode & stat.S_IWOTH:
                    sev_level = bandit.HIGH
                else:
                    sev_level = bandit.MEDIUM

                filename = context.get_call_arg_at_position(0)
                if filename is None:
                    filename = 'NOT PARSED'
                return bandit.Issue(
                    severity=sev_level,
                    confidence=bandit.HIGH,
                    text="Chmod setting a permissive mask %s on file (%s)." %
                    (oct(mode), filename)
                ) 
开发者ID:PyCQA,项目名称:bandit,代码行数:24,代码来源:general_bad_file_permissions.py

示例10: render_python_value

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def render_python_value(value):
		if not isinstance(value, int):
			return
		if value & stat.S_IFDIR:
			perm = 'd'
		else:
			perm = '-'
		perm += 'r' if value & stat.S_IRUSR else '-'
		perm += 'w' if value & stat.S_IWUSR else '-'
		if value & stat.S_ISUID:
			perm += 's' if value & stat.S_IXUSR else 'S'
		else:
			perm += 'x' if value & stat.S_IXUSR else '-'

		perm += 'r' if value & stat.S_IRGRP else '-'
		perm += 'w' if value & stat.S_IWGRP else '-'
		if value & stat.S_ISGID:
			perm += 's' if value & stat.S_IXGRP else 'S'
		else:
			perm += 'x' if value & stat.S_IXGRP else '-'

		perm += 'r' if value & stat.S_IROTH else '-'
		perm += 'w' if value & stat.S_IWOTH else '-'
		perm += 'x' if value & stat.S_IXOTH else '-'
		return perm 
开发者ID:rsmusllp,项目名称:king-phisher-plugins,代码行数:27,代码来源:directory.py

示例11: prepare_shutoff_daemon

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def prepare_shutoff_daemon(logger):
    if not os.path.exists(hooks_dir):
        os.makedirs(hooks_dir)
    if os.path.exists(hooks_file):
        os.remove(hooks_file)
    with open(hooks_file, 'w') as f:
        f.write(hooks_str)
    if not os.access(hooks_file, os.X_OK):
        st = os.stat(hooks_file)
        os.chmod(hooks_file, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)

    cmd = "service libvirtd restart"
    ret, out = utils.exec_cmd(cmd, shell=True)
    if ret:
        logger.error("Restart libvirtd failed: %s" % out)
        return 1
    return 0 
开发者ID:libvirt,项目名称:libvirt-test-API,代码行数:19,代码来源:connection_getAllDomainStats.py

示例12: _chmodplusx

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def _chmodplusx(d):
    if not os.path.exists(d):
        return
    if os.path.isdir(d):
        for item in os.listdir(d):
            p = os.path.join(d, item)
            if os.path.isdir(p):
                _chmodplusx(p)
            else:
                st = os.stat(p)
                os.chmod(p, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
    else:
        st = os.stat(d)
        os.chmod(d, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)


##################################       Hook the ugly python setup() call that can output gcc warnings.
# NOTE: yes, there is os.dup and file descriptor things. Deal with it (r).
# Keep a trace of the old stdout, because setup() is just toooooooooo verbose when succeed 
开发者ID:naparuba,项目名称:opsbro,代码行数:21,代码来源:setup-py2exe.py

示例13: validate

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def validate(taskKwargs, xlog=KodiLogger.log):

        tmpl = process_cmdline(taskKwargs['scriptfile'])
        found = False
        for tmp in tmpl:
            tmp = xbmc.translatePath(tmp)
            if xbmcvfs.exists(tmp) or os.path.exists(tmp) and found is False:
                try:
                    mode = os.stat(tmp).st_mode
                    mode |= stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
                    os.chmod(tmp, mode)
                except OSError:
                    if sysplat.startswith('win') is False:
                        xlog(msg=_('Failed to set execute bit on script: %s') % tmp)
                finally:
                    found = True
        return True 
开发者ID:KenV99,项目名称:script.service.kodi.callbacks,代码行数:19,代码来源:taskScript.py

示例14: save

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def save(self, path, serial='json'):
        '''
        Safely save keys with perms of 0400
        '''
        pre = self.for_json()

        if serial == 'msgpack':
            import msgpack
            packaged = msgpack.dumps(pre)
        elif serial == 'json':
            import json
            packaged = json.dumps(pre)

        perm_other = stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH
        perm_group = stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP

        cumask = os.umask(perm_other | perm_group)
        with open(path, 'w+') as fp_:
            fp_.write(packaged)
        os.umask(cumask) 
开发者ID:saltstack,项目名称:libnacl,代码行数:22,代码来源:base.py

示例15: symlink

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IXGRP [as 别名]
def symlink(self, id_p, name, target, ctx):
        log.debug('started with %d, %r, %r', id_p, name, target)

        if self.failsafe:
            raise FUSEError(errno.EPERM)

        mode = (stat.S_IFLNK | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
                stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP |
                stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH)

        # Unix semantics require the size of a symlink to be the length
        # of its target. Therefore, we create symlink directory entries
        # with this size. If the kernel ever learns to open and read
        # symlinks directly, it will read the corresponding number of \0
        # bytes.
        inode = self._create(id_p, name, mode, ctx, size=len(target))
        self.db.execute('INSERT INTO symlink_targets (inode, target) VALUES(?,?)',
                        (inode.id, target))
        self.open_inodes[inode.id] += 1
        return inode.entry_attributes() 
开发者ID:s3ql,项目名称:s3ql,代码行数:22,代码来源:fs.py


注:本文中的stat.S_IXGRP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。