本文整理匯總了Python中appy.shared.utils.FolderDeleter.delete方法的典型用法代碼示例。如果您正苦於以下問題:Python FolderDeleter.delete方法的具體用法?Python FolderDeleter.delete怎麽用?Python FolderDeleter.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類appy.shared.utils.FolderDeleter
的用法示例。
在下文中一共展示了FolderDeleter.delete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: createDistRelease
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def createDistRelease(self):
"""Create the distutils package."""
curdir = os.getcwd()
distFolder = "%s/dist" % self.genFolder
# Create setup.py
os.mkdir(distFolder)
f = file("%s/setup.py" % distFolder, "w")
# List all packages to include
packages = []
os.chdir(os.path.dirname(appyPath))
for dir, dirnames, filenames in os.walk("appy"):
if self.isDistExcluded(dir):
continue
packageName = dir.replace("/", ".")
packages.append('"%s"' % packageName)
f.write(distInfo % (self.versionShort, ",".join(packages)))
f.close()
# Create MANIFEST.in
f = file("%s/MANIFEST.in" % distFolder, "w")
f.write(manifestInfo)
f.close()
# Move appy sources within the dist folder
os.rename("%s/appy" % self.genFolder, "%s/appy" % distFolder)
# Create the source distribution
os.chdir(distFolder)
self.executeCommand("python setup.py sdist")
# DistUtils has created the .tar.gz file. Move it to folder "versions"
name = "appy-%s.tar.gz" % self.versionShort
os.rename("%s/dist/%s" % (distFolder, name), "%s/versions/%s" % (appyPath, name))
# Clean temp files
os.chdir(curdir)
# Keep the Appy source for building the Debian package afterwards
os.rename(os.path.join(self.genFolder, "dist", "appy"), os.path.join(self.genFolder, "appy"))
FolderDeleter.delete(os.path.join(self.genFolder, "dist"))
return name
示例2: zipResult
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def zipResult(self, eggFullName, eggTempFolder):
'''Zips the result and removes the egg temp folder.'''
zipFile = zipfile.ZipFile(eggFullName, 'w', zipfile.ZIP_DEFLATED)
# Put the Python module inside the egg.
prefix = os.path.dirname(eggTempFolder)
for dir, dirnames, filenames in os.walk(eggTempFolder):
for f in filenames:
fileName = os.path.join(dir, f)
zipFile.write(fileName, fileName[len(prefix):])
# Put the Appy module inside it if required.
if self.includeAppy:
eggPrefix = '%s/%s' % (eggTempFolder[len(prefix):],
self.moduleName.replace('.', '/'))
# Where is Appy?
appyPath = os.path.dirname(appy.__file__)
appyPrefix = os.path.dirname(appyPath)
# Clean the Appy folder
Cleaner().run(verbose=False)
# Insert appy files into the zip
for dir, dirnames, filenames in os.walk(appyPath):
if not self.dirInZip(dir): continue
for f in filenames:
fileName = os.path.join(dir, f)
zipName = eggPrefix + fileName[len(appyPrefix):]
zipFile.write(fileName, zipName)
zipFile.close()
# Remove the temp egg folder.
FolderDeleter.delete(eggTempFolder)
示例3: eggify
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def eggify(self):
'''Let's wrap a nice Python module into an ugly egg.'''
j = os.path.join
# First, clean the Python module
cleanFolder(self.pythonModule, verbose=False)
# Create the egg folder
eggFullName = j(self.eggFolder, self.eggName)
if os.path.exists(eggFullName):
os.remove(eggFullName)
print('Existing "%s" was removed.' % eggFullName)
# Create a temp folder where to store the egg
eggTempFolder = os.path.splitext(eggFullName)[0]
if os.path.exists(eggTempFolder):
FolderDeleter.delete(eggTempFolder)
print('Removed "%s" that was in my way.' % eggTempFolder)
os.mkdir(eggTempFolder)
# Create the "Products" sub-folder if we must wrap the package in this
# namespace
eggModulePath = j(j(eggTempFolder, self.moduleName.replace('.', '/')))
# Copy the Python module into the egg.
os.makedirs(eggModulePath)
copyFolder(self.pythonModule, eggModulePath)
# Create setup files in the root egg folder
self.createSetupFile(eggTempFolder)
self.createInitFile(eggTempFolder)
self.zipResult(eggFullName, eggTempFolder)
示例4: __init__
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def __init__(self):
# Delete the "egg" folder on not-yet-copied local site.
eggFolder = "%s/temp/egg" % appyPath
if os.path.isdir(eggFolder):
FolderDeleter.delete(eggFolder)
# Ask user id and password for FTP transfer
userId, userPassword = askLogin()
self.site = ftplib.FTP(self.name)
self.site.login(userId, userPassword)
self.rootFolder = None # Root folder of appy site ~FtpFolder~
self.currentFolder = None # Currently visited folder ~FtpFolder~
示例5: __init__
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def __init__(self, app, pythonVersions=('2.6',)):
self.appName = os.path.basename(app)
self.pythonVersions = pythonVersions
appFolder = os.path.dirname(app)
# Prepare the output folder (remove any existing one)
cortexFolder = os.path.join(appFolder, 'cortex.admin')
if os.path.exists(cortexFolder):
FolderDeleter.delete(cortexFolder)
allFolders = os.path.join(cortexFolder, 'applications', self.appName)
os.makedirs(allFolders)
self.out = allFolders
示例6: run
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def run(self, verbose=True):
cleanFolder(appyPath, verbose=verbose)
# Remove all files in temp folders
for tempFolder in ('%s/temp' % appyPath,
'%s/pod/test/temp' % appyPath):
if os.path.exists(tempFolder):
FolderDeleter.delete(tempFolder)
# Remove test reports if any
for testReport in ('%s/pod/test/Tester.report.txt' % appyPath,):
if os.path.exists(testReport):
os.remove(testReport)
示例7: finalize
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def finalize(self):
msg = '%d/%d successful test(s)' % \
(self.nbOfSuccesses, (self.nbOfTests-self.nbOfIgnoredTests))
if self.nbOfIgnoredTests >0:
msg += ', but %d ignored test(s) not counted' % \
self.nbOfIgnoredTests
msg += '.'
self.report.say(msg, force=True)
self.report.close()
if not self.keepTemp:
if os.path.exists(self.tempFolder):
FolderDeleter.delete(self.tempFolder)
示例8: setStylesMapping
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def setStylesMapping(self, stylesMapping):
'''Establishes a correspondence between, on one hand, CSS styles or
XHTML tags that will be found inside XHTML content given to POD,
and, on the other hand, ODT styles found into the template.'''
try:
stylesMapping = self.stylesManager.checkStylesMapping(stylesMapping)
self.stylesManager.setStylesMapping(stylesMapping)
except PodError, po:
self.contentParser.env.currentBuffer.content.close()
self.stylesParser.env.currentBuffer.content.close()
if os.path.exists(self.tempFolder):
FolderDeleter.delete(self.tempFolder)
raise po
示例9: run
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def run(self):
'''Renders the result.'''
try:
# Remember which parser is running
self.currentParser = self.contentParser
# Create the resulting content.xml
self.currentParser.parse(self.contentXml)
self.currentParser = self.stylesParser
# Create the resulting styles.xml
self.currentParser.parse(self.stylesXml)
# Patch META-INF/manifest.xml
self.patchManifest()
# Re-zip the result
self.finalize()
finally:
FolderDeleter.delete(self.tempFolder)
示例10: run
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def run(self):
self.report.say('-' * 79)
self.report.say('- Test %s.' % self.data['Name'])
self.report.say('- %s\n' % self.description)
# Prepare test data
self.tempFolder = os.path.join(self.testFolder, 'temp')
if os.path.exists(self.tempFolder):
FolderDeleter.delete(self.tempFolder)
os.mkdir(self.tempFolder)
try:
self.do()
self.report.say('Checking result...')
testFailed = self.checkResult()
except:
testFailed = self.onError()
self.finalize()
return testFailed
示例11: run
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def run(self):
Cleaner().run(verbose=False)
# Perform a small analysis on the Appy code
LinesCounter(appy).run()
print 'Generating site in %s...' % self.genFolder
minimalist = askQuestion('Minimalist (shipped without tests)?',
default='no')
self.prepareGenFolder(minimalist)
self.createDocToc()
self.applyTemplate()
self.createZipRelease()
#self.createCodeAndEggReleases()
if askQuestion('Do you want to publish the site on ' \
'appyframework.org?', default='no'):
AppySite().publish()
if askQuestion('Delete locally generated site ?', default='no'):
FolderDeleter.delete(self.genFolder)
示例12: run
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def run(self):
self.report.say('-' * 79)
self.report.say('- Test %s.' % self.data['Name'])
self.report.say('- %s\n' % self.description)
# Prepare test data
self.tempFolder = os.path.join(self.testFolder, 'temp', self.data['Name'])
if os.path.exists(self.tempFolder):
time.sleep(0.3) # Sometimes I can't remove it, so I wait
FolderDeleter.delete(self.tempFolder)
os.makedirs(self.tempFolder)
try:
self.do()
self.report.say('Checking result...')
testFailed = self.checkResult()
except:
testFailed = self.onError()
self.finalize()
return testFailed
示例13: run
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def run(self):
Cleaner().run(verbose=False)
# Perform a small analysis on the Appy code
LinesCounter(appy).run()
print "Generating site in %s..." % self.genFolder
minimalist = self.askQuestion("Minimalist (shipped without tests)?", default="no")
self.prepareGenFolder(minimalist)
self.createDocToc()
self.applyTemplate()
self.createZipRelease()
tarball = self.createDistRelease()
self.createDebianRelease()
if self.askQuestion("Upload %s on PyPI?" % tarball, default="no"):
self.uploadOnPypi(tarball)
if self.askQuestion("Publish on appyframework.org?", default="no"):
AppySite().publish()
if self.askQuestion("Delete locally generated site ?", default="yes"):
FolderDeleter.delete(self.genFolder)
示例14: setStylesMapping
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def setStylesMapping(self, stylesMapping):
'''Establishes a correspondance between, on one hand, CSS styles or
XHTML tags that will be found inside XHTML content given to POD,
and, on the other hand, ODT styles found into the template.'''
try:
stylesMapping = self.stylesManager.checkStylesMapping(stylesMapping)
# The predefined styles below are currently ignored, because the
# xhtml2odt parser does not take into account span tags.
if 'span[font-weight=bold]' not in stylesMapping:
stylesMapping['span[font-weight=bold]'] = 'podBold'
if 'span[font-style=italic]' not in stylesMapping:
stylesMapping['span[font-style=italic]'] = 'podItalic'
self.stylesManager.stylesMapping = stylesMapping
except PodError, po:
self.contentParser.env.currentBuffer.content.close()
self.stylesParser.env.currentBuffer.content.close()
if os.path.exists(self.tempFolder):
FolderDeleter.delete(self.tempFolder)
raise po
示例15: walkFile
# 需要導入模塊: from appy.shared.utils import FolderDeleter [as 別名]
# 或者: from appy.shared.utils.FolderDeleter import delete [as 別名]
def walkFile(self, fileName):
'''Unzip p_fileName in a temp folder, call self.script, and then re-zip
the result.'''
print 'Walking %s...' % fileName
# Create a temp folder
name = 'f%f' % time.time()
tempFolder = os.path.join(self.tempFolder, name)
os.mkdir(tempFolder)
# Unzip the file in it
unzip(fileName, tempFolder)
# Call self.script
py = sys.executable or 'python'
cmd = [py, self.script, tempFolder]
print ' Running %s...' % cmd,
out, err = executeCommand(cmd)
# Re-zip the result
zip(fileName, tempFolder, odf=True)
FolderDeleter.delete(tempFolder)
print 'done.'