• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.write_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.write_file函数的典型用法代码示例。如果您正苦于以下问题:Python write_file函数的具体用法?Python write_file怎么用?Python write_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test

def test():
    action = util.parse_action(sys.argv[1])
    if not action == ALLOW:
        quit(1)
    util.install_trap()
    f = SyscallFilter(TRAP)
    # NOTE: additional syscalls required for python
    f.add_rule(ALLOW, "stat")
    f.add_rule(ALLOW, "fstat")
    f.add_rule(ALLOW, "open")
    f.add_rule(ALLOW, "openat")
    f.add_rule(ALLOW, "mmap")
    f.add_rule(ALLOW, "munmap")
    f.add_rule(ALLOW, "read")
    f.add_rule(ALLOW, "write")
    f.add_rule(ALLOW, "close")
    f.add_rule(ALLOW, "rt_sigaction")
    f.add_rule(ALLOW, "rt_sigreturn")
    f.add_rule(ALLOW, "exit_group")
    f.load()
    try:
        util.write_file("/dev/null")
    except OSError as ex:
        quit(ex.errno)
    quit(160)
开发者ID:Cellrox,项目名称:android_external_libseccomp,代码行数:25,代码来源:21-live-basic_allow.py


示例2: do_emf_carving

def do_emf_carving(volume, carveokdir, carvenokdir):
    deletedFiles, filekeys = carveEMFVolumeJournal(volume)

    print "Journal carving done, trying to extract deleted files"
    n = 0
    for name, vv in deletedFiles:
        for filekey in filekeys.get(vv.data.fileID, []):
            ff = EMFFile(volume,vv.data.dataFork, vv.data.fileID, filekey, deleted=True)
            data = ff.readAllBuffer()
            if isDecryptedCorrectly(data):
                write_file(carveokdir + "%s_%s" % (filekey.encode("hex")[:8],name.replace("/","_")),data)
                n += 1
            else:
                write_file(carvenokdir + "%s_%s" % (filekey.encode("hex")[:8],name.replace("/","_")),data)
        if not filekeys.has_key(vv.data.fileID):
            print "Missing file key for", name
        else:
            del filekeys[vv.data.fileID]
    
    print "Done, extracted %d files" % n

    if False:
        fks = set(reduce(lambda x,y: x+y, filekeys.values()))
        print "%d file keys left, try carving empty space (slow) ? CTRL-C to exit" % len(fks)
        raw_input()
        carveEMFemptySpace(volume, fks)
开发者ID:HaHa80,项目名称:iOS-DataProtection,代码行数:26,代码来源:journal.py


示例3: smrf

def smrf(afa_file, pdb_file, options, pmrf_path):
    edge_file, mrf_file = options.edge_file, options.mrf_file
    pmrf_exec = '%s/pmrf'%pmrf_path
    if not os.path.exists(pmrf_exec):
        print 'Cannot find the PMRF executable in the directory %s.'%(pmrf_path)
        sys.exit(1)

    ## Determine graph structure
    edge_list = build_edge(afa_file, pdb_file)
    write_file('\n'.join(['%s\t%s'%(i, j) for i, j in edge_list]), edge_file)
    message('MRF edge is determined.')

    ## Build MRF model
    cmd = '%s build %s --edge %s -o %s'%(pmrf_exec, afa_file, edge_file, mrf_file)
    subprocess.check_call(cmd.split())
    message('MRF model is parameterized.')

    ## Estimate positional coevolution
    cmd = '%s stat %s --mode pos'%(pmrf_exec, mrf_file)
    fp = sys.stdout if options.score_file1 == "stdout" else open(options.score_file1, 'w')
    p = subprocess.Popen(shlex.split(cmd), stdout=fp)
    p.wait()
    message('Positional coevolution scores are estimated.')

    ## Estimate pairwise coevolution
    if options.score_file2:
        cmd = '%s stat %s --mode pair'%(pmrf_exec, mrf_file)
        p = subprocess.Popen(shlex.split(cmd), stdout=open(options.score_file2, 'w'))
        p.wait()
        message('Pairwise coevolution scores are estimated.')
开发者ID:jeongchans,项目名称:smrf,代码行数:30,代码来源:smrf.py


示例4: bf_system

