-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Системная информация. Часть1. #233
base: develop
Are you sure you want to change the base?
Conversation
# Conflicts: # engine/src/main/java/com/github/otymko/jos/runtime/context/type/StandardTypeInitializer.java # engine/src/main/java/com/github/otymko/jos/runtime/context/type/TypeManager.java
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, начало положено, спасибо!
@GlobalContextClass | ||
public class SystemEnvironmentGlobalContext implements AttachableContext { | ||
public static final ContextInfo INFO = ContextInfo.createByClass(SystemEnvironmentGlobalContext.class); | ||
private static final Map<String, String> environmentVariables = getEnvironmentVariablesSnapshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, мне не очень нравится текущее решение с static field, т.к. при многократном использовании контекста будет будут просачиваться значения из других. Давай пока сделаем синглтон + todo на исправление с DI, потом переделаем.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужен какой-то стейт на процесс выполнения (
|
||
@ContextMethod(name = "УстановитьПеременнуюСреды", alias = "SetEnvironmentVariable") | ||
public void setEnvironmentVariable(String name, String value) { | ||
environmentVariables.put(name, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, как это работает дальше? Ну изменили мы у себя кеш, а на систему как это влияет?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@otymko На систему никак не влияет.
В рамках работы движка скрипты будут получать значение, установленное внутри скрипта(движка).
При запуске процесса из скрипта в него будем передавать переменные отсюда.
Ну либо пилить нативную либу. Других вариантов гугель не предложил, так что тут либо костыли, либо C++
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, а в оскрипте как?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@otymko в дотнете оно из коробки умеет ставить переменные среды в ОС
https://learn.microsoft.com/ru-ru/dotnet/api/system.environment.setenvironmentvariable?view=net-7.0
import java.util.TreeMap; | ||
|
||
@GlobalContextClass | ||
public class SystemEnvironmentGlobalContext implements AttachableContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, добавь, плиз, jdoc
engine/src/main/java/com/github/otymko/jos/runtime/context/type/env/PlatformType.java
Show resolved
Hide resolved
*/ | ||
public static PlatformType parse(String osName, boolean is64) { | ||
var prepared = osName.toUpperCase(); | ||
if (prepared.contains("WINDOWS")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, узоры: скобочки { }
*/ | ||
@ContextProperty(name = "КоличествоПроцессоров", alias = "ProcessorCount") | ||
public int getProcessorCount() { | ||
return Runtime.getRuntime().availableProcessors(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, кстати, в v8 возвращается количество физический или логических процессоров?
*/ | ||
@ContextProperty(name = "ВремяРаботыСМоментаЗагрузки", alias = "TickCount") | ||
public long getTickCount() { | ||
return System.currentTimeMillis(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, System.currentTimeMillis возвращает не ВремяРаботыСМоментаЗагрузки. Смотри как в https://github.com/oshi/oshi работает getSystemUptime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно здесь закинуть нон-саппортед, а а отдельной задаче реализовать.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@otymko getSystemUptime - там ад, если честно. Куча if (os1) get_os1(); if (os2) get_os2();
import com.github.otymko.jos.runtime.context.TestScript; | ||
|
||
@TestScript(script = "src/test/resources/tests/SystemInfo.os") | ||
public class V8SystemInfoTest extends BaseScriptTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, public можно убрать
|
||
Процедура ТестДолжен_ПолучитьВремяРаботыСМоментаЗагрузки() Экспорт | ||
Си = Новый СистемнаяИнформация(); | ||
юТест.ПроверитьБольше(Си.ВремяРаботыСМоментаЗагрузки,0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmpas, плохой тестовый кейс (
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@otymko принял... придумаем лучше...
No description provided.