ctdclient.model.near_real_time_publication module¶
- ctdclient.model.near_real_time_publication.instantiate_near_real_time_target(*args, frequency_of_action='23:59:00', **kwargs)[source]¶
Differentiate the two NRT modes and instantiates respecive classes.
- Parameters:
*args – Are given to NRT classes
frequency_of_action (
str) – The information to distinguish the two NRT modes**kwargs – Are given to NRT classes
- Return type:
- class ctdclient.model.near_real_time_publication.NRTList(*args, **kwargs)[source]¶
Bases:
UserListA collection of NearRealTimeTargets.
- update_nrt_data(clear_data=True)[source]¶
Fills collection with NRT instances.
- Parameters:
clear_data (
bool) – Whether to reset previous data when updating
- create_nrt_instance(path)[source]¶
Get new instance of NearRealTimeTarget.
- Parameters:
path (
Path) – File path to toml config file- Return type:
NearRealTimeTarget instance.
- get_template(template_path=PosixPath('/home/runner/work/CTD-Client/CTD-Client/src/ctdclient/resources/templates/nrt_template.toml'))[source]¶
Create template NearRealTimeTarget instance.
- Parameters:
template_path (
Path) – File path to template file config- Return type:
NearRealTimeTarget instance.
- toggle_activity(nrt)[source]¶
Toggle whether a particluar NearRealTimeTarget is active or not.
- Parameters:
nrt (
NearRealTimeTarget) – The target instance to toggle
- delete_nrt(nrt)[source]¶
Removes a NearRealTimeTarget from the collection.
- Parameters:
nrt (
NearRealTimeTarget) – The instance to remove
- class ctdclient.model.near_real_time_publication.NearRealTimeTarget(recipient_address, target_file_suffix, target_file_directory='', geo_filter='', email_info={}, file_path='', active=False, **kwargs)[source]¶
Bases:
objectStores information for near-real-time distribution of latest CTD data files. Can work in two modes: email or rsync/copy. Will distinguish between these by checking ‘recipient_adress’ for an ‘@’.
- Parameters:
recipient_address (
str) – Target of the action, email address or file pathtarget_file_suffix (
str) – File suffix to select target files withtarget_file_directory (
Path|str) – The directory to look for target filesgeo_filter (
str) – A geographic location to filter target files withemail_info (
dict) – Collection of email informationfile_path (
Path|str) – File path to config fileactive (
bool) – Whether the NRT job is active
- create_email_message(target_files, to_address='', from_address='', subject='', body='')[source]¶
Creates an email with target files attached.
- Parameters:
target_files (
list[Path]) – Target files to attachto_address (
str) – Email address to send tofrom_address (
str) – Email address to send fromsubject (
str) – Email subject linebody (
str) – Email text
- Return type:
Assembled email message.
- create_email_draft(msg, file_path='')[source]¶
Creates an email .eml draft file, that can be opened by common email programs.
- Parameters:
msg (
EmailMessage) – Assembled email message ready for sendingfile_path (
Path|str) – File path to save .eml draft file to
- Return type:
Path
- open_draft_msg(file_path)[source]¶
Open an .eml file using the default email program.
- Parameters:
file_path (
Path|str) – File path to .eml file
- run_email_logic(files_to_attach, run_manually=False)[source]¶
Master method to coordinate email assembly and sending.
- Parameters:
files_to_attach (
list) – List of target files to attach to emailrun_manually (
bool) – Whether to automatically send email or open draft message for editing
- send_email(msg)[source]¶
Sends the email message using the given smtp server configuration.
- Parameters:
msg (
EmailMessage) – Assembled email message to send
- copy_files(target_file)[source]¶
Copies target files to given location.
- Parameters:
target_file (
Path) – The target file to copy
- get_target_files(target_file=PosixPath('.'))[source]¶
Creates a list of paths to files that are meant to be published.
- Parameters:
target_file (
Path) – File path to target file- Return type:
list[Path]
- deg_min_to_deg_decimal(value)[source]¶
Converts coordinates from deg minutes to decimal degrees.
- Parameters:
value (
str) – Coordinate information- Return type:
float
- geographic_filter(coordinate_pair)[source]¶
Checks, whether we are inside of a certain polygon.
The polygon will usually be the EEZ of a certain country. Does support all data formats that geopandas can handle.
- Parameters:
coordinate_pair (
tuple) – Coordinates of the target file- Return type:
bool
- point_in_polygon(point, polygon)[source]¶
Check if a point is inside a polygon using the Ray Casting Algorithm.
- Parameters:
point – Tuple (x, y) representing the point to check.
polygon – List of tuples [(x1, y1), (x2, y2), …] representing the polygon vertices.
- Return type:
True if the point is inside the polygon, False otherwise.
- class ctdclient.model.near_real_time_publication.DailyPublication(*args, time_to_run_at='23:59:30', single_run=False, **kwargs)[source]¶
Bases:
NearRealTimeTargetAutomatic publication once a day.
- Parameters:
time_to_run_at (
str) – The time point to publishsingle_run (
bool) – Whether to run once or infinitely
- ctdclient.model.near_real_time_publication.timer(time_to_run_at, function, single_run)[source]¶
Timer to next publication moment.
- Parameters:
time_to_run_at (
datetime) – Next target timefunction (
Callable) – Action to perform on publication timesingle_run (
bool) – Whether to run only once
- class ctdclient.model.near_real_time_publication.EachProcessingPublication(*args, **kwargs)[source]¶
Bases:
NearRealTimeTargetAutomatic publication every processing.