def bf_system():
    client = RamdiskToolClient()
    di = client.getDeviceInfos()
    devicedir = di["udid"]
    if os.getcwd().find(devicedir) == -1:
        try:
            os.mkdir(devicedir)
        except:
            pass
        os.chdir(devicedir)
    key835 = di.get("key835").decode("hex")
    
    systembag = client.getSystemKeyBag()
    kbkeys = systembag["KeyBagKeys"].data
    kb = Keybag.createWithDataSignBlob(kbkeys, key835)
    keybags = di.setdefault("keybags", {})
    kbuuid = kb.uuid.encode("hex")
    print "Keybag UUID :", kbuuid
    if True and keybags.has_key(kbuuid) and keybags[kbuuid].has_key("passcodeKey"):
        print "We've already seen this keybag"
        passcodeKey = keybags[kbuuid].get("passcodeKey").decode("hex")
        print kb.unlockWithPasscodeKey(passcodeKey)
        kb.printClassKeys()
    else:
        keybags[kbuuid] = {"KeyBagKeys": systembag["KeyBagKeys"]}
        di["KeyBagKeys"] = systembag["KeyBagKeys"]
        di.save()
        print "Enter passcode or leave blank for bruteforce:"
        z = raw_input()
        res = client.getPasscodeKey(systembag["KeyBagKeys"].data, z)
        if kb.unlockWithPasscodeKey(res.get("passcodeKey").decode("hex")):
            print "Passcode \"%s\" OK" % z
            di.update(res)
            keybags[kbuuid].update(res)
            di.save()
            keychain_blob = client.downloadFile("/mnt2/Keychains/keychain-2.db")
            write_file("keychain-2.db", keychain_blob)
            print "Downloaded keychain database, use keychain_tool.py to decrypt secrets"
            return
        if z != "":
            print "Wrong passcode, trying to bruteforce !"
        if checkPasscodeComplexity(client) == 0:
            print "Trying all 4-digits passcodes..."
            bf = client.bruteforceKeyBag(systembag["KeyBagKeys"].data)
            if bf:
                di.update(bf)
                keybags[kbuuid].update(bf)
            print bf
            print kb.unlockWithPasscodeKey(bf.get("passcodeKey").decode("hex"))
            kb.printClassKeys()
            di["classKeys"] = kb.getClearClassKeysDict()
            di.save()
        else:
            print "Complex passcode used !"
            return
        
    #keychain_blob =    client.downloadFile("/private/var/Keychains/keychain-2.db")
    keychain_blob = client.downloadFile("/mnt2/Keychains/keychain-2.db")
    write_file("keychain-2.db", keychain_blob)
    print "Downloaded keychain database, use keychain_tool.py to decrypt secrets"
开发者ID:AbhinavBansal,项目名称:iOS-DataProtection-ToolKit,代码行数:60,代码来源:demo_bruteforce.py


示例5: save_user_tags

def save_user_tags(path,top_tag=50):
  output = {}
  for u in db.get_user_list():
    person_tags = tags.generate_tag(u).user_tags(50)
    output[u] = person_tags
    print u
  util.write_file(output,path)
开发者ID:Tracywangsw,项目名称:recommender,代码行数:7,代码来源:user_profile.py


示例6: save_user_topics

def save_user_topics(path):
  output = []
  for u in db.get_user_list():
    person_topics = similarity.get_user_topics(u)
    output.append(person_topics)
    print u
  util.write_file(output,path)
开发者ID:Tracywangsw,项目名称:recommender,代码行数:7,代码来源:user_profile.py


示例7: create_profile

def create_profile(auth_info,**kwargs):
    if auth_info['code'] == 1:
        return json.dumps(auth_info)
    username = auth_info['username']
    try:
        data = request.get_json()['params']
	para = eval(str(data["partion"]))
	name = data['profile']
	filename = str(name)
	util.copy_file(filename)
	util.write_file(filename,para)
	util.replace_url(filename,str(data['url']))
	ret = profile_create(app.config['cobbler_url'],app.config['cobbler_user'],app.config['cobbler_password'],filename,str(data['distro']),'/var/lib/cobbler/kickstarts/%s'%filename)
	print "xiaoluoge"
	
	print ret
	if str(ret['result']) == "True": 
	    data = {"distro":str(data['distro']),"os":filename,"ks":'/var/lib/cobbler/kickstarts/%s'%filename} 
	    app.config['cursor'].execute_insert_sql('profile', data)
	    util.write_log('api').info(username, "create cobbler profile %s success"  %filename)
	else:
	    util.write_log('api').info(username, "create cobbler profile %s faile"  %  data['ip'])
        return json.dumps({'code':0,'result':'create %s success' % filename})
    except:
        util.write_log('api').error('create cobbler error:%s' % traceback.format_exc())
        return json.dumps({'code':1,'errmsg': 'create cobbler failed'})
