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

Python util.makedirs函数代码示例

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

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



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

示例1: write_xenvmd_config

def write_xenvmd_config(uuid, vg, devices, vgsize):
    global config_dir
    configfile = "%s/%s.xenvmd.config" % (config_dir, vg)
    sockpath = sockpath_of_sr_uuid(uuid)
    #Min host allocation quantum in MiB, i.e., 10 times
    #min_allocation_quantum (currently 16MiB):
    min_host_allocation_quantum = 160
    #host_allocation_quantum is 0.5% of SR size
    host_allocation_quantum = (vgsize * 0.005) / (1024 * 1024)
    #host_allocation_quantum should be bigger than 1GiB
    host_allocation_quantum = max(min_host_allocation_quantum,
                                  host_allocation_quantum)
    host_low_water_mark = (host_allocation_quantum * 0.5)
    config = """
(
 (listenPort ())
 (listenPath (Some %s))
 (host_allocation_quantum %d)
 (host_low_water_mark %d)
 (vg %s)
 (devices (%s))
 (rrd_ds_owner %s)
)
""" % (sockpath, host_allocation_quantum, host_low_water_mark, vg, " ".join(devices), uuid)
    if not os.path.exists(config_dir):
      util.makedirs(config_dir)
    if not os.path.exists(os.path.dirname(sockpath)):
      util.makedirs(os.path.dirname(sockpath))
    with open(configfile,'w') as f:
        f.write(config)
开发者ID:letsboogey,项目名称:sm,代码行数:30,代码来源:lvutil.py


示例2: fetch

    def fetch(self, request, opener=None, summary=None):

        if not self.__enable_http:
            return (None, None)

        if opener is None:
            opener = OpenerDirector()
            opener.add_handler(HTTPDefaultErrorHandler())
            opener.add_handler(HTTPSHandler())

        t = time.clock()
        response = opener.open(request)
        body = response.read()
        t = timedelta(seconds=time.clock() - t)
        url = request.get_full_url()
        self.__context.get_logger().info('HTTP time: %s\n%s' % (t, url))

        if self.__log_http:
            log_dir = os.path.join(self.__context.get_config_dir(), 'http-log')
            makedirs(log_dir)
            log_file = os.path.join(log_dir,
                                    datetime.utcnow().strftime(
                                        '%Y-%m-%d-%H-%M-%S-%f'))
            if summary is not None:
                log_file += '-' + _safe_str(summary)
            fp = open(log_file, 'w')
            fp.write('\n\n'.join([
                request.get_full_url(),
                request.get_data() or 'No request data',
                body or 'No response body',
            ]))
            fp.close()

        return (response, body)
开发者ID:chris-martin,项目名称:grouch,代码行数:34,代码来源:scraper.py


示例3: writeOutputFiles

    def writeOutputFiles(self, sourceRoot, outputRoot=None):
        import util
        hardcoreDir = os.path.join(sourceRoot, 'modules', 'hardcore')
        actionsDir = os.path.join(hardcoreDir, 'actions')
        if outputRoot is None: targetDir = actionsDir
        else:
            targetDir = os.path.join(outputRoot, 'modules', 'hardcore', 'actions')
            util.makedirs(targetDir)
        changed = util.readTemplate(os.path.join(actionsDir, 'actions_template.h'),
                                    os.path.join(targetDir, 'generated_actions.h'),
                                    HandleTemplateAction(self))

        changed = util.readTemplate(os.path.join(actionsDir, 'actions_enum_template.h'),
                                    os.path.join(targetDir, 'generated_actions_enum.h'),
                                    HandleTemplateAction(self)) or changed
        changed = util.readTemplate(os.path.join(actionsDir, 'actions_strings_template.h'),
                                    os.path.join(targetDir, 'generated_actions_strings.h'),
                                    HandleTemplateAction(self)) or changed
        # Ignore changes in this; this is just a template for a
        # platforms' actions.h and not used when building Opera:
        util.readTemplate(os.path.join(actionsDir, 'actions_template_template.h'),
                          os.path.join(targetDir, 'generated_actions_template.h'),
                          HandleTemplateAction(self))
        if targetDir == actionsDir:
            util.updateModuleGenerated(
                hardcoreDir,
                ['actions/generated_actions.h',
                 'actions/generated_actions_enum.h',
                 'actions/generated_actions_strings.h',
                 'actions/generated_actions_template.h'])
        return changed
开发者ID:prestocore,项目名称:browser,代码行数:31,代码来源:actions.py


示例4: render_ebook

    def render_ebook(self, polish_fun=None):
        print "-- generating ebooks"
        makedirs(self.ebook_dir)

        this_dir = os.getcwd()
        os.chdir(self.extracted_dir)
