-
Couldn't load subscription status.
- Fork 0
start splitting up into server_common[epics] #11
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
Draft
rerpha
wants to merge
2
commits into
main
Choose a base branch
from
add_dep_groups
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,7 @@ | ||
| import json | ||
| import os | ||
| import sys | ||
| from typing import Dict | ||
|
|
||
| from genie_python import genie as g | ||
| from genie_python.mysql_abstraction_layer import SQLAbstraction | ||
|
|
||
| from server_common.ioc_data_source import IocDataSource | ||
| from server_common.utilities import SEVERITY, print_and_log | ||
|
|
||
|
|
||
| def register_ioc_start( | ||
| ioc_name: str, | ||
| pv_database: Dict[str, Dict[str, str]] = None, | ||
| prefix: str | None = None, | ||
| ) -> None: | ||
| """ | ||
| A helper function to register the start of an ioc. | ||
| Args: | ||
| ioc_name: name of the ioc to start | ||
| pv_database: doctionary of pvs in the iov | ||
| prefix: prefix of pvs in this ioc | ||
| """ | ||
| try: | ||
| exepath = sys.argv[0] | ||
| if pv_database is None: | ||
| pv_database = {} | ||
| if prefix is None: | ||
| prefix = "none" | ||
|
|
||
| ioc_data_source = IocDataSource(SQLAbstraction("iocdb", "iocdb", "$iocdb")) | ||
| ioc_data_source.insert_ioc_start(ioc_name, os.getpid(), exepath, pv_database, prefix) | ||
| except Exception as e: | ||
| print_and_log( | ||
| "Error registering ioc start: {}: {}".format(e.__class__.__name__, e), | ||
| SEVERITY.MAJOR, | ||
| ) | ||
|
|
||
|
|
||
| def get_macro_values() -> Dict[str, str]: | ||
| """ | ||
| Parse macro environment JSON into dict. To make this work use the icpconfigGetMacros program. | ||
|
|
@@ -50,9 +14,6 @@ def get_macro_values() -> Dict[str, str]: | |
| return macros | ||
|
|
||
|
|
||
| motor_in_set_mode = g.adv.motor_in_set_mode | ||
|
|
||
|
|
||
| def _get_env_var(name: str) -> str: | ||
| try: | ||
| return os.environ[name] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import os | ||
| import sys | ||
| from typing import Dict | ||
|
|
||
| from genie_python.mysql_abstraction_layer import SQLAbstraction | ||
| from server_common.ioc_data_source import IocDataSource | ||
| from server_common.utilities import SEVERITY, print_and_log | ||
|
|
||
|
|
||
| def register_ioc_start( | ||
| ioc_name: str, | ||
| pv_database: Dict[str, Dict[str, str]] = None, | ||
| prefix: str | None = None, | ||
| ) -> None: | ||
| """ | ||
| A helper function to register the start of an ioc. | ||
| Args: | ||
| ioc_name: name of the ioc to start | ||
| pv_database: doctionary of pvs in the iov | ||
| prefix: prefix of pvs in this ioc | ||
| """ | ||
| try: | ||
| exepath = sys.argv[0] | ||
| if pv_database is None: | ||
| pv_database = {} | ||
| if prefix is None: | ||
| prefix = "none" | ||
|
|
||
| ioc_data_source = IocDataSource(SQLAbstraction("iocdb", "iocdb", "$iocdb")) | ||
| ioc_data_source.insert_ioc_start(ioc_name, os.getpid(), exepath, pv_database, prefix) | ||
| except Exception as e: | ||
| print_and_log( | ||
| "Error registering ioc start: {}: {}".format(e.__class__.__name__, e), | ||
| SEVERITY.MAJOR, | ||
| ) |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| import threading | ||
| import time | ||
| import zlib | ||
| from typing import Any, Iterable | ||
| from xml.etree import ElementTree | ||
|
|
||
| from server_common.common_exceptions import MaxAttemptsExceededException | ||
|
|
@@ -113,6 +114,14 @@ def dehex_and_decompress(value): | |
| ) | ||
| return zlib.decompress(binascii.unhexlify(value)) | ||
|
|
||
| def dehex_decompress_and_dejson(value: bytes) -> Any: # noqa: ANN401 | ||
| """ | ||
| Convert string from zipped hexed json to a python representation | ||
| :param value: value to convert | ||
| :return: python representation of json | ||
| """ | ||
| return json.loads(dehex_and_decompress(value)) | ||
|
|
||
|
|
||
| def dehex_and_decompress_waveform(value): | ||
| """Decompresses the inputted waveform, assuming it is a array of integers representing characters (null terminated). | ||
|
|
@@ -157,7 +166,7 @@ def convert_from_json(value): | |
| return json.loads(value) | ||
|
|
||
|
|
||
| def parse_boolean(string): | ||
| def parse_boolean(string: str) -> bool: | ||
| """Parses an xml true/false value to boolean | ||
|
|
||
| Args: | ||
|
|
@@ -265,19 +274,21 @@ def parse_xml_removing_namespace(file_path): | |
| return it.root | ||
|
|
||
|
|
||
| def waveform_to_string(data): | ||
| def waveform_to_string(data: Iterable[int | str]) -> str: | ||
| """ | ||
| Args: | ||
| data: waveform as null terminated string | ||
|
|
||
| Returns: waveform as a sting | ||
|
|
||
| """ | ||
| output = str() | ||
| output = "" | ||
| for i in data: | ||
| if i == 0: | ||
| break | ||
| output += chr(i) | ||
| if isinstance(i, str): | ||
| output += i | ||
| else: | ||
| output += str(chr(i)) | ||
| return output | ||
|
|
||
|
|
||
|
|
@@ -294,7 +305,7 @@ def ioc_restart_pending(ioc_pv, channel_access): | |
| return channel_access.caget(ioc_pv + ":RESTART", as_string=True) == "Busy" | ||
|
|
||
|
|
||
| def retry(max_attempts, interval, exception): | ||
| def retry(max_attempts: int, interval: int, exception: BaseException): | ||
| """ | ||
| Attempt to perform a function a number of times in specified intervals before failing. | ||
|
|
||
|
|
@@ -327,7 +338,7 @@ def _wrapper(*args, **kwargs): | |
| return _tags_decorator | ||
|
|
||
|
|
||
| def remove_from_end(string, text_to_remove): | ||
| def remove_from_end(string: str, text_to_remove: str) -> str: | ||
| """ | ||
| Remove a String from the end of a string if it exists | ||
| Args: | ||
|
|
@@ -342,7 +353,7 @@ def remove_from_end(string, text_to_remove): | |
| return string | ||
|
|
||
|
|
||
| def lowercase_and_make_unique(in_list): | ||
| def lowercase_and_make_unique(in_list: list[str]) -> set[str]: | ||
| """ | ||
| Takes a collection of strings, and returns it with all strings lowercased and with duplicates removed. | ||
|
|
||
|
|
||
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ | |
| class TestFilePathManagerSequence(unittest.TestCase): | ||
| def setUp(self): | ||
| # Find the schema directory | ||
| dir = os.path.join(".") | ||
| dir = os.path.join("../src/server_common/test_modules") | ||
|
|
||
| self.config_path = os.path.abspath(CONFIG_PATH) | ||
| self.script_path = os.path.abspath(SCRIPT_PATH) | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Unused import Note
Copilot Autofix
AI 12 days ago
To fix the problem, simply delete the unused import statement:
from genie_python.genie_cachannel_wrapper import AlarmCondition as AlarmStatus # noqa: F401.AlarmStatusis not used elsewhere in the provided snippet.