def run(self, project, platform, requestId, param1, param2): self._log.debug("Started EditorApi with arguments: {0}".format(" ".join(sys.argv[1:]))) self._project = project self._platform = platform self._requestId = requestId self._param1 = param1 self._param2 = param2 succeeded = True # This is repeated in __main__ but this is better because # it will properly log detailed errors to the file log instead of to the console try: self._runInternal() except Exception as e: sys.stderr.write(str(e)) self._log.error(str(e)) if not MiscUtil.isRunningAsExe(): self._log.error('\n' + traceback.format_exc()) succeeded = False if not succeeded: sys.exit(1)
def run(self, project, platform, requestId, param1, param2): self._log.debug("Started EditorApi with arguments: {0}".format( " ".join(sys.argv[1:]))) self._project = project self._platform = platform self._requestId = requestId self._param1 = param1 self._param2 = param2 succeeded = True # This is repeated in __main__ but this is better because # it will properly log detailed errors to the file log instead of to the console try: self._runInternal() except Exception as e: sys.stderr.write(str(e)) self._log.error(str(e)) if not MiscUtil.isRunningAsExe(): self._log.error('\n' + traceback.format_exc()) succeeded = False if not succeeded: sys.exit(1)
def installPlugins(): if MiscUtil.isRunningAsExe(): # Must be running from source for plugins return import importlib pluginDir = getPluginDirPath() for filePath in findFilesByPattern(pluginDir, '*.py'): basePath = filePath[len(pluginDir) + 1:] basePath = os.path.splitext(basePath)[0] basePath = basePath.replace('\\', '.') importlib.import_module('plugins.' + basePath)
def _updateDirLinksForSchema(self, schema): self._removePackageJunctions() self._sys.deleteDirectoryIfExists('[PluginsDir]/Projeny') if self._config.getBool('LinkToProjenyEditorDir') and not MiscUtil.isRunningAsExe(): self._junctionHelper.makeJunction('[ProjenyDir]/UnityPlugin/Projeny', '[PluginsDir]/Projeny/Editor/Source') else: dllOutPath = '[PluginsDir]/Projeny/Editor/Projeny.dll' self._sys.copyFile('[ProjenyUnityEditorDllPath]', dllOutPath) self._sys.copyFile('[ProjenyUnityEditorDllMetaFilePath]', dllOutPath + '.meta') self._sys.copyFile('[YamlDotNetDllPath]', '[PluginsDir]/Projeny/Editor/YamlDotNet.dll') assetsOutPath = '[PluginsDir]/Projeny/Editor/Assets' self._sys.copyDirectory('[ProjenyUnityEditorAssetsDirPath]', assetsOutPath) settingsFileOutPath = os.path.join(assetsOutPath, 'Resources/Projeny/PmSettings.asset') self._sys.writeFileAsText(settingsFileOutPath, self._sys.readFileAsText(settingsFileOutPath).replace( 'm_Script: {fileID: 11500000, guid: 01fe9b81f68762b438dd4eecbcfe2900, type: 3}', 'm_Script: {fileID: 1582608718, guid: b7b2ba04b543d234aa4225d91c60af2b, type: 3}')) self._createSwitchProjectMenuScript(schema.name, '[PluginsDir]/Projeny/Editor/ProjenyChangeProjectMenu.cs') self._createPlaceholderCsFile('[PluginsDir]/Projeny/Placeholder.cs') self._createPlaceholderCsFile('[PluginsDir]/Projeny/Editor/Placeholder.cs') for packageInfo in schema.packages.values(): self._log.debug('Processing package "{0}"'.format(packageInfo.name)) sourceDir = self._varMgr.expandPath('[UnityPackagesDir]/{0}'.format(packageInfo.name)) self._validateDirForFolderType(packageInfo, sourceDir) assertThat(os.path.exists(sourceDir), "Could not find package with name '{0}' while processing schema '{1}'. See build log for full object graph to see where it is referenced".format(packageInfo.name, schema.name)) outputPackageDir = self._varMgr.expandPath(packageInfo.outputDirVar) linkDir = os.path.join(outputPackageDir, packageInfo.name) assertThat(not os.path.exists(linkDir), "Did not expect this path to exist: '{0}'".format(linkDir)) self._junctionHelper.makeJunction(sourceDir, linkDir)
def installBindings(mainConfigPath = None): projenyDir = getProjenyDir() projenyConfigPath = os.path.join(projenyDir, ConfigFileName) # Put the standard config first so it can be over-ridden by user settings configPaths = [projenyConfigPath] if mainConfigPath: assertThat(os.path.isfile(mainConfigPath), 'Could not find file at "{0}"', mainConfigPath) configPaths += [mainConfigPath] configPaths += getExtraUserConfigPaths() Container.bind('Config').toSingle(Config, loadYamlFilesThatExist(*configPaths)) initialVars = { 'ProjenyDir': projenyDir, } if mainConfigPath: initialVars['ConfigDir'] = os.path.dirname(mainConfigPath) if not MiscUtil.isRunningAsExe(): initialVars['PythonPluginDir'] = getPluginDirPath() Container.bind('VarManager').toSingle(VarManager, initialVars) Container.bind('SystemHelper').toSingle(SystemHelper) Container.bind('Logger').toSingle(Logger) Container.bind('UnityHelper').toSingle(UnityHelper) Container.bind('ScriptRunner').toSingle(ScriptRunner) Container.bind('PackageManager').toSingle(PackageManager) Container.bind('ProcessRunner').toSingle(ProcessRunner) Container.bind('JunctionHelper').toSingle(JunctionHelper) Container.bind('VisualStudioSolutionGenerator').toSingle(VisualStudioSolutionGenerator) Container.bind('VisualStudioHelper').toSingle(VisualStudioHelper) Container.bind('ProjectSchemaLoader').toSingle(ProjectSchemaLoader) Container.bind('CommonSettings').toSingle(CommonSettings) Container.bind('UnityPackageExtractor').toSingle(UnityPackageExtractor) Container.bind('ZipHelper').toSingle(ZipHelper) Container.bind('UnityPackageAnalyzer').toSingle(UnityPackageAnalyzer) Container.bind('ReleaseSourceManager').toSingle(ReleaseSourceManager)
installBindings(tryGetMainConfigPath(args)) installPlugins() PrjRunner().run(args) if __name__ == '__main__': if (sys.version_info < (3, 0)): print('Wrong version of python! Install python 3 and try again') sys.exit(2) succeeded = True try: main() except KeyboardInterrupt as e: print('Operation aborted by user by hitting CTRL+C') succeeded = False except Exception as e: sys.stderr.write(str(e)) if not MiscUtil.isRunningAsExe(): sys.stderr.write('\n' + traceback.format_exc()) succeeded = False if not succeeded: sys.exit(1)