#        for t in range(0, 99):
#            first_nr = 100 * t + 1
#            last_nr = 100 * (t + 1)
#            md_name = "%s.%04i.md" % (self.name, last_nr)
#            if not os.path.exists(md_name):
#                break
        import glob
        for md_name in sorted(glob.glob("%s.*.md" % self.name)):
            last_nr = int(re.sub("%s." % self.name, "", os.path.splitext(md_name)[0]))
            first_nr = last_nr - self.chunk_size + 1
            print "---- processing markdown %s" % md_name
            epub_name = os.path.join(self.ebook_dir, "%s.%04i.epub" % (self.name, last_nr))
            makedirs(os.path.dirname(epub_name))
            cmd = ["pandoc", "-S", md_name,  "-o", epub_name, "--smart"]
            if self.res_dir:
                cmd.append("--epub-stylesheet=%s/epub.css" % self.res_dir)
            if polish_fun:
                context = locals()
                context.update(vars(self))
                cmd = polish_fun(context)
            print "------ rendering %s" % epub_name
            subprocess.check_call(cmd)
        os.chdir(this_dir)
开发者ID:arnehilmann,项目名称:ebookkit,代码行数:29,代码来源:ebookkit.py


示例5: versionthis

def versionthis(filetoversion):
    global options
    try:
        if accesscontrollist.hasacl(filetoversion) and not options.ignoreacl:
            err = "filetoversion has a 'deny' in ACL permissions (ls -lde %s: %s) \n \
            This program is currently not clever enough to check if you have permission to move/delete this file. \n \
            To avoid this problem remove deny permissions from the access control entries \n \
            or rerun this command with --ignoreacl" % (filetoversion, accesscontrollist.getacl(filetoversion))
            raise SyncherException(err)

        # TODO: verify that this file is not already added
        logging.info("should: check for dups")

        filetoversionpath, repospathofversionedfile, repospathtoputnewfilein = settings.getFileToVersionPathes(filetoversion)

        util.makedirs(repospathtoputnewfilein)

        acl = None
        if options.ignoreacl:
            acl = accesscontrollist.removeacl(filetoversion)

        util.move(filetoversionpath, repospathofversionedfile)  # repospathtoputnewfilein)

        if acl is not None:
            accesscontrollist.setacl(repospathofversionedfile, acl)

        util.symlink(repospathofversionedfile, filetoversionpath)

        syncdb.add(filetoversionpath)

    except Exception as e:
        logging.warn("ROLLING BACK because of %s" % e)
        undo.rollback()
        raise
开发者ID:uncreative,项目名称:syncher,代码行数:34,代码来源:keepsynched.py


示例6: runxenvm_local_allocator

def runxenvm_local_allocator(uuid, vg, devices, uri):
    global config_dir
    configfile = "%s/%s.xenvm-local-allocator.config" % (config_dir, vg)
    uuid = util.get_this_host ()
    socket_dir = "/var/run/sm/allocator"
    journal_dir = "/tmp/sm/allocator-journal"
    for d in [ socket_dir, journal_dir ]:
        if not os.path.exists(d):
            util.makedirs(d)
    local_allocator = "%s/%s" % (socket_dir, vg)
    config = """
(
 (socket %s)
 (allocation_quantum 16)
 (localJournal %s/%s)
 (devices (%s))
 (toLVM %s-toLVM)
 (fromLVM %s-fromLVM)
)
""" % (local_allocator, journal_dir, vg, "".join(devices), uuid, uuid)
    if not os.path.exists(config_dir):
      util.makedirs(config_dir)
    with open(configfile, 'w') as f:
        f.write(config)
    cmd = [ "/bin/xenvm", "host-create", vg, uuid ]
    util.pread2(cmd)
    cmd = [ "/bin/xenvm", "host-connect", vg, uuid ]
    util.pread2(cmd)
    cmd = [ "/bin/xenvm-local-allocator", "--daemon", "--config", configfile ]
    util.pread2(cmd)
    setvginfo(uuid,vg,devices,uri,local_allocator)
开发者ID:letsboogey,项目名称:sm,代码行数:31,代码来源:lvutil.py


