move zmq port to config file for C# and python

This commit is contained in:
Alex Bezdieniezhnykh
2025-02-16 16:35:52 +02:00
parent 0d6ea4264f
commit 2ecbc9bfd4
17 changed files with 80 additions and 180 deletions
+11 -8
View File
@@ -33,7 +33,7 @@ public partial class App
private IMediator _mediator = null!;
private FormState _formState = null!;
private readonly PythonResourceLoader _resourceLoader = new();
private PythonResourceLoader _resourceLoader = null!;
private Stream _securedConfig = null!;
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
@@ -54,23 +54,25 @@ public partial class App
"Azaion.Dataset"
];
private static ApiConfig ReadConfig()
private static PythonConfig ReadPythonConfig()
{
try
{
if (!File.Exists(SecurityConstants.CONFIG_PATH))
throw new FileNotFoundException(SecurityConstants.CONFIG_PATH);
var configStr = File.ReadAllText(SecurityConstants.CONFIG_PATH);
return JsonConvert.DeserializeObject<SecureAppConfig>(configStr)!.ApiConfig;
return JsonConvert.DeserializeObject<SecureAppConfig>(configStr)!.PythonConfig;
}
catch (Exception e)
{
Console.WriteLine(e);
return new ApiConfig
return new PythonConfig
{
Url = SecurityConstants.DEFAULT_API_URL,
RetryCount = SecurityConstants.DEFAULT_API_RETRY_COUNT,
TimeoutSeconds = SecurityConstants.DEFAULT_API_TIMEOUT_SECONDS,
ZeroMqHost = SecurityConstants.DEFAULT_ZMQ_HOST,
ZeroMqPort = SecurityConstants.DEFAULT_ZMQ_PORT,
OneTryTimeoutSeconds = SecurityConstants.DEFAULT_TIMEOUT_SECONDS,
RetryCount = SecurityConstants.DEFAULT_RETRY_COUNT,
ResourcesFolder = ""
};
}
@@ -80,9 +82,10 @@ public partial class App
{
new ConfigUpdater().CheckConfig();
var login = new Login();
var config = ReadPythonConfig();
_resourceLoader = new PythonResourceLoader(config);
login.CredentialsEntered += (_, credentials) =>
{
var config = ReadConfig();
credentials.Folder = config.ResourcesFolder;
_resourceLoader.Login(credentials);
_securedConfig = _resourceLoader.LoadFileFromPython("secured-config.json");