开发者ID:gitsucce,项目名称:roncoo-cmdb,代码行数:26,代码来源:cobbler.py


示例8: download

def download(course, item):
    """
    Download announcement JSON.
    :param course: A Course object.
    :param item: {
        "close_time": 2147483647,
        "user_id": 1069689,
        "open_time": 1411654451,
        "title": "Coursera",
        "deleted": 0,
        "email_announcements": "email_sent",
        "section_id": "14",
        "order": "6",
        "item_type": "announcement",
        "__type": "announcement",
        "published": 1,
        "item_id": "39",
        "message": "Hello, everyone.",
        "uid": "announcement39",
        "id": 39,
        "icon": ""
    }
    :return: None.
    """
    path = '{}/announcement/{}.json'
    path = path.format(course.get_folder(), item['item_id'])

    util.make_folder(path, True)
    util.write_json(path, item)

    content = util.read_file(path)
    content = util.remove_coursera_bad_formats(content)

    util.write_file(path, content)
开发者ID:kq2,项目名称:Ricin,代码行数:34,代码来源:announcement.py


示例9: _write_attributes

 def _write_attributes(self, key, attrdict):
     for attr, new_value in sorted(attrdict.items()):
         attrfile = self._attr_file(key, attr)
         is_new_attribute = not os.path.exists(attrfile)
         util.write_file(attrfile, new_value)
         if is_new_attribute:
             self._hg(["add", attrfile])
开发者ID:Doddzy,项目名称:DAS-Fast-Downward,代码行数:7,代码来源:db.py


示例10: translate

def translate(ast, sig, child, device, outfile, translate_only, v):
  """ 
  Translate the AST to target system.
  """
  vmsg(v, 'Translating AST...')

  buf = io.StringIO()
  ext = None

  # Create a tranlator AST walker
  if device.system == SYSTEM_TYPE_XS1:
    walker = TranslateXS1(sig, child, buf)
  elif device.system == SYSTEM_TYPE_MPI:
    walker = TranslateMPI(sig, child, buf)

  walker.walk_program(ast)
  
  if translate_only:
    outfile = (outfile if outfile!=defs.DEFAULT_OUT_FILE else
        outfile+'.'+device.source_file_ext())
    util.write_file(outfile, buf.getvalue())
    vmsg(v, 'Produced file: '+outfile)
    raise SystemExit()

  return buf
开发者ID:xcore,项目名称:tool_sire,代码行数:25,代码来源:codegen.py


示例11: _write_pickle

    def _write_pickle(self, filename_stem, results, also_save_txt=True):
        self._progress("Pickling results dictionary.")
        file = open("%s.pkl" % filename_stem, 'wb')
	cPickle.dump(results, file, cPickle.HIGHEST_PROTOCOL)
	file.close()
        if also_save_txt:
            util.write_file("%s_dict.txt" % filename_stem, str(results))
开发者ID:Brian-Tomasik,项目名称:Combine-Data-Sources-for-Semantic-Music-Discovery,代码行数:7,代码来源:crossvalidate.py


示例12: load_config

def load_config():
    if not os.path.exists(CONFIG_FILE):
        write_file(DEFAULT_CONFIG, CONFIG_FILE)
        print 'Configuration file is created as %s'%(CONFIG_FILE)
        raise SystemExit
    cfg = ConfigParser.ConfigParser()
    cfg.read(CONFIG_FILE)
    return {'pmrf_path': os.path.expanduser(cfg.get('external', 'pmrf_path').split(';')[0])}
开发者ID:jeongchans,项目名称:smrf,代码行数:8,代码来源:smrf.py


示例13: save_certs_keys

 def save_certs_keys(self):
     certs, pkeys = self.get_certs()
     for c in certs:
         filename = (c)
         certs[c].save_pem(filename + ".crt")
     for k in pkeys:
         filename = (k)
         write_file(filename + ".key", pkeys[k])
开发者ID:WilhelmTell1337,项目名称:wilhelmtell-iosplayground,代码行数:8,代码来源:keychain.py


示例14: test

