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
localDatabasePath = FileUtils.createPath( rootPath, '..', 'resources', 'local', 'apps', 'Cadence', 'data', isDir=True) if not os.path.exists(localDatabasePath): print('[ERROR]: No local database resource folder exists') sys.exit(1) for filename in os.listdir(localDatabasePath): if StringUtils.begins(filename, '.'): # Skip '.' hidden files continue source = FileUtils.createPath(localDatabasePath, filename) target = FileUtils.createPath(inputPath, filename) if not SystemUtils.copy(source, target): print('[ERROR]: Failed to copy "%s" database file from local app resources' % filename) sys.exit(2) print('[COPIED]: %s -> %s' % ( filename, target.replace(FileUtils.getDirectoryOf(rootPath), '') )) #--------------------------------------------------------------------------------------------------- # OUTPUTS outputPath = FileUtils.createPath(rootPath, 'output', isDir=True) if os.path.exists(outputPath): SystemUtils.remove(outputPath) os.makedirs(outputPath)
from pyaid.json.JSON import JSON from pyaid.system.SystemUtils import SystemUtils FOLDER_NAME = 'Statistical-Results' #--------------------------------------------------------------------------------------------------- rootPath = FileUtils.getDirectoryOf(__file__) localAnalysisPath = FileUtils.makeFolderPath(rootPath, '..', 'resources', 'local', 'analysis') analysisConfigPath = FileUtils.makeFilePath(localAnalysisPath, 'analysis.json') config = JSON.fromFile(analysisConfigPath) if 'OUTPUT_PATH' not in config: rootTargetPath = localAnalysisPath else: rootTargetPath = FileUtils.cleanupPath(config['OUTPUT_PATH'], isDir=True) targetPath = FileUtils.makeFolderPath(rootTargetPath, FOLDER_NAME) if os.path.exists(targetPath): SystemUtils.remove(targetPath) outputPath = FileUtils.makeFolderPath(rootPath, 'output') if not SystemUtils.copy(outputPath, targetPath, echo=True): print('[FAILED]: Deployment') sys.exit(1) print('Deployment Complete')
def _compileImpl(self): sets = self._settings os.chdir(sets.projectPath) adtPath = self.getAirPath('bin', 'adt', isFile=True) swcRootPath = FileUtils.createPath(sets.projectPath, 'swc', isDir=True) buildPath = FileUtils.createPath(sets.projectPath, 'build', isDir=True) SystemUtils.remove(buildPath) os.makedirs(buildPath) sets.setPlatform(FlexProjectData.DEFAULT_PLATFORM) swcPath = FileUtils.createPath( swcRootPath, sets.getSetting('FOLDER'), sets.getSetting('FILENAME') + '.swc', isFile=True) cmd = [adtPath, '-package', '-target', 'ane', sets.getSetting('FILENAME') + '.ane', 'extension.xml', '-swc', swcPath] platforms = [ (FlexProjectData.DEFAULT_PLATFORM, 'default', None), (FlexProjectData.ANDROID_PLATFORM, 'Android-ARM', 'jar'), (FlexProjectData.IOS_PLATFORM, 'iPhone-ARM', 'a'), (FlexProjectData.WINDOWS_PLATFORM, 'Windows-x86', None), (FlexProjectData.MAC_PLATFORM, 'MacOS-x86', None)] platformsData = [] for platformDef in platforms: if not sets.setPlatform(platformDef[0]): continue platformFolder = sets.getSetting('FOLDER') platformBuildPath = FileUtils.createPath(buildPath, platformFolder, isDir=True, noTail=True) os.makedirs(platformBuildPath) # LIBRARY.SWF SystemUtils.copy( FileUtils.createPath( sets.projectPath, 'swc', platformFolder, 'extracted', 'library.swf', isFile=True), FileUtils.createPath(platformBuildPath, 'library.swf', isFile=True) ) # NATIVE LIBRARY nativeLibrary = sets.getSetting('NATIVE_LIBRARY') if nativeLibrary: SystemUtils.copy( FileUtils.createPath(sets.projectPath, platformFolder, nativeLibrary, isFile=True), FileUtils.createPath(buildPath, platformFolder, nativeLibrary, isFile=True)) # Android RES folder if platformDef[0] == FlexProjectData.ANDROID_PLATFORM: FileUtils.mergeCopy( FileUtils.createPath(sets.projectPath, platformFolder, 'res', isDir=True), FileUtils.createPath(buildPath, platformFolder, 'res', isDir=True)) cmd.extend(['-platform', platformDef[1]]) optionsPath = FileUtils.createPath( sets.projectPath, platformFolder, 'platform.xml', isFile=True, noTail=True) if os.path.exists(optionsPath): cmd.extend(['-platformoptions', '"%s"' % optionsPath]) cmd.extend(['-C', platformBuildPath, '.']) data = dict( nativeLibrary=nativeLibrary, definition=platformDef, folder=platformFolder, initializer=sets.getSetting('INITIALIZER'), finalizer=sets.getSetting('FINALIZER')) platformsData.append(data) self._createExtensionDescriptor(platformsData) result = self.executeCommand(cmd, 'PACKAGING ANE') # Cleanup deployed library.swf files SystemUtils.remove(buildPath) if result: self._log.write('PACKAGING FAILED') return False self._log.write('PACKAGED SUCCEEDED') return True
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)