Skip to content

Commit

Permalink
headless = climode
Browse files Browse the repository at this point in the history
dont attempt to write with lucene
dont copy docs for openxml
dont copy samples,licenses,or node docs
  • Loading branch information
mjkkirschner committed Jun 7, 2024
1 parent 68dd564 commit d07d4e8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 40 deletions.
3 changes: 2 additions & 1 deletion src/DynamoApplications/StartupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ private static DynamoModel StartDynamoWithDefaultConfig(bool CLImode,
PathResolver = CreatePathResolver(CLImode, preloaderLocation, userDataFolder, commonDataFolder),
IsServiceMode = isServiceMode,
Preferences = PreferenceSettings.Instance,
NoNetworkMode = noNetworkMode
NoNetworkMode = noNetworkMode,
IsHeadless = CLImode
};
var model = DynamoModel.Start(config);
return model;
Expand Down
84 changes: 47 additions & 37 deletions src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ protected DynamoModel(IStartConfiguration config)
//If network traffic is disabled, analytics should also be disabled - this is already done in
//our other entry points(CLI,Sandbox etc) - but
//not all integrators will use those entry points, some may just create a DynamoModel directly.
Analytics.DisableAnalytics = NoNetworkMode || Analytics.DisableAnalytics;
Analytics.DisableAnalytics = NoNetworkMode || Analytics.DisableAnalytics || IsServiceMode;

// If user skipped analytics from assembly config, do not try to launch the analytics client
// or the feature flags client for web traffic reason.
Expand Down Expand Up @@ -798,51 +798,52 @@ protected DynamoModel(IStartConfiguration config)
var userCommonPackageFolder = pathManager.CommonPackageDirectory;
AddPackagePath(userCommonPackageFolder);

// Load Python Template
// The loading pattern is conducted in the following order
// 1) Set from DynamoSettings.XML
// 2) Set from API via the configuration file
// 3) Set from PythonTemplate.py located in 'C:\Users\USERNAME\AppData\Roaming\Dynamo\Dynamo Core\2.X'
// 4) Set from OOTB hard-coded default template

// If a custom python template path doesn't already exists in the DynamoSettings.xml
if (string.IsNullOrEmpty(PreferenceSettings.PythonTemplateFilePath) || !File.Exists(PreferenceSettings.PythonTemplateFilePath) && !IsServiceMode)
{
// To supply a custom python template host integrators should supply a 'DefaultStartConfiguration' config file
// or create a new struct that inherits from 'DefaultStartConfiguration' making sure to set the 'PythonTemplatePath'
// while passing the config to the 'DynamoModel' constructor.
if (config is DefaultStartConfiguration)
{
var configurationSettings = (DefaultStartConfiguration)config;
var templatePath = configurationSettings.PythonTemplatePath;

// If a custom python template path was set in the config apply that template
if (!string.IsNullOrEmpty(templatePath) && File.Exists(templatePath))
// Load Python Template
// The loading pattern is conducted in the following order
// 1) Set from DynamoSettings.XML
// 2) Set from API via the configuration file
// 3) Set from PythonTemplate.py located in 'C:\Users\USERNAME\AppData\Roaming\Dynamo\Dynamo Core\2.X'
// 4) Set from OOTB hard-coded default template

// If a custom python template path doesn't already exists in the DynamoSettings.xml
if (string.IsNullOrEmpty(PreferenceSettings.PythonTemplateFilePath) ||
!File.Exists(PreferenceSettings.PythonTemplateFilePath) && !IsServiceMode)
{
// To supply a custom python template host integrators should supply a 'DefaultStartConfiguration' config file
// or create a new struct that inherits from 'DefaultStartConfiguration' making sure to set the 'PythonTemplatePath'
// while passing the config to the 'DynamoModel' constructor.
if (config is DefaultStartConfiguration)
{
PreferenceSettings.PythonTemplateFilePath = templatePath;
var configurationSettings = (DefaultStartConfiguration)config;
var templatePath = configurationSettings.PythonTemplatePath;

// If a custom python template path was set in the config apply that template
if (!string.IsNullOrEmpty(templatePath) && File.Exists(templatePath))
{
PreferenceSettings.PythonTemplateFilePath = templatePath;
Logger.Log(Resources.PythonTemplateDefinedByHost + " : " + PreferenceSettings.PythonTemplateFilePath);
}

// Otherwise fallback to the default
else
{
SetDefaultPythonTemplate();
}
}

// Otherwise fallback to the default
else
{
// Fallback to the default
SetDefaultPythonTemplate();
}
}

else
{
// Fallback to the default
SetDefaultPythonTemplate();
// A custom python template path already exists in the DynamoSettings.xml
Logger.Log(Resources.PythonTemplateUserFile + " : " + PreferenceSettings.PythonTemplateFilePath);
}
}

else
{
// A custom python template path already exists in the DynamoSettings.xml
Logger.Log(Resources.PythonTemplateUserFile + " : " + PreferenceSettings.PythonTemplateFilePath);
}


pathManager.Preferences = PreferenceSettings;
PreferenceSettings.RequestUserDataFolder += pathManager.GetUserDataFolder;

Expand All @@ -861,6 +862,7 @@ protected DynamoModel(IStartConfiguration config)
extensionManager.MessageLogged += LogMessage;
var extensions = config.Extensions ?? LoadExtensions();

//don't load linter manager in service mode.
if (!IsServiceMode)
{
LinterManager = new LinterManager(this.ExtensionManager);
Expand Down Expand Up @@ -975,18 +977,26 @@ protected DynamoModel(IStartConfiguration config)
LogWarningMessageEvents.LogInfoMessage += LogInfoMessage;
DynamoConsoleLogger.LogMessageToDynamoConsole += LogMessageWrapper;
DynamoConsoleLogger.LogErrorToDynamoConsole += LogErrorMessageWrapper;
StartBackupFilesTimer();
if (!IsServiceMode)
{
StartBackupFilesTimer();
}

TraceReconciliationProcessor = this;

State = DynamoModelState.StartedUIless;
// Write index to disk only once
LuceneUtility.CommitWriterChanges();

if(!IsServiceMode)
{
// Write index to disk only once
LuceneUtility.CommitWriterChanges();
}
//Disposed writer if it is in file system mode so that the index files can be used by other processes (potentially a second Dynamo session)
if (LuceneUtility.startConfig.StorageType == LuceneSearchUtility.LuceneStorage.FILE_SYSTEM)
{
LuceneUtility.DisposeWriter();
LuceneUtility.DisposeWriter();
}


GraphChecksumDictionary = new Dictionary<string, List<string>>();

Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/DSOfficeUtilities/DSOfficeUtilities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.12.3" CopyXML="true" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.12.3" CopyXML="false" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DynamoCore\DynamoCore.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
</dependencies>
</metadata>
<files>
<file src="**" target="lib\$TargetFramework$\" exclude="en-US\fallback_docs\*;NodeHelpSharedDocs\*;Open Source Licenses\* "/>
<file src="**"
target="lib\$TargetFramework$\"
exclude="en-US\fallback_docs\*;NodeHelpSharedDocs\*;Open Source Licenses\*;samples\** "/>
</files>
</package>

0 comments on commit d07d4e8

Please sign in to comment.