def test():
  movie_hot_list = movie_data_profile().hot_movies(rate=4.0,users=40)
  test_list = get_user_list()
  return_list = []
  for u in test_list:
    print u
    return_list.extend(user_alanysis(u))
  util.write_file(return_list,type='csv',path='user_info/whole_users_add_test.csv')
开发者ID:Tracywangsw,项目名称:recommender,代码行数:8,代码来源:db.py


示例15: writeCerts

    def writeCerts(self):
        if not self.certs:
            self.extractCertificates()

        for key, cert in self.certs.items():
            cert_data = cert.as_der()
            cert_sha1 = hashlib.sha1(cert_data).hexdigest()
            write_file("%s_%s.crt" % (key, cert_sha1), cert_data)
开发者ID:yzx65,项目名称:AppParser,代码行数:8,代码来源:img3.py


示例16: download_stats

    def download_stats(self):
        url = self.url + '/data/stats'
        path = self.info_folder + '/stats.html'
        util.download(url, path, self.cookie_file)

        content = util.read_file(path)
        pattern = r'<h1.*?</table>'
        content = re.search(pattern, content, re.DOTALL).group(0)
        util.write_file(path, content)
开发者ID:kq2,项目名称:Ricin,代码行数:9,代码来源:course.py


示例17: key

 def key(self, rowid, filename=""):
     for row in self.get_keys():
         if row["rowid"] == rowid:
             blob =  RSA_KEY_DER_to_PEM(row["data"])
             if filename:
                 write_file(filename, blob)
             #k = M2Crypto.RSA.load_key_string(blob)
             print blob
             return
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:9,代码来源:keychain.py


示例18: cert

 def cert(self, rowid, filename=""):
     for row in self.get_cert():
         if row["rowid"] == rowid:
             blob = CERT_DER_to_PEM(row["data"])
             if filename:
                 write_file(filename, blob)
             cert = M2Crypto.X509.load_cert_der_string(row["data"])
             print cert.as_text()
             return
开发者ID:AbhinavBansal,项目名称:iOS-DataProtection-ToolKit,代码行数:9,代码来源:keychain.py


示例19: cmd_mv

    def cmd_mv(self, src_pn, dst_pn):
        if not self.check_sanity():
            dbg.err("it's not a metasync repo.")
            return False
        src_pn = os.path.abspath(src_pn)
        dst_pn = os.path.abspath(dst_pn)

        #TODO: check src_pn exists
        beg = time.time()
        try:
            dirname = os.path.dirname(src_pn)
            dirblob = self.blobstore.load_dir(dirname, False, dirty=True)
            if(dirblob is None):
                dbg.err("%s does not exist" % src_pn)
                return False
        except NotTrackedException as e:
            dbg.err(str(e))
            return False

        fname = os.path.basename(src_pn)
        if(not fname in dirblob): 
            dbg.err("%s does not exist" % pn)
            return False
        fblob = dirblob[fname]
        dirblob.rm(fname)

        dst_dirname = os.path.dirname(dst_pn)
        if(dirname != dst_dirname):
            dirblob = self.blobstore.load_dir(dirname, True, dirty=True)
            assert dirblob is not None

        dst_fname = os.path.basename(dst_pn)
        dirblob.add(dst_fname, fblob, dirty=False)

        root = self.get_root_blob()
        root.store()
        newblobs = self.blobstore.get_added_blobs()

        util.write_file(self.get_head(), root.hv)
        self.append_history(root.hv)

        end = time.time()
        dbg.time("local write: %f" % (end-beg))

        # push new blobs remotely
        self.bstore_sync(newblobs)
        self._put_all(self.get_head(), self.get_remote_path(self.get_head_name()))

        end = time.time()
        dbg.time("remote write: %f" % (end-beg))

        # move the file
        shutil.move(src_pn, dst_pn)
        self._join()

        return True 
开发者ID:UWNetworksLab,项目名称:metasync,代码行数:56,代码来源:metasyncAPI.py


示例20: save_certs_keys

 def save_certs_keys(self):
     certs, pkeys = self.get_certs()
     for c in certs:
         filename = c + ".crt"
         print "Saving certificate %s" % filename
         certs[c].save_pem(filename)
     for k in pkeys:
         filename = k + ".key"
         print "Saving key %s" % filename
         write_file(filename, pkeys[k])
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:10,代码来源:keychain.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.write_log函数代码示例发布时间:2022-05-26
下一篇:
Python util.writeFile函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap