本文整理匯總了Python中pyaid.system.SystemUtils.SystemUtils.remove方法的典型用法代碼示例。如果您正苦於以下問題:Python SystemUtils.remove方法的具體用法?Python SystemUtils.remove怎麽用?Python SystemUtils.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyaid.system.SystemUtils.SystemUtils
的用法示例。
在下文中一共展示了SystemUtils.remove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: initialize
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def initialize():
path = FileUtils.makeFolderPath(MY_DIR, 'data')
SystemUtils.remove(path)
os.makedirs(path)
tracks = DataLoadUtils.getTrackWithAnalysis()
return tracks[['uid', 'site', 'width', 'sizeClass']]
示例2: _deployResources
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def _deployResources(cls):
""" On windows the resource folder data is stored within the application install directory.
However, due to permissions issues, certain file types cannot be accessed from that
directory without causing the program to crash. Therefore, the stored resources must
be expanded into the user's AppData/Local folder. The method checks the currently
deployed resources folder and deploys the stored resources if the existing resources
either don't exist or don't match the currently installed version of the program. """
if not OsUtils.isWindows() or not PyGlassEnvironment.isDeployed:
return False
storagePath = PyGlassEnvironment.getInstallationPath('resource_storage', isDir=True)
storageStampPath = FileUtils.makeFilePath(storagePath, 'install.stamp')
resourcePath = PyGlassEnvironment.getRootResourcePath(isDir=True)
resourceStampPath = FileUtils.makeFilePath(resourcePath, 'install.stamp')
try:
resousrceData = JSON.fromFile(resourceStampPath)
storageData = JSON.fromFile(storageStampPath)
if resousrceData['CTS'] == storageData['CTS']:
return False
except Exception as err:
pass
SystemUtils.remove(resourcePath)
FileUtils.mergeCopy(storagePath, resourcePath)
return True
示例3: deployDebugNativeExtensions
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def deployDebugNativeExtensions(cls, cmd, settings):
from CompilerDeck.adobe.flex.FlexProjectData import FlexProjectData
sets = settings
if not sets.aneIncludes:
return None
debugPath = FileUtils.createPath(
sets.projectPath, 'NativeExtensions', '__debug__', isDir=True, noTail=True)
if os.path.exists(debugPath):
SystemUtils.remove(debugPath)
os.makedirs(debugPath)
extensionIDs = []
for ane in sets.aneIncludes:
anePath = FileUtils.createPath(sets.projectPath, 'NativeExtensions', ane, isDir=True)
aneSets = FlexProjectData(anePath)
extensionIDs.append(aneSets.getSetting('ID'))
aneFilename = aneSets.getSetting('FILENAME')
aneFile = FileUtils.createPath(anePath, aneFilename + '.ane', isFile=True)
z = zipfile.ZipFile(aneFile)
z.extractall(FileUtils.createPath(debugPath, aneFilename + '.ane', isDir=True, noTail=True))
AirUtils.updateAppExtensions(sets.appDescriptorPath, extensionIDs)
cmd.extend(['-extdir', '"%s"' % debugPath])
return debugPath
示例4: initializeFolder
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def initializeFolder(self, *args):
""" Initializes a folder within the root analysis path by removing any existing contents
and then creating a new folder if it does not already exist. """
path = self.getPath(*args, isDir=True)
if os.path.exists(path):
SystemUtils.remove(path)
os.makedirs(path)
return path
示例5: initialize
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def initialize(my_path):
if os.path.isfile(my_path):
my_path = FileUtils.getDirectoryOf(my_path)
path = FileUtils.makeFolderPath(my_path, 'data')
SystemUtils.remove(path)
os.makedirs(path)
return path
示例6: run
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def run(self):
""" Executes the analysis process, iterating through each of the analysis stages before
cleaning up and exiting. """
print('[OUTPUT PATH]: %s' % self.analysisRootPath)
print(analysisStamp)
print(tracksStamp)
self._startTime = TimeUtils.getNowDatetime()
myRootPath = self.getPath(isDir=True)
if os.path.exists(myRootPath):
FileUtils.emptyFolder(myRootPath)
if not os.path.exists(myRootPath):
os.makedirs(myRootPath)
tempPath = self.tempPath
if os.path.exists(tempPath):
SystemUtils.remove(tempPath)
os.makedirs(tempPath)
if not self.logger.loggingPath:
self.logger.loggingPath = myRootPath
try:
session = self.getAnalysisSession()
self._preAnalyze()
for stage in self._stages:
self._currentStage = stage
stage.analyze()
self._currentStage = None
self._postAnalyze()
session.commit()
session.close()
self._success = True
except Exception as err:
session = self.getAnalysisSession()
session.close()
msg = [
'[ERROR]: Failed to execute analysis',
'STAGE: %s' % self._currentStage]
self._errorMessage = Logger.createErrorMessage(msg, err)
self.logger.writeError(msg, err)
session = self.getTracksSession()
session.close()
self._cleanup()
SystemUtils.remove(tempPath)
self.logger.write('\n\n[%s]: %s (%s)' % (
'SUCCESS' if self._success else 'FAILED',
self.__class__.__name__,
TimeUtils.toPrettyElapsedTime(self.elapsedTime)
), indent=False)
示例7: run
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def run(self):
"""Doc..."""
# Create the bin directory where the output will be stored if it does not already exist
binPath = self.getBinPath(isDir=True)
if not os.path.exists(binPath):
os.makedirs(binPath)
# Remove any folders created by previous build attempts
for d in self._CLEANUP_FOLDERS:
path = os.path.join(binPath, d)
if os.path.exists(path):
shutil.rmtree(path)
os.chdir(binPath)
ResourceCollector(self, verbose=True).run()
cmd = [
FileUtils.makeFilePath(sys.prefix, 'bin', 'python'),
'"%s"' % self._createSetupFile(binPath),
OsUtils.getPerOsValue('py2exe', 'py2app'), '>',
'"%s"' % self.getBinPath('setup.log', isFile=True)]
print('[COMPILING]: Executing %s' % OsUtils.getPerOsValue('py2exe', 'py2app'))
print('[COMMAND]: %s' % ' '.join(cmd))
result = SystemUtils.executeCommand(cmd, remote=False, wait=True)
if result['code']:
print('COMPILATION ERROR:')
print(result['out'])
print(result['error'])
return False
if self.appFilename and OsUtils.isWindows():
name = self.applicationClass.__name__
source = FileUtils.createPath(binPath, 'dist', name + '.exe', isFile=True)
dest = FileUtils.createPath(binPath, 'dist', self.appFilename + '.exe', isFile=True)
os.rename(source, dest)
if OsUtils.isWindows() and not self._createWindowsInstaller(binPath):
print('Installer Creation Failed')
return False
elif OsUtils.isMac() and not self._createMacDmg(binPath):
print('DMG Creation Failed')
return False
# Remove the resources path once compilation is complete
resourcePath = FileUtils.createPath(binPath, 'resources', isDir=True)
SystemUtils.remove(resourcePath)
buildPath = FileUtils.createPath(binPath, 'build', isDir=True)
SystemUtils.remove(buildPath)
FileUtils.openFolderInSystemDisplay(binPath)
return True
示例8: run
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def run(self):
"""Doc..."""
# Create the bin directory where the output will be stored if it does not alread exist
binPath = self.getBinPath(isDir=True)
if not os.path.exists(binPath):
os.makedirs(binPath)
# Remove any folders created by previous build attempts
for d in self._CLEANUP_FOLDERS:
path = os.path.join(binPath, d)
if os.path.exists(path):
shutil.rmtree(path)
os.chdir(binPath)
ResourceCollector(self, verbose=True).run()
cmd = 'python %s %s > %s' % (
self._createSetupFile(binPath),
'py2exe' if OsUtils.isWindows() else 'py2app',
self.getBinPath('setup.log', isFile=True) )
result = SystemUtils.executeCommand(cmd, remote=False, wait=True)
if result['code']:
print 'COMPILATION ERROR:'
print result['error']
return False
if self.appFilename and OsUtils.isWindows():
name = self.applicationClass.__name__
source = FileUtils.createPath(binPath, 'dist', name + '.exe', isFile=True)
dest = FileUtils.createPath(binPath, 'dist', self.appFilename + '.exe', isFile=True)
os.rename(source, dest)
if OsUtils.isWindows() and not self._createWindowsInstaller(binPath):
print 'Installer Creation Failed'
return False
elif OsUtils.isMac() and not self._createMacDmg(binPath):
print 'DMG Creation Failed'
return False
# Remove the resources path once compilation is complete
resourcePath = FileUtils.createPath(binPath, 'resources', isDir=True)
SystemUtils.remove(resourcePath)
buildPath = FileUtils.createPath(binPath, 'build', isDir=True)
SystemUtils.remove(buildPath)
return True
示例9: run
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def run(self):
""" Executes the site generation process """
try:
if os.path.exists(self.targetWebRootPath):
if not SystemUtils.remove(self.targetWebRootPath):
# In unsuccessful wait a brief period and try again in case the OS delayed
# the allowance for the removal because of an application conflict
time.sleep(5)
SystemUtils.remove(self.targetWebRootPath, throwError=True)
os.makedirs(self.targetWebRootPath)
except Exception, err:
self.writeLogError(
u'Unable to Remove Existing Deployment',
error=err,
throw=False)
return False
示例10: _createEngineCss
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def _createEngineCss(self):
resourcePath = StaticFlowEnvironment.rootResourcePath
sourceFolder = FileUtils.createPath(resourcePath, '..', 'css', isDir=True)
targetFolder = FileUtils.createPath(resourcePath, 'web', 'css', isDir=True)
tempPath = FileUtils.createPath(targetFolder, 'engine.temp.css', isFile=True)
SystemUtils.remove(tempPath)
destF = open(tempPath, 'a')
for item in FileUtils.getFilesOnPath(sourceFolder):
try:
f = open(item, 'r')
destF.write('\n' + f.read())
f.close()
except Exception , err:
print 'ERROR: Failed to read CSS file:', item
示例11: _remove
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def _remove(self, path):
if not os.path.exists(path):
print 'NOTHING TO REMOVE: ' + path
return False
result = SystemUtils.remove(path)
if not result:
print 'FAILED TO REMOVE: ' + path
return False
print 'REMOVED PATH: ' + path
return True
示例12: emptyFolder
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def emptyFolder(cls, folderPath):
""" Recursively empties all elements within a folder, and returns a
boolean specifying whether the operation succeeded.
"""
folderPath = cls.cleanupPath(folderPath, isDir=True)
if not os.path.exists(folderPath):
return False
result = True
for path in os.listdir(folderPath[:-1]):
result = SystemUtils.remove(folderPath + path) and result
return result
示例13: _createMacDmg
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def _createMacDmg(self, binPath):
print 'CREATING Mac DMG'
target = FileUtils.createPath(binPath, self.application.appID + '.dmg', isFile=True)
tempTarget = FileUtils.createPath(binPath, 'pack.tmp.dmg', isFile=True)
distPath = FileUtils.createPath(binPath, 'dist', isDir=True, noTail=True)
if os.path.exists(tempTarget):
SystemUtils.remove(tempTarget)
cmd = ['hdiutil', 'create', '-size', '500m', '"%s"' % tempTarget, '-ov', '-volname',
'"%s"' % self.appDisplayName, '-fs', 'HFS+', '-srcfolder', '"%s"' % distPath]
result = SystemUtils.executeCommand(cmd, wait=True)
if result['code']:
print 'Failed Command Execution:'
print result
return False
cmd = ['hdiutil', 'convert', "%s" % tempTarget, '-format', 'UDZO', '-imagekey',
'zlib-level=9', '-o', "%s" % target]
if os.path.exists(target):
SystemUtils.remove(target)
result = SystemUtils.executeCommand(cmd)
if result['code']:
print 'Failed Command Execution:'
print result
return False
SystemUtils.remove(tempTarget)
return True
示例14: _handleReplaceDatabase
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def _handleReplaceDatabase(self):
self.mainWindow.showLoading(
self,
u'Browsing for Database File',
u'Choose a valid database (*.vcd) file')
defaultPath = self.appConfig.get(UserConfigEnum.DATABASE_IMPORT_PATH)
if not defaultPath:
defaultPath = self.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH)
path = PyGlassBasicDialogManager.browseForFileOpen(
parent=self,
caption=u'Select Database File',
defaultPath=defaultPath)
self.mainWindow.hideLoading(self)
if not path:
self.mainWindow.toggleInteractivity(True)
return
# Store directory for later use
self.appConfig.set(
UserConfigEnum.DATABASE_IMPORT_PATH,
FileUtils.getDirectoryOf(path) )
self.mainWindow.showStatus(
self,
u'Replacing Database File',
u'Removing existing database file and replacing it with selection')
sourcePath = getattr(Tracks_Track, 'URL')[len(u'sqlite:'):].lstrip(u'/')
if not OsUtils.isWindows():
sourcePath = u'/' + sourcePath
savePath = '%s.store' % sourcePath
try:
if os.path.exists(savePath):
SystemUtils.remove(savePath, throwError=True)
except Exception as err:
self.mainWindow.appendStatus(
self, u'<span style="color:#CC3333">ERROR: Unable to access database save location.</span>')
self.mainWindow.showStatusDone(self)
return
try:
SystemUtils.move(sourcePath, savePath)
except Exception as err:
self.mainWindow.appendStatus(
self, u'<span style="color:#CC3333;">ERROR: Unable to modify existing database file.</span>')
self.mainWindow.showStatusDone(self)
return
try:
SystemUtils.copy(path, sourcePath)
except Exception as err:
SystemUtils.move(savePath, sourcePath)
self.mainWindow.appendStatus(
self, u'<span style="color:#CC3333;">ERROR: Unable to copy new database file.</span>')
self.mainWindow.showStatusDone(self)
return
if os.path.exists(savePath):
SystemUtils.remove(savePath)
self.mainWindow.appendStatus(self, u'<span style="color:#33CC33;">Database Replaced</span>')
self.mainWindow.showStatusDone(self)
示例15: _runImpl
# 需要導入模塊: from pyaid.system.SystemUtils import SystemUtils [as 別名]
# 或者: from pyaid.system.SystemUtils.SystemUtils import remove [as 別名]
def _runImpl(self):
if not os.path.exists(self.targetWebRootPath):
os.makedirs(self.targetWebRootPath)
for staticPath in self.get('STATIC_PATHS', []):
self._staticPaths.append(FileUtils.createPath(
self.sourceWebRootPath,
*staticPath.strip(u'/').split(u'/')))
#-------------------------------------------------------------------------------------------
# COPY FILES
# Copies files from the source folders to the target root folder, maintaining folder
# structure in the process
FileUtils.walkPath(self.sourceWebRootPath, self._copyWalker)
#--- COMMON FILES ---#
copies = [
(u'StaticFlow Javascript', 'web/js', 'js/sflow'),
(u'StaticFlow CSS', 'web/css', 'css/sflow') ]
for item in copies:
source = FileUtils.createPath(
StaticFlowEnvironment.rootResourcePath, *item[1].split('/'), isDir=True)
target = FileUtils.createPath(
self.targetWebRootPath, *item[2].split('/'), isDir=True)
if os.path.exists(target):
SystemUtils.remove(target)
targetFolder = FileUtils.createPath(target, '..', isDir=True)
if not os.path.exists(targetFolder):
os.makedirs(targetFolder)
fileList = FileUtils.mergeCopy(source, target)
for path, data in fileList.files.iteritems():
SiteProcessUtils.copyToCdnFolder(
path, self, FileUtils.getUTCModifiedDatetime(source))
self.writeLogSuccess(u'COPIED', u'%s | %s -> %s' % (
item[0], source.rstrip(os.sep), target.rstrip(os.sep) ))
#-------------------------------------------------------------------------------------------
# COMPILE
# Compiles source files to the target root folder
currentPath = os.curdir
os.path.walk(self.sourceWebRootPath, self._compileWalker, None)
os.chdir(currentPath)
#-------------------------------------------------------------------------------------------
# CREATE PAGE DEFS
# Creates the page data files that define the pages to be generated
os.path.walk(self.sourceWebRootPath, self._htmlDefinitionWalker, None)
self._pages.process()
self._sitemap.write()
self._robots.write()
for rssGenerator in self._rssGenerators:
rssGenerator.write()
self._writeGoogleFiles()
#-------------------------------------------------------------------------------------------
# CLEANUP
# Removes temporary and excluded file types from the target root folder
os.path.walk(self.targetWebRootPath, self._cleanupWalker, dict())
return True