本文整理汇总了Python中pyaid.system.SystemUtils.SystemUtils类的典型用法代码示例。如果您正苦于以下问题:Python SystemUtils类的具体用法?Python SystemUtils怎么用?Python SystemUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SystemUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:sernst,项目名称:StaticFlow,代码行数:30,代码来源:SiteProcessUtils.py
示例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']]
开发者ID:sernst,项目名称:Cadence,代码行数:7,代码来源:validation_generate.py
示例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
开发者ID:sernst,项目名称:PyGlass,代码行数:27,代码来源:PyGlassApplication.py
示例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
开发者ID:sernst,项目名称:CompilerDeck,代码行数:29,代码来源:AirUtils.py
示例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
开发者ID:sernst,项目名称:Cadence,代码行数:8,代码来源:AnalysisStage.py
示例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
开发者ID:hannahp,项目名称:PyGlass,代码行数:57,代码来源:PyGlassApplicationCompiler.py
示例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
开发者ID:sernst,项目名称:Cadence,代码行数:9,代码来源:__init__.py
示例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)
开发者ID:sernst,项目名称:Cadence,代码行数:56,代码来源:AnalyzerBase.py
示例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
开发者ID:sernst,项目名称:PyGlass,代码行数:56,代码来源:PyGlassApplicationCompiler.py
示例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)
开发者ID:sernst,项目名称:CompilerDeck,代码行数:11,代码来源:DeckCompileWidget.py
示例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
开发者ID:hannahp,项目名称:PyGlass,代码行数:32,代码来源:PyGlassApplicationCompiler.py
示例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
开发者ID:hannahp,项目名称:PyGlass,代码行数:50,代码来源:PyGlassApplicationCompiler.py
示例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
开发者ID:sernst,项目名称:StaticFlow,代码行数:16,代码来源:Site.py
示例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
开发者ID:hannahp,项目名称:PyAid,代码行数:7,代码来源:SystemCommandIssuer.py
示例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
开发者ID:sernst,项目名称:PyAid,代码行数:26,代码来源:SystemCommandIssuer.py
示例16: executeCommand
def executeCommand(self, cmd, messageHeader =None, message =None):
if isinstance(cmd, list):
cmd = ' '.join(cmd)
if messageHeader:
self.printCommand(message if message else cmd, messageHeader)
result = SystemUtils.executeCommand(cmd)
self._commandBuffer.append([result['error'], result['out']])
out = ''
if result['out']:
out += '<br /><br />' \
+ '<div style="color:#999999"><span style="font-size:16px">RESULTS:</span>\n' \
+ 50*'- ' + '\n' + str(result['out']) + '</div>'
if result['error']:
out += '<br /><br />' \
+ '<div style="color:#993333"><span style="font-size:16px">ERRORS:</span>\n' \
+ 50*'- ' + '\n' + str(result['error']) + '</div>'
if out:
self._log.write(out + '\n\n')
self._checkOutput(result['code'], result['out'], result['error'])
if result['code']:
return result['code']
return 0
开发者ID:sernst,项目名称:CompilerDeck,代码行数:27,代码来源:SystemCompiler.py
示例17: save
def save(self, toPDF=True):
""" Writes the current _drawing in SVG format to the file specified at initialization. If
one wishes to have create a PDF file (same file name as used for the .SVG, but with
suffix .PDF), then call with toPDF True). """
if not self.siteMapReady:
return
# Make sure the directory where the file will be saved exists before saving
FileUtils.getDirectoryOf(self._drawing.filename, createIfMissing=True)
self._drawing.save()
# we're done if no PDF version is also required
if not toPDF:
return
# strip any extension off of the file name
basicName = self.fileName.split(".")[0]
# load up the command
cmd = ["/Applications/Inkscape.app/Contents/Resources/bin/inkscape", "-f", None, "-A", None]
cmd[2] = basicName + ".svg"
cmd[4] = basicName + ".pdf"
# and execute it
response = SystemUtils.executeCommand(cmd)
if response["error"]:
print("response[error]=%s" % response["error"])
开发者ID:sernst,项目名称:Cadence,代码行数:29,代码来源:CadenceDrawing.py
示例18: _createEngineCss
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
开发者ID:sernst,项目名称:StaticFlow,代码行数:16,代码来源:WebResourcePackager.py
示例19: _copy
def _copy(self, source, destination):
result = SystemUtils.copy(source, destination)
if not result:
print 'FAILED TO COPY: %s -> %s' % (source, destination)
return False
print 'COPIED: %s -> %s' % (source, destination)
return True
开发者ID:hannahp,项目名称:PyAid,代码行数:8,代码来源:SystemCommandIssuer.py
示例20: startServer
def startServer(cls, path):
""" RUN NGINX
NGinx is started as an active process.
"""
cls.initializeEnvironment(path)
os.chdir(path)
print 'STARTING SERVER AT:', path
return SystemUtils.executeCommand('nginx')
开发者ID:sernst,项目名称:NGinxWinManager,代码行数:9,代码来源:NGinxRunOps.py
注:本文中的pyaid.system.SystemUtils.SystemUtils类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论