diff --git a/config/old_config/NEW_CONFIG_YAML_AVIRER/config.yml b/config/old_config/NEW_CONFIG_YAML_AVIRER/config.yml new file mode 100644 index 0000000..ff73d6b --- /dev/null +++ b/config/old_config/NEW_CONFIG_YAML_AVIRER/config.yml @@ -0,0 +1,67 @@ +OBSERVATORY: + _name: TNC + + UNITS: + - UNIT: + _name: TNC-Telescope + # _Site: (home, ligne d'horizon) + + MOUNT: + _name: TNC-Mount + _components: + - Mount_TM350-Astromecca_sn459.yml + + CHANNELS: + + - CHANNEL: + _name: TNC-NW + _components: + - Camera_FLIKepler4040_sn123.yml + - Focuser_Optec_sn341.yml + - Optic_TakahashiED180_sn445.yml + + - CHANNEL: + _name: TNC-NE + + - CHANNEL: + _name: TNC-SW + + - CHANNEL: + _name: TNC-SE + + COMPUTERS: + + - COMPUTER: + _name: PyROS_bdd + _file: Computer_DELL_PowerEdge7000_sn599.yml + _hostname: TNC_PC_DB + database: + name: MySQL + port: 3306 + + - COMPUTER: + _name: PyROS_principal + _file: Computer_DELL_E6430_sn000.yml + _hostname: TNC_PC1 + _role: Main + agents: + - Majordome: /home/pyros/private/majordome_perso + - Monitoring: ~ + + - COMPUTER: + _name: PyROS_spare + _file: Computer_DELL_E6430_sn001.yml + _hostname: TNC_PC2 + _role: Spare + _main: TNC_PC1 + agents: + - Majordome: ~ + - Monitoring: ~ + + - COMPUTER: + _name: PyROS_channel + _file: Computer_DELL_MiniPC_s772.yml + _hostname: TNC_MINIPC_SW + _role: Main + agents: + - Camera: ~ diff --git a/config/old_config/NEW_CONFIG_YAML_AVIRER/minimal_config.txt b/config/old_config/NEW_CONFIG_YAML_AVIRER/minimal_config.txt new file mode 100644 index 0000000..cd04adb --- /dev/null +++ b/config/old_config/NEW_CONFIG_YAML_AVIRER/minimal_config.txt @@ -0,0 +1,143 @@ +================================================ +Assemblage configuration +Commande à placer par exemple dans /etc/rc.local + +nohup python3 pyros -c assembly.xml & + +nohup python3 pyros -c pyros_plugins/assembly_TNC.xml & + +pyros_plugins est un dossier vide versionné +------------------------------------------------ + +assembly_TNC.xml + +OBSERVATORY_1: + _name: TNC + + UNITS: + UNIT_1: + _name: TNC-Telescope + # _Site: (home, ligne d'horizon) + + MOUNT: + _name: TNC-Mount + _components: + - Mount_TM350-Astromecca_sn459.yml + + CHANNELS: + + CHANNEL_1: + _name: TNC-NW + _components: + - Camera_FLIKepler4040_sn123.yml + - Focuser_Optec_sn341.yml + - Optic_TakahashiED180_sn445.yml + + CHANNEL_2: + _name: TNC-NE + + CHANNEL_3: + _name: TNC-SW + + CHANNEL_4: + _name: TNC-SE + + COMPUTERS: + + COMPUTER_1: + _name: PyROS_bdd + _file: Computer_DELL_PowerEdge7000_sn599.yml + _hostname: TNC_PC_DB + database: + name: MySQL + port: 3306 + + COMPUTER_2: + _name: PyROS_principal + _file: Computer_DELL_E6430_sn000.yml + _hostname: TNC_PC1 + _role: Main + agents: + - Majordome: /home/pyros/private/majordome_perso + - Monitoring: ~ + + COMPUTER_3: + _name: PyROS_spare + _file: Computer_DELL_E6430_sn001.yml + _hostname: TNC_PC2 + _role: Spare + _main: TNC_PC1 + agents: + - Majordome: ~ + - Monitoring: ~ + + COMPUTER_4: PyROS_channel + _file: Computer_DELL_MiniPC_s772.yml + _hostname: TNC_MINIPC_SW + _role: Main + agents: + - Camera: ~ + + Reste à décrire, UPS, router, VPN (dans monitoring ?) + +================================================ +LISTE DE HARDWARE Disponible dans l'observatoire +------------------------------------------------ + +Computer_DELL_MiniPC_s772.xml + _serialNumber + _tag_dell + _macaddress: 23:e5:67:ee:a2:11 + +Computer_DELL_PowerEdge7000_sn599.xml + _serialNumber + _tag_dell + _macaddress: 23:e5:67:ee:a2:34 + +Computer_DELL_E6430_sn000.xml + _serialNumber + _tag_dell + _macaddress: 23:e5:67:ee:a2:33 + +Computer_DELL_E6430_sn001.xml + _serialNumber + _tag_dell + _macaddress: 23:e5:67:ee:a2:35 + +Mount_TM350-Astromecca_sn459.xml + _serialNumber + _communication_transport: Serial + _communication_langage: MCS + MountPointing + Type: HADEC + +Camera_FLIKepler4040_sn123.xml + _serialNumber + _communication_transport: USB + _communication_langage: FLIPro library + _input: photons + _output: image + DetectorSensor + DetectorShutter + DetectorTimer + +Focuser_Optec_sn341.xml + _SerialNumber + DetectorFocus + +Optic_TakahashiED180_sn445.xml + _SerialNumber + Optic + +Filterwheel_FLI_sn57345.xml + _SerialNumber + FilterSelector + + + + + + + + + \ No newline at end of file diff --git a/config/old_config/NEW_CONFIG_YAML_AVIRER/schema.yaml b/config/old_config/NEW_CONFIG_YAML_AVIRER/schema.yaml new file mode 100644 index 0000000..74be066 --- /dev/null +++ b/config/old_config/NEW_CONFIG_YAML_AVIRER/schema.yaml @@ -0,0 +1,108 @@ +schema;schema_UNIT: + type: map + required: True + mapping: + _name: + type: str + required: True + MOUNT: + include: schema_MOUNT + CHANNELS: + include: schema_CHANNELS + COMPUTERS: + include: schema_COMPUTERS + +schema;schema_MOUNT: + type: map + mapping: + _name: + type: str + required: True + _components: + type: seq + required: True + sequence: + - type: str + +schema;schema_CHANNEL: + type: map + mapping: + _name: + type: str + required: True + _components: + type: seq + required: False + sequence: + - type: str + +schema;schema_COMPUTER: + type: map + mapping: + _name: + type: str + required: True + _file: + type: str + required: True + _hostname: + type: str + required: False + _role: + type: str + required: False + database: + type: map + required: False + mapping: + name: + type: str + port: + type: int + _main: + type: str + required: False + agents: + type: any + required: False + +schema;schema_COMPUTERS: +# TODO: can be improved if we switch to sequence -> we can have any number of computers + type: seq + sequence: + - type: map + mapping: + COMPUTER: + include: schema_COMPUTER + +schema;schema_UNITS: + type: seq + required: True + sequence: + - type: map + mapping : + UNIT: + include: schema_UNIT + + + +schema;schema_CHANNELS: + type: seq + required: True + sequence: + - type : map + mapping: + CHANNEL: + include: schema_CHANNEL + + +type: map +mapping: + OBSERVATORY: + type: map + required: True + mapping: + _name: + type: str + UNITS: + include: schema_UNITS \ No newline at end of file diff --git a/config/old_config/NEW_CONFIG_YAML_AVIRER/test_yaml.py b/config/old_config/NEW_CONFIG_YAML_AVIRER/test_yaml.py new file mode 100644 index 0000000..7f8ac99 --- /dev/null +++ b/config/old_config/NEW_CONFIG_YAML_AVIRER/test_yaml.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +from pykwalify.core import Core +from pykwalify.errors import SchemaError + +""" +Read yaml file : +import yaml +with open("C:/srv/develop/pyros/config/config.yml", 'r') as stream: + try: + a = yaml.safe_load(stream) + print(a) + except yaml.YAMLError as exc: + print(exc) + +# Write YAML file +with open('C:/srv/develop/pyros/config/config2.yml', 'w', encoding='utf8') as outfile: + yaml.dump(a, outfile, default_flow_style=False, allow_unicode=True) +""" + +""" +import yaml +with open("config.yml", 'r') as stream: + try: + a = yaml.safe_load(stream) + print(a) + except yaml.YAMLError as exc: + print(exc) + + """ + +def check_and_return_config(yaml_file:str,schema_file:str)->dict: + """ + Check if yaml_file is valid for the schema_file + + Args: + yaml_file (str): Path to the config_file to be validated + schema_file (str): Path to the schema file + + Returns: + dict: Dictionnary of the config file (with values) + """ + try: + + c = Core(source_file=yaml_file, schema_files=[schema_file]) + return c.validate(raise_exception=True) + except SchemaError as error: + #TODO : find a way to retrieve message with path to error + print(error.path) + + +print(check_and_return_config("config.yml","schema.yaml")) \ No newline at end of file diff --git a/config/old_config/config.yml b/config/old_config/config.yml deleted file mode 100644 index ff73d6b..0000000 --- a/config/old_config/config.yml +++ /dev/null @@ -1,67 +0,0 @@ -OBSERVATORY: - _name: TNC - - UNITS: - - UNIT: - _name: TNC-Telescope - # _Site: (home, ligne d'horizon) - - MOUNT: - _name: TNC-Mount - _components: - - Mount_TM350-Astromecca_sn459.yml - - CHANNELS: - - - CHANNEL: - _name: TNC-NW - _components: - - Camera_FLIKepler4040_sn123.yml - - Focuser_Optec_sn341.yml - - Optic_TakahashiED180_sn445.yml - - - CHANNEL: - _name: TNC-NE - - - CHANNEL: - _name: TNC-SW - - - CHANNEL: - _name: TNC-SE - - COMPUTERS: - - - COMPUTER: - _name: PyROS_bdd - _file: Computer_DELL_PowerEdge7000_sn599.yml - _hostname: TNC_PC_DB - database: - name: MySQL - port: 3306 - - - COMPUTER: - _name: PyROS_principal - _file: Computer_DELL_E6430_sn000.yml - _hostname: TNC_PC1 - _role: Main - agents: - - Majordome: /home/pyros/private/majordome_perso - - Monitoring: ~ - - - COMPUTER: - _name: PyROS_spare - _file: Computer_DELL_E6430_sn001.yml - _hostname: TNC_PC2 - _role: Spare - _main: TNC_PC1 - agents: - - Majordome: ~ - - Monitoring: ~ - - - COMPUTER: - _name: PyROS_channel - _file: Computer_DELL_MiniPC_s772.yml - _hostname: TNC_MINIPC_SW - _role: Main - agents: - - Camera: ~ diff --git a/config/old_config/minimal_config.txt b/config/old_config/minimal_config.txt deleted file mode 100644 index cd04adb..0000000 --- a/config/old_config/minimal_config.txt +++ /dev/null @@ -1,143 +0,0 @@ -================================================ -Assemblage configuration -Commande à placer par exemple dans /etc/rc.local - -nohup python3 pyros -c assembly.xml & - -nohup python3 pyros -c pyros_plugins/assembly_TNC.xml & - -pyros_plugins est un dossier vide versionné ------------------------------------------------- - -assembly_TNC.xml - -OBSERVATORY_1: - _name: TNC - - UNITS: - UNIT_1: - _name: TNC-Telescope - # _Site: (home, ligne d'horizon) - - MOUNT: - _name: TNC-Mount - _components: - - Mount_TM350-Astromecca_sn459.yml - - CHANNELS: - - CHANNEL_1: - _name: TNC-NW - _components: - - Camera_FLIKepler4040_sn123.yml - - Focuser_Optec_sn341.yml - - Optic_TakahashiED180_sn445.yml - - CHANNEL_2: - _name: TNC-NE - - CHANNEL_3: - _name: TNC-SW - - CHANNEL_4: - _name: TNC-SE - - COMPUTERS: - - COMPUTER_1: - _name: PyROS_bdd - _file: Computer_DELL_PowerEdge7000_sn599.yml - _hostname: TNC_PC_DB - database: - name: MySQL - port: 3306 - - COMPUTER_2: - _name: PyROS_principal - _file: Computer_DELL_E6430_sn000.yml - _hostname: TNC_PC1 - _role: Main - agents: - - Majordome: /home/pyros/private/majordome_perso - - Monitoring: ~ - - COMPUTER_3: - _name: PyROS_spare - _file: Computer_DELL_E6430_sn001.yml - _hostname: TNC_PC2 - _role: Spare - _main: TNC_PC1 - agents: - - Majordome: ~ - - Monitoring: ~ - - COMPUTER_4: PyROS_channel - _file: Computer_DELL_MiniPC_s772.yml - _hostname: TNC_MINIPC_SW - _role: Main - agents: - - Camera: ~ - - Reste à décrire, UPS, router, VPN (dans monitoring ?) - -================================================ -LISTE DE HARDWARE Disponible dans l'observatoire ------------------------------------------------- - -Computer_DELL_MiniPC_s772.xml - _serialNumber - _tag_dell - _macaddress: 23:e5:67:ee:a2:11 - -Computer_DELL_PowerEdge7000_sn599.xml - _serialNumber - _tag_dell - _macaddress: 23:e5:67:ee:a2:34 - -Computer_DELL_E6430_sn000.xml - _serialNumber - _tag_dell - _macaddress: 23:e5:67:ee:a2:33 - -Computer_DELL_E6430_sn001.xml - _serialNumber - _tag_dell - _macaddress: 23:e5:67:ee:a2:35 - -Mount_TM350-Astromecca_sn459.xml - _serialNumber - _communication_transport: Serial - _communication_langage: MCS - MountPointing - Type: HADEC - -Camera_FLIKepler4040_sn123.xml - _serialNumber - _communication_transport: USB - _communication_langage: FLIPro library - _input: photons - _output: image - DetectorSensor - DetectorShutter - DetectorTimer - -Focuser_Optec_sn341.xml - _SerialNumber - DetectorFocus - -Optic_TakahashiED180_sn445.xml - _SerialNumber - Optic - -Filterwheel_FLI_sn57345.xml - _SerialNumber - FilterSelector - - - - - - - - - \ No newline at end of file diff --git a/config/old_config/schema.yaml b/config/old_config/schema.yaml deleted file mode 100644 index 74be066..0000000 --- a/config/old_config/schema.yaml +++ /dev/null @@ -1,108 +0,0 @@ -schema;schema_UNIT: - type: map - required: True - mapping: - _name: - type: str - required: True - MOUNT: - include: schema_MOUNT - CHANNELS: - include: schema_CHANNELS - COMPUTERS: - include: schema_COMPUTERS - -schema;schema_MOUNT: - type: map - mapping: - _name: - type: str - required: True - _components: - type: seq - required: True - sequence: - - type: str - -schema;schema_CHANNEL: - type: map - mapping: - _name: - type: str - required: True - _components: - type: seq - required: False - sequence: - - type: str - -schema;schema_COMPUTER: - type: map - mapping: - _name: - type: str - required: True - _file: - type: str - required: True - _hostname: - type: str - required: False - _role: - type: str - required: False - database: - type: map - required: False - mapping: - name: - type: str - port: - type: int - _main: - type: str - required: False - agents: - type: any - required: False - -schema;schema_COMPUTERS: -# TODO: can be improved if we switch to sequence -> we can have any number of computers - type: seq - sequence: - - type: map - mapping: - COMPUTER: - include: schema_COMPUTER - -schema;schema_UNITS: - type: seq - required: True - sequence: - - type: map - mapping : - UNIT: - include: schema_UNIT - - - -schema;schema_CHANNELS: - type: seq - required: True - sequence: - - type : map - mapping: - CHANNEL: - include: schema_CHANNEL - - -type: map -mapping: - OBSERVATORY: - type: map - required: True - mapping: - _name: - type: str - UNITS: - include: schema_UNITS \ No newline at end of file diff --git a/config/old_config/test_yaml.py b/config/old_config/test_yaml.py deleted file mode 100644 index 7f8ac99..0000000 --- a/config/old_config/test_yaml.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- - -from pykwalify.core import Core -from pykwalify.errors import SchemaError - -""" -Read yaml file : -import yaml -with open("C:/srv/develop/pyros/config/config.yml", 'r') as stream: - try: - a = yaml.safe_load(stream) - print(a) - except yaml.YAMLError as exc: - print(exc) - -# Write YAML file -with open('C:/srv/develop/pyros/config/config2.yml', 'w', encoding='utf8') as outfile: - yaml.dump(a, outfile, default_flow_style=False, allow_unicode=True) -""" - -""" -import yaml -with open("config.yml", 'r') as stream: - try: - a = yaml.safe_load(stream) - print(a) - except yaml.YAMLError as exc: - print(exc) - - """ - -def check_and_return_config(yaml_file:str,schema_file:str)->dict: - """ - Check if yaml_file is valid for the schema_file - - Args: - yaml_file (str): Path to the config_file to be validated - schema_file (str): Path to the schema file - - Returns: - dict: Dictionnary of the config file (with values) - """ - try: - - c = Core(source_file=yaml_file, schema_files=[schema_file]) - return c.validate(raise_exception=True) - except SchemaError as error: - #TODO : find a way to retrieve message with path to error - print(error.path) - - -print(check_and_return_config("config.yml","schema.yaml")) \ No newline at end of file -- libgit2 0.21.2