mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:56:31 +00:00
move zmq port to config file for C# and python
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user