當前位置: 首頁>>代碼示例>>Python>>正文


Python stat.S_IXUSR屬性代碼示例

本文整理匯總了Python中stat.S_IXUSR屬性的典型用法代碼示例。如果您正苦於以下問題:Python stat.S_IXUSR屬性的具體用法?Python stat.S_IXUSR怎麽用?Python stat.S_IXUSR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在stat的用法示例。


在下文中一共展示了stat.S_IXUSR屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ensure_session_manager_plugin

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [as 別名]
def ensure_session_manager_plugin():
    session_manager_dir = os.path.join(config.user_config_dir, "bin")
    PATH = os.environ.get("PATH", "") + ":" + session_manager_dir
    if shutil.which("session-manager-plugin", path=PATH):
        subprocess.check_call(["session-manager-plugin"], env=dict(os.environ, PATH=PATH))
    else:
        os.makedirs(session_manager_dir, exist_ok=True)
        target_path = os.path.join(session_manager_dir, "session-manager-plugin")
        if platform.system() == "Darwin":
            download_session_manager_plugin_macos(target_path=target_path)
        elif platform.linux_distribution()[0] == "Ubuntu":
            download_session_manager_plugin_linux(target_path=target_path)
        else:
            download_session_manager_plugin_linux(target_path=target_path, pkg_format="rpm")
        os.chmod(target_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
        subprocess.check_call(["session-manager-plugin"], env=dict(os.environ, PATH=PATH))
    return shutil.which("session-manager-plugin", path=PATH) 
開發者ID:kislyuk,項目名稱:aegea,代碼行數:19,代碼來源:ssm.py

示例2: replace_gmsh

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [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_IXUSR [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: cleanupdir

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [as 別名]
def cleanupdir(temporarydir):
	osgen = os.walk(temporarydir)
	try:
		while True:
			i = osgen.next()
			## make sure all directories can be accessed
			for d in i[1]:
				if not os.path.islink(os.path.join(i[0], d)):
					os.chmod(os.path.join(i[0], d), stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR)
			for p in i[2]:
				try:
					if not os.path.islink(os.path.join(i[0], p)):
						os.chmod(os.path.join(i[0], p), stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR)
				except Exception, e:
					#print e
					pass
	except StopIteration:
		pass
	try:
		shutil.rmtree(temporarydir)
	except:
		## nothing that can be done right now, so just give up
		pass 
開發者ID:armijnhemel,項目名稱:binaryanalysis,代碼行數:25,代碼來源:createmanifests.py

示例5: test_execute_bit_not_copied

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [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

示例6: get_tmp_dir

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [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: cmd_git_receive_pack

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [as 別名]
def cmd_git_receive_pack(app):
    """INTERNAL: Handle git pushes for an app"""

    app = sanitize_app_name(app)
    hook_path = join(GIT_ROOT, app, 'hooks', 'post-receive')
    env = globals()
    env.update(locals())

    if not exists(hook_path):
        makedirs(dirname(hook_path))
        # Initialize the repository with a hook to this script
        call("git init --quiet --bare " + app, cwd=GIT_ROOT, shell=True)
        with open(hook_path, 'w') as h:
            h.write("""#!/usr/bin/env bash
set -e; set -o pipefail;
cat | PIKU_ROOT="{PIKU_ROOT:s}" {PIKU_SCRIPT:s} git-hook {app:s}""".format(**env))
        # Make the hook executable by our user
        chmod(hook_path, stat(hook_path).st_mode | S_IXUSR)
    # Handle the actual receive. We'll be called with 'git-hook' after it happens
    call('git-shell -c "{}" '.format(argv[1] + " '{}'".format(app)), cwd=GIT_ROOT, shell=True) 
開發者ID:piku,項目名稱:piku,代碼行數:22,代碼來源:piku.py

示例8: write_batch_script

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [as 別名]
def write_batch_script(self, n):
        """Instantiate and write the batch script to the work_dir."""
        self.n = n
        # first priority is batch_template if set
        if self.batch_template_file and not self.batch_template:
            # second priority is batch_template_file
            with open(self.batch_template_file) as f:
                self.batch_template = f.read()
        if not self.batch_template:
            # third (last) priority is default_template
            self.batch_template = self.default_template
            # add jobarray or queue lines to user-specified template
            # note that this is *only* when user did not specify a template.
            self._insert_queue_in_script()
            self._insert_job_array_in_script()
        script_as_string = self.formatter.format(self.batch_template, **self.context)
        self.log.debug('Writing batch script: %s', self.batch_file)
        with open(self.batch_file, 'w') as f:
            f.write(script_as_string)
        os.chmod(self.batch_file, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:22,代碼來源:launcher.py

示例9: special_to_letter

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [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

示例10: testGetRemotePathNoArchive

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [as 別名]
def testGetRemotePathNoArchive(self, cs_get_mock):
    def _GetIfHashChangedMock(cs_path, download_path, bucket, file_hash):
      del cs_path, bucket, file_hash
      if not os.path.exists(download_path):
        self.fs.CreateFile(download_path, contents='1010001010101010110101')
    cs_get_mock.side_effect = _GetIfHashChangedMock
    # All of the needed information is given, and the downloaded path exists
    # after calling cloud storage.
    self.assertEqual(
        os.path.abspath(self.download_path),
        self.cs_info.GetRemotePath())
    self.assertTrue(os.stat(self.download_path).st_mode & stat.S_IXUSR)

    # All of the needed information is given, but the downloaded path doesn't
    # exists after calling cloud storage.
    self.fs.RemoveObject(self.download_path)
    cs_get_mock.side_effect = [True]  # pylint: disable=redefined-variable-type
    self.assertRaises(
        exceptions.FileNotFoundError, self.cs_info.GetRemotePath) 
開發者ID:FSecureLABS,項目名稱:Jandroid,代碼行數:21,代碼來源:cloud_storage_info_unittest.py

示例11: SetUnzippedDirPermissions

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [as 別名]
def SetUnzippedDirPermissions(archive, unzipped_dir):
  """Set the file permissions in an unzipped archive.

     Designed to be called right after extractall() was called on |archive|.
     Noop on Win. Otherwise sets the executable bit on files where needed.

     Args:
         archive: A zipfile.ZipFile object opened for reading.
         unzipped_dir: A path to a directory containing the unzipped contents
             of |archive|.
  """
  if sys.platform.startswith('win'):
    # Windows doesn't have an executable bit, so don't mess with the ACLs.
    return
  for zip_info in archive.infolist():
    archive_acls = GetModeFromZipInfo(zip_info)
    if archive_acls & stat.S_IXUSR:
      # Only preserve owner execurable permissions.
      unzipped_path = os.path.abspath(
          os.path.join(unzipped_dir, zip_info.filename))
      mode = GetModeFromPath(unzipped_path)
      os.chmod(unzipped_path, mode | stat.S_IXUSR) 
開發者ID:FSecureLABS,項目名稱:Jandroid,代碼行數:24,代碼來源:dependency_manager_util.py

示例12: testStatDirectory_filePermissions

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [as 別名]
def testStatDirectory_filePermissions(self):
    should_have = (
      ('some_file', stat.S_IWUSR),  # Owner can write.
      ('tmp', stat.S_IXOTH),  # Others can execute.
      ('tmp', stat.S_ISVTX),  # Has sticky bit.
      ('my_cmd', stat.S_ISGID),  # Has set-group-ID bit.
      ('silly', stat.S_ISUID),  # Has set UID bit.
    )
    should_not_have = (
      ('some_file', stat.S_IWOTH),  # Others can't write.
      ('block_dev', stat.S_IRGRP),  # Group can't read.
      ('silly', stat.S_IXUSR),  # Owner can't execute.
    )
    entries = self.getStatEntries()
    for filename, bit in should_have:
      self.assertTrue(entries[filename]['st_mode'] & bit)
    for filename, bit in should_not_have:
      self.assertFalse(entries[filename]['st_mode'] & bit) 
開發者ID:FSecureLABS,項目名稱:Jandroid,代碼行數:20,代碼來源:device_utils_test.py

示例13: get_massdns_path

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [as 別名]
def get_massdns_path(massdns_dir):
    path = setting.brute_massdns_path
    if path:
        return path
    system = platform.system().lower()
    machine = platform.machine().lower()
    name = f'massdns_{system}_{machine}'
    if system == 'windows':
        name = name + '.exe'
        if machine == 'amd64':
            massdns_dir = massdns_dir.joinpath('windows', 'x64')
        else:
            massdns_dir = massdns_dir.joinpath('windows', 'x84')
    path = massdns_dir.joinpath(name)
    path.chmod(S_IXUSR)
    if not path.exists():
        logger.log('FATAL', 'There is no massdns for this platform or architecture')
        logger.log('INFOR', 'Please try to compile massdns yourself and specify the path in the configuration')
        exit(0)
    return path 
開發者ID:shmilylty,項目名稱:OneForAll,代碼行數:22,代碼來源:utils.py

示例14: test_no_read_directory

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [as 別名]
def test_no_read_directory(self):
        # Issue #16730
        tempdir = tempfile.TemporaryDirectory()
        original_mode = os.stat(tempdir.name).st_mode
        def cleanup(tempdir):
            """Cleanup function for the temporary directory.

            Since we muck with the permissions, we want to set them back to
            their original values to make sure the directory can be properly
            cleaned up.

            """
            os.chmod(tempdir.name, original_mode)
            # If this is not explicitly called then the __del__ method is used,
            # but since already mucking around might as well explicitly clean
            # up.
            tempdir.__exit__(None, None, None)
        self.addCleanup(cleanup, tempdir)
        os.chmod(tempdir.name, stat.S_IWUSR | stat.S_IXUSR)
        finder = self.get_finder(tempdir.name)
        found = self._find(finder, 'doesnotexist')
        self.assertEqual(found, self.NOT_FOUND) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:24,代碼來源:test_finder.py

示例15: set_own_perm

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IXUSR [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


注:本文中的stat.S_IXUSR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。