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


Python Path.rmtree方法代码示例

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


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

示例1: exportSinglePage

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import rmtree [as 别名]
 def exportSinglePage(self, client, filename, webDir, stylesDir):
     """
     Export 'client' to a single web page,
     'webDir' is just read from config.webDir
     'stylesDir' is where to copy the style sheet information from
     """
     imagesDir    = webDir.joinpath('images')
     scriptsDir   = webDir.joinpath('scripts')
     templatesDir = webDir.joinpath('templates')
     filename = Path(filename)
     if filename.basename() != self.package.name:
         filename /= self.package.name
     if not filename.exists():
         filename.makedirs()
     elif not filename.isdir():
         client.alert(_(u'Filename %s is a file, cannot replace it') % 
                      filename)
         log.error("Couldn't export web page: "+
                   "Filename %s is a file, cannot replace it" % filename)
         return
     else:
         try:
             filename.rmtree()
             filename.mkdir()
         except Exception, e:
             client.alert(_('There was an error in the export:\n%s') % str(e))
             return
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: main

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import rmtree [as 别名]
def main():
    if len(sys.argv) < 2:
        print 'Usage: %s [version] [--install] [--local|username password]' % sys.argv[0]
        print 'Where [version] is the branch you want to checkout'
        print 'and username and password are for your eduforge account'
        print 'Eg. %s 0.7 --local' % sys.argv[0]
    else:
        version = sys.argv[1]
        branch = 'http://exe.cfdl.auckland.ac.nz/svn/exe/branches/%s' % version
        origDir = Path(sys.argv[0]).abspath().dirname()
        tmp = TempDirPath()
        os.chdir(tmp)
        os.system('svn export %s exe' % branch)
        (origDir/'../../exe/webui/firefox').copytree(tmp/'exe/exe/webui/firefox')
        os.chdir(tmp/'exe')
        tarball = Path('../exe-%s-source.tgz' % version).abspath()
        os.system('tar czf %s *' % tarball)
        os.chdir(tmp)
        if '--local' not in sys.argv:
            try:
                from paramiko import Transport
            except ImportError:
                print 'To upload you need to install paramiko python library from:'
                print 'http://www.lag.net/paramiko'
                sys.exit(2)
            from socket import socket, gethostbyname
            s = socket()
            s.connect((gethostbyname('shell.eduforge.org'), 22))
            t = Transport(s)
            t.connect()
            t.auth_password(sys.argv[-2], sys.argv[-1])
            f = t.open_sftp_client()
            f.chdir('/home/pub/exe')
            f.put(tarball.encode('utf8'), tarball.basename().encode('utf8'))
        if os.getuid() == 0:
            tarball.copyfile('/usr/portage/distfiles/' + tarball.basename())
        os.chdir(tmp/'exe/installs/gentoo')
        newEbuildFilename = Path('exe-%s.ebuild' % version).abspath()
        if not newEbuildFilename.exists():
            Path('exe-0.7.ebuild').copy(newEbuildFilename)
        if os.getuid() == 0:
            ebuildDir = Path('/usr/local/portage/dev-python/exe')
            if ebuildDir.exists():
                ebuildDir.rmtree()
            ebuildDir.makedirs()
            os.chdir(ebuildDir)
            newEbuildFilename.copy(ebuildDir)
            filesDir = ebuildDir/'files'
            filesDir.makedirs()
            Path(tmp/'exe/installs/gentoo/all-config.patch').copy(filesDir)
            if '--local' not in sys.argv:
                oldTarball = Path('/usr/portage/distfiles/')/tarball.basename()
                if oldTarball.exists():
                    oldTarball.remove()
                os.environ['GENTOO_MIRRORS']=''
                os.system('ebuild %s fetch' % newEbuildFilename.basename())
            os.system('ebuild %s manifest' % newEbuildFilename.basename())
            os.system('ebuild %s digest' % newEbuildFilename.basename())
            if '--install' in sys.argv:
                os.system('ebuild %s install' % newEbuildFilename.basename())
开发者ID:,项目名称:,代码行数:62,代码来源:

示例3: exportWebSite

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import rmtree [as 别名]
 def exportWebSite(self, client, filename, webDir, stylesDir):
     """
     Export 'client' to a web site,
     'webDir' is just read from config.webDir
     'stylesDir' is where to copy the style sheet information from
     """
     imagesDir    = webDir.joinpath('images')
     scriptsDir   = webDir.joinpath('scripts')
     templatesDir = webDir.joinpath('templates')
     filename = Path(filename)
     if filename.basename() != self.package.name:
         filename /= self.package.name
     if not filename.exists():
         filename.makedirs()
     elif not filename.isdir():
         client.alert(_(u'Filename %s is a file, cannot replace it') % 
                      filename)
         log.error("Couldn't export web page: "+
                   "Filename %s is a file, cannot replace it" % filename)
         return
     else:
         filename.rmtree()
         filename.mkdir()
     websiteExport = WebsiteExport(stylesDir, filename, 
                                   imagesDir, scriptsDir, templatesDir)
     websiteExport.export(self.package)
     self._startFile(filename)
开发者ID:,项目名称:,代码行数:29,代码来源:


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