Python stat 模块,S_IXUSR 实例代码

电脑杂谈  发布时间:2019-08-14 20:01:38  来源:网络整理

python s ixusr_python s.sendmail_python %s

我们从Python开源项目中python s ixusrpython s ixusr,提取了以上50个代码实例,用来证明怎么使用stat.S_IXUSR。

系统页面索引列表stat.S_IXUSR

项目:binaryanalysis 作者:armijnhemel 文件:createmanifests.py |项目代码 |文档代码

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

项目:zippy 作者:securesystemslab 文件:test_import.py |项目代码 |文档代码

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.
        with temp_umask(0o022):
            sys.path.insert(0, os.curdir)
            try:
                fname = TESTFN + os.extsep + "py"
                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))
                fn = imp.cache_from_source(fname)
                unlink(fn)
                __import__(TESTFN)
                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:
                del sys.path[0]
                remove_files(TESTFN)
                unload(TESTFN)

项目:indy-node 作者:hyperledger 文件:1_2_188_to_1_2_189.py |项目代码 |文档代码

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)

项目:indy-node 作者:hyperledger 文件:1_2_233_to_1_2_234.py |项目代码 |文档代码

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)

项目:graynet 作者:raamana 文件:generate_hpc_jobs.py |项目代码 |文档代码

def make_job(subject_id_list, freesurfer_dir,
             base_feature, weight_method, num_bins, edge_range,
             atlas, fwhm, out_proc_dir, job_dir, job_name, num_procs):
    "Creates graynet job for running on HPC"
    str_list_weight_method = ' '.join(weight_method)
    job_file = pjoin(job_dir, '{}.graynet.job'.format(job_name))
    job_log  = pjoin(job_dir, '{}.graynet.log'.format(job_name))
    if pexists(job_file):
        os.remove(job_file)
    with open(job_file, 'w') as jf:
        jf.write('#!/bin/bash\n')
        jf.write(specify_hpc_resources(mem, queue, num_procs, job_dir, job_log))
        jf.write(make_cli_call(cli_name,realpath(subject_id_list), base_feature, realpath(freesurfer_dir),
            str_list_weight_method, num_bins, edge_range, atlas, fwhm, realpath(out_proc_dir), num_procs))
    st = os.stat(job_file)
    os.chmod(job_file, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
    return job_file

项目:graynet 作者:raamana 文件:multi_generate_hpc_jobs.py |项目代码 |文档代码

def make_job(subject_id_list, freesurfer_dir,
             base_feature, weight_method, num_bins, edge_range, summary_stat,
             atlas, fwhm, out_proc_dir, job_dir, job_name, num_procs):
    "Creates graynet job for running on HPC"
    str_list_weight_method = ' '.join(weight_method)
    job_file = pjoin(job_dir, '{}.{}.job'.format(job_name, job_type))
    job_log = pjoin(job_dir, '{}.{}.log'.format(job_name, job_type))
    if pexists(job_file):
        os.remove(job_file)
    with open(job_file, 'w') as jf:
        jf.write('#!/bin/bash\n')
        jf.write(specify_hpc_resources(mem, queue, num_procs, job_dir, job_log))
        jf.write(make_cli_call(cli_name, realpath(subject_id_list), base_feature, realpath(freesurfer_dir),
                               str_list_weight_method, num_bins, edge_range, summary_stat, atlas, fwhm, realpath(out_proc_dir),
                               num_procs))
    st = os.stat(job_file)
    os.chmod(job_file, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
    return job_file


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/shumachanpin/article-119245-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...