示例7: writeFile

    def writeFile(self, f, decrypted_chunks):
        path = os.path.join(self.outputFolder, re.sub(r'[:|*<>?"]', "_", f.RelativePath))
        print path
        makedirs(os.path.dirname(path))
        ff = open(path, "wb")
        h = hashlib.sha1()
        for i in xrange(len(decrypted_chunks)):
            d = decrypted_chunks[i]
            h.update(d)
            ff.write(d)
        ff.close()

        if f.Attributes.EncryptionKey:
            EncryptionKey = f.Attributes.EncryptionKey
            #ProtectionClass = f.Attributes.ProtectionClass
            hexdump(EncryptionKey)
            ProtectionClass = struct.unpack(">L", EncryptionKey[0x18:0x1C])[0]
            assert ProtectionClass == f.Attributes.ProtectionClass
            #EncryptionKeyVersion=2 => starts with keybag uuid
            if f.Attributes.EncryptionKeyVersion and f.Attributes.EncryptionKeyVersion == 2:
                assert self.kb.uuid == EncryptionKey[:0x10]
                keyLength = struct.unpack(">L", EncryptionKey[0x20:0x24])[0]
                assert keyLength == 0x48
                wrapped_key = EncryptionKey[0x24:]
            else:#XXX old format ios 5 backup
                wrapped_key = EncryptionKey[0x1C:]
            print "ProtectionClass= %d" % ProtectionClass
            filekey = self.kb.unwrapCurve25519(ProtectionClass, wrapped_key)
            if not filekey:
                print "Failed to unwrap file key for file %s !!!" % f.RelativePath
            else:
                print "filekey",filekey.encode("hex")
                self.decryptProtectedFile(path, filekey, f.Attributes.DecryptedSize)
开发者ID:yzx65,项目名称:AppParser,代码行数:33,代码来源:backup.py


示例8: download

    def download(self, backupUDID):
        mbsbackup = self.getBackup(backupUDID)
        print "Downloading backup %s" % backupUDID.encode("hex")
        self.outputFolder = os.path.join(self.outputFolder, backupUDID.encode("hex"))
        makedirs(self.outputFolder)
        print backup_summary(mbsbackup)
        #print mbsbackup.Snapshot.Attributes.KeybagUUID.encode("hex")
        keys = self.getKeys(backupUDID)
        if not keys or not len(keys.Key):
            print "getKeys FAILED!"
            return
        
        print "Got OTA Keybag"
        self.kb = Keybag(keys.Key[1].KeyData)
        if not self.kb.unlockBackupKeybagWithPasscode(keys.Key[0].KeyData):
            print "Unable to unlock OTA keybag !"
            return

        for snapshot in xrange(1, mbsbackup.Snapshot.SnapshotID+1):
            files = self.listFiles(backupUDID, snapshot)
            print "%d files" % len(files)
            files2 = []
            for f in files:
                if f.Attributes.EncryptionKey:
                    files2.append(f)
                    print f
            if len(files2):
                authTokens = self.getFiles(backupUDID, snapshot, files)
                self.authorizeGet(authTokens)
开发者ID:yzx65,项目名称:AppParser,代码行数:29,代码来源:backup.py


示例9: __call__

  def __call__(self, user):
    configDir = user + 'Config/'
    util.makedirs(configDir)

    with open(configDir + 'GCPadNew.ini', 'w') as f:
      f.write(generateGCPadNew(self.cpus))

    with open(configDir + 'Dolphin.ini', 'w') as f:
      config_args = dict(
        user=user,
        gfx=self.gfx,
        cpu_thread=self.cpu_thread,
        dump_frames=self.dump_frames,
        audio=self.audio,
        speed=self.speed
      )
      f.write(dolphinConfig.format(**config_args))

    # don't need memory card with netplay
    #gcDir = user + 'GC/'
    #os.makedirs(gcDir, exist_ok=True)
    #memcardName = 'MemoryCardA.USA.raw'
    #shutil.copyfile(memcardName, gcDir + memcardName)
    
    gameSettings = "GameSettings/"
    shutil.copytree(gameSettings, user + gameSettings)

    util.makedirs(user + 'Dump/Frames/')
开发者ID:codealphago,项目名称:melee-ai,代码行数:28,代码来源:dolphin.py


示例10: __init__

    def __init__(self, ctx, path, state):
        self._path = path
        self._state = state
        r = ctx._repo
        root = r.wjoin(path)
        create = False
        if not os.path.exists(os.path.join(root, '.hg')):
            create = True
            util.makedirs(root)
        self._repo = hg.repository(r.ui, root, create=create)
        self._repo._subparent = r
        self._repo._subsource = state[0]

        if create:
            fp = self._repo.opener("hgrc", "w", text=True)
            fp.write('[paths]\n')

            def addpathconfig(key, value):
                if value:
                    fp.write('%s = %s\n' % (key, value))
                    self._repo.ui.setconfig('paths', key, value)

            defpath = _abssource(self._repo, abort=False)
            defpushpath = _abssource(self._repo, True, abort=False)
            addpathconfig('default', defpath)
            if defpath != defpushpath:
                addpathconfig('default-push', defpushpath)
            fp.close()
开发者ID:helloandre,项目名称:cr48,代码行数:28,代码来源:subrepo.py


示例11: setvginfo

def setvginfo(uuid,vg,devices,uri, local_allocator=None):
    sockpath = sockpath_of_sr_uuid(uuid)

    try:
        util.makedirs(config_dir)
    except OSError, e:
        if e.errno != errno.EEXIST:
            raise
