Skip to content

Commit

Permalink
Merge pull request #176 from epics-containers/add-env
Browse files Browse the repository at this point in the history
Add get environment to __utils__ , fix #173
  • Loading branch information
gilesknap authored Feb 2, 2024
2 parents 999c694 + 44d4a62 commit 5a66d6c
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 16 deletions.
6 changes: 0 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.languageServer": "Pylance",
"editor.formatOnSave": true,
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "never",
"source.organizeImports.ruff": "explicit",
"source.black": "explicit"
}
},
"workbench.colorCustomizations": {
"activityBar.background": "#01333D",
"titleBar.activeBackground": "#014756",
"titleBar.activeForeground": "#F1FDFF"
}
}
1 change: 1 addition & 0 deletions src/ibek/dev_cmds/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def instance(
file_okay=False,
exists=True,
autocompletion=lambda: [], # Forces path autocompletion
resolve_path=True,
),
):
"""
Expand Down
1 change: 1 addition & 0 deletions src/ibek/gen_scripts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions for building the db and boot scripts
"""

import logging
import re
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions src/ibek/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Functions for generating an IocInstance derived class from a
support module definition YAML file
"""

from __future__ import annotations

import builtins
Expand Down
1 change: 1 addition & 0 deletions src/ibek/support.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The Support Class represents a deserialized <MODULE_NAME>.ibek.support.yaml file.
"""

from __future__ import annotations

import json
Expand Down
7 changes: 7 additions & 0 deletions src/ibek/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
we pass a single instance of this class into all Jinja contexts.
"""

import os
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict
Expand Down Expand Up @@ -62,6 +63,12 @@ def set_ioc_name(self: "Utils", name: str):
"""
self.ioc_name = name

def get_env(self, key: str) -> str:
"""
Get an environment variable
"""
return os.environ.get(key, "")

def set_var(self, key: str, value: Any):
"""create a global variable for our jinja context"""
self.variables[key] = value
Expand Down
10 changes: 5 additions & 5 deletions tests/samples/outputs/index.bob
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<name>Display</name>
<x>0</x>
<y>0</y>
<width>273</width>
<width>388</width>
<height>55</height>
<grid_step_x>4</grid_step_x>
<grid_step_y>4</grid_step_y>
Expand All @@ -12,7 +12,7 @@
<text>ibek-mo-ioc-01 - Index</text>
<x use_class="true">0</x>
<y use_class="true">0</y>
<width>273</width>
<width>388</width>
<height>25</height>
<font use_class="true">
<font name="Header 1" family="Liberation Sans" style="BOLD" size="22.0">
Expand All @@ -30,7 +30,7 @@
<text>Simple</text>
<x>23</x>
<y>30</y>
<width>115</width>
<width>150</width>
<height>20</height>
</widget>
<widget type="action_button" version="3.0.0">
Expand All @@ -46,9 +46,9 @@
</action>
</actions>
<text>Simple</text>
<x>143</x>
<x>178</x>
<y>30</y>
<width>125</width>
<width>205</width>
<height>20</height>
<tooltip>$(actions)</tooltip>
</widget>
Expand Down
10 changes: 5 additions & 5 deletions tests/samples/outputs/simple.pvi.bob
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<name>Display</name>
<x>0</x>
<y>0</y>
<width>273</width>
<width>388</width>
<height>55</height>
<grid_step_x>4</grid_step_x>
<grid_step_y>4</grid_step_y>
Expand All @@ -12,7 +12,7 @@
<text>Simple Device - ${prefix}</text>
<x use_class="true">0</x>
<y use_class="true">0</y>
<width>273</width>
<width>388</width>
<height>25</height>
<font use_class="true">
<font name="Header 1" family="Liberation Sans" style="BOLD" size="22.0">
Expand All @@ -30,15 +30,15 @@
<text>Simple PV</text>
<x>23</x>
<y>30</y>
<width>115</width>
<width>150</width>
<height>20</height>
</widget>
<widget type="textupdate" version="2.0.0">
<name>TextUpdate</name>
<pv_name>${prefix}Simple</pv_name>
<x>143</x>
<x>178</x>
<y>30</y>
<width>125</width>
<width>205</width>
<height>20</height>
<font>
<font name="Default Bold" family="Liberation Sans" style="BOLD" size="14.0">
Expand Down
1 change: 1 addition & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
System tests that run the CLI commands and compare the output to expected
results.
"""

import json
import subprocess
import sys
Expand Down
1 change: 1 addition & 0 deletions tests/test_error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests to verify that the error handling works as expected.
"""

from pathlib import Path

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Unit tests for the rendering of scripts and database entries from generated
Entity classes
"""

from typing import Literal

from ibek.ioc import IOC, clear_entity_model_ids
Expand Down
1 change: 1 addition & 0 deletions tests/test_support.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for the support subcommand"""

from pathlib import Path

from ibek.support_cmds.files import symlink_files
Expand Down

0 comments on commit 5a66d6c

Please sign in to comment.