本文整理汇总了Python中pyaid.system.SystemUtils.SystemUtils类的典型用法代码示例。如果您正苦于以下问题:Python SystemUtils类的具体用法?Python SystemUtils怎么用?Python SystemUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SystemUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compileCoffeescriptFile
def compileCoffeescriptFile(cls, source, destFolder, minify =True):
iniDirectory = os.curdir
os.chdir(os.path.dirname(source))
cmd = cls.modifyNodeCommand([
StaticFlowEnvironment.getNodeCommandAbsPath('coffee'),
'--output', '"%s"' % FileUtils.stripTail(destFolder),
'--compile', '"%s"' % source ])
result = SystemUtils.executeCommand(cmd)
if not minify or result['code']:
os.chdir(iniDirectory)
return result
name = os.path.splitext(os.path.basename(source))[0] + '.js'
dest = FileUtils.createPath(destFolder, name, isFile=True)
tempOutPath = dest + '.tmp'
shutil.move(dest, tempOutPath)
cmd = cls.modifyNodeCommand([
StaticFlowEnvironment.getNodeCommandAbsPath('uglifyjs'),
'"%s"' % tempOutPath,
'>',
'"%s"' % dest ])
result = SystemUtils.executeCommand(cmd)
os.remove(tempOutPath)
os.chdir(iniDirectory)
return result
示例2: initialize
def initialize():
path = FileUtils.makeFolderPath(MY_DIR, 'data')
SystemUtils.remove(path)
os.makedirs(path)
tracks = DataLoadUtils.getTrackWithAnalysis()
return tracks[['uid', 'site', 'width', 'sizeClass']]
示例3: _deployResources
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
示例4: deployDebugNativeExtensions
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
示例5: initializeFolder
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
示例6: _createIcon
def _createIcon(self, binPath):
iconPath = self._getIconPath()
if not iconPath:
return iconPath
if os.path.isfile(iconPath):
return iconPath
#-------------------------------------------------------------------------------------------
# MAC ICON CREATION
# On OSX use Apple's iconutil (XCode developer tools must be installed) to create an
# icns file from the icons.iconset folder at the specified location.
if OsUtils.isMac():
targetPath = FileUtils.createPath(binPath, self.appDisplayName + '.icns', isFile=True)
result = SystemUtils.executeCommand([
'iconutil', '-c', 'icns', '-o', '"' + targetPath + '"', '"' + iconPath + '"'])
if result['code']:
return ''
return targetPath
#-------------------------------------------------------------------------------------------
# WINDOWS ICON CREATION
# On Windows use convert (ImageMagick must be installed and on the PATH) to create an
# ico file from the icons folder of png files.
result = SystemUtils.executeCommand('where convert')
if result['code']:
return ''
items = result['out'].replace('\r', '').strip().split('\n')
convertCommand = None
for item in items:
if item.find('System32') == -1:
convertCommand = item
break
if not convertCommand:
return ''
images = os.listdir(iconPath)
cmd = ['"' + convertCommand + '"']
for image in images:
if not StringUtils.ends(image, ('.png', '.jpg')):
continue
imagePath = FileUtils.createPath(iconPath, image, isFile=True)
cmd.append('"' + imagePath + '"')
if len(cmd) < 2:
return ''
targetPath = FileUtils.createPath(binPath, self.appDisplayName + '.ico', isFile=True)
cmd.append('"' + targetPath + '"')
result = SystemUtils.executeCommand(cmd)
if result['code'] or not os.path.exists(targetPath):
print 'FAILED:'
print result['command']
print result['error']
return ''
return targetPath
示例7: initialize
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
示例8: run
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)
示例9: run
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
示例10: _handleOpenDocumentsInFinder
def _handleOpenDocumentsInFinder(self):
snap = self._getLatestBuildSnapshot()
data = FlexProjectData(**snap)
path = FileUtils.createPath(
os.path.expanduser('~'), 'Library', 'Application Support',
'iPhone Simulator', '7.0.3', 'Applications', data.appId, isDir=True)
cmd = ['open', '"%s"' % path]
print 'COMMAND:', cmd
SystemUtils.executeCommand(cmd)
示例11: _createMacDmg
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
示例12: run
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
示例13: run
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
示例14: _move
def _move(self, source, destination):
if not SystemUtils.move(source, destination):
print 'FAILED TO MOVE: %s -> %s' % (source, destination)
return False
print 'MOVED: %s -> %s' % (source, destination)
return True
示例15: _download
def _download(self, url, target, httpsVerify =False, critical =None):
print('Downloading %s -> %s' % (url, target))
try:
result = SystemUtils.download(
url=url,
target=target,
httpsVerify=httpsVerify,
critical=critical,
raiseExceptions=self._raiseCommandExceptions)
except Exception as err:
print('DOWNLOAD FAILED\n', err)
if critical or (critical is None and self._raiseCommandExceptions):
raise err
else:
print(err)
return False
if not result:
if critical or (critical is None and self._raiseCommandExceptions):
raise Exception('Download failed')
else:
print('DOWNLOAD FAILED')
return False
print('SUCCESS')
return True