开发者ID:letsboogey,项目名称:sm,代码行数:8,代码来源:lvutil.py


示例12: dir

 def dir(self):
   d = os.path.join(
     self.__context.get_config_dir(),
     'cache',
     os.path.join(*self.__path)
   )
   makedirs(d)
   return d
开发者ID:alecgorge,项目名称:grouch,代码行数:8,代码来源:store.py


示例13: set_options

	def set_options(self, opts):
		self._keep_on_close = opts["keep_images"]

		suf = time.strftime("-%y.%m.%d-%H.%M", time.localtime())
		util.makedirs(opts["img_path"])
		wdir = tempfile.mkdtemp(suf, "%s-" % self._typ, opts["img_path"])
		self._wdir = opendir(wdir)
		self._img_path = os.path.join(self._wdir.name(), "img")
		os.mkdir(self._img_path)
开发者ID:biddyweb,项目名称:phaul,代码行数:9,代码来源:images.py


示例14: close

        def close(self):
            written = self.__file.getvalue()

            try: existing = open(self.__path).read()
            except: existing = None

            if written != existing:
                self.__updated = True
                util.makedirs(os.path.dirname(self.__path))
                open(self.__path, "w").write(written)
开发者ID:prestocore,项目名称:browser,代码行数:10,代码来源:atoms.py


示例15: download

def download(item):
    path = item['path']
    if not os.path.exists(path):
        makedirs(path)

    cmd = 'cd "%s"; wget "%s" ' % (item['path'], item['url'])
    if item['fname']:
        cmd += '-O "%s"' % item['fname']
    print cmd
    return os.system(cmd.encode('utf8'))
开发者ID:huanghao,项目名称:muse,代码行数:10,代码来源:d2.py


示例16: run

def run():
    print("Creating search")
    util.makedirs("../search")
    util.copyfile("database/countries.csv", "../search/countries.csv")
    util.copyfile("database/estudiantes.csv", "../search/estudiantes.csv")
    util.copyfile("templates/search/search.js", "../search/search.js")
    util.copyfile("templates/search/asciify.js", "../search/asciify.js")
    html = templates.get("search/index")
    html = templates.initial_replace(html, 3)
    html = templates.final_replace(html, "..")
    util.writefile("../search/index.html", html)
开发者ID:abeakkas,项目名称:ipho-unofficial.org,代码行数:11,代码来源:search.py


示例17: __init__

 def __init__(self, ctx, path, state):
     self._path = path
     self._state = state
     r = ctx._repo
     root = r.wjoin(path)
     create = False
     if not os.path.exists(os.path.join(root, '.hg')):
         create = True
         util.makedirs(root)
     self._repo = hg.repository(r.ui, root, create=create)
     self._initrepo(r, state[0], create)
开发者ID:sandeepprasanna,项目名称:ODOO,代码行数:11,代码来源:subrepo.py


示例18: init_album

def init_album(alb):
    path = alb['path']
    makedirs(path)

    with open(os.path.join(path, 'meta'), 'w') as f:
        f.write(json.dumps(alb))

    if alb['desc']:
        with open(os.path.join(path, 'desc'), 'w') as f:
            f.write(alb['desc'])

    '''
开发者ID:huanghao,项目名称:muse,代码行数:12,代码来源:load2db.py


示例19: __init__

 def __init__(self, ctx, path, state):
     self._path = path
     self._state = state
     r = ctx._repo
     root = r.wjoin(path)
     if os.path.exists(os.path.join(root, '.hg')):
         self._repo = localrepo.localrepository(r.ui, root)
     else:
         util.makedirs(root)
         self._repo = localrepo.localrepository(r.ui, root, create=True)
     self._repo._subparent = r
     self._repo._subsource = state[0]
开发者ID:dkrisman,项目名称:Traipse,代码行数:12,代码来源:subrepo.py


示例20: writeUndeletedFile

 def writeUndeletedFile(self, filename, data):
     knownExtensions = (".m4a", ".plist",".sqlite",".sqlitedb", ".jpeg", ".jpg", ".png", ".db",".json",".xml",".sql")
     #windows invalid chars  \/:*?"<>|
     filename = str(filename.encode("utf-8")).translate(None, "\\/:*?\"<>|,")
     folder = self.outputdir
     if self.outputdir == "./":
         folder = folder + "/undelete"
     elif filename.lower().endswith(knownExtensions):
         ext = filename[filename.rfind(".")+1:]
         folder = folder + "/" + ext.lower()
     makedirs(folder)
     open(folder + "/" + filename, "wb").write(data)
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:12,代码来源:carver.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.manhattanDistance函数代码示例发布时间:2022-05-26
下一篇:
Python util.makedate函数代码示例发布时间: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