v7.2.4.0: Update requirements and refactor date formatting function

The requirements for el9, deb, and main have been updated to specifically use version 2.27.1 of the "requests" package. In addition, the date formatting function get_time_zoned_date in common.py has been refactored. The default format for the date has been moved to the function arguments, and the function now also checks if the provided date is an instance of datetime before processing it.
pull/377/head
Aidaho 2024-04-17 22:54:00 +03:00
parent 04e39325c8
commit 5b98f1b611
6 changed files with 13 additions and 11 deletions

View File

@ -26,7 +26,7 @@ def _convert_to_time_zone(date: datetime) -> datetime:
return native
def get_time_zoned_date(date: datetime, fmt: str = None) -> str:
def get_time_zoned_date(date: datetime, fmt: str = '%Y-%m-%d %H:%M:%S') -> str:
"""
Formats a given date and returns the formatted date in the specified or default format.
@ -39,12 +39,11 @@ def get_time_zoned_date(date: datetime, fmt: str = None) -> str:
:return: The formatted date.
:rtype: str
"""
native = _convert_to_time_zone(date)
date_format = '%Y-%m-%d %H:%M:%S'
if fmt:
return native.strftime(fmt)
else:
return native.strftime(date_format)
if not isinstance(date, datetime):
date = datetime.strptime(date, date_format)
native = _convert_to_time_zone(date)
return native.strftime(fmt)
def get_present_time():

View File

@ -185,7 +185,7 @@ function createHaClusterStep1(edited=false, cluster_id=0, clean=true) {
}
}
});
$.getScript('/inc/ha.js');
$.getScript('/app/static/js/ha.js');
var regx = /^[a-z0-9_-]+$/;
var dialog_div = $("#create-ha-cluster-step-1").dialog({
autoOpen: false,
@ -614,7 +614,7 @@ function add_vip_ha_cluster(cluster_id, cluster_name, router_id='', vip='', edit
}
}
});
$.getScript('/inc/ha.js');
$.getScript('/app/static/js/ha.js');
var dialog_div = $("#add-vip").dialog({
autoOpen: false,
resizable: false,
@ -739,7 +739,7 @@ function addCheckToStatus(server_id, server_ip) {
'</div>';
$('#add_check-' + server_id).remove();
$("#enabled-check").append(html_tag);
$.getScript('/inc/ha.js');
$.getScript('/app/static/js/ha.js');
}
function removeCheckFromStatus(server_id, server_ip) {
var hostname = $('#remove_check-' + server_id).attr('data-name');

View File

@ -4,7 +4,7 @@
{% block content %}
{% from 'include/input_macros.html' import input, checkbox, copy_to_clipboard %}
<script src="/inc/users.js"></script>
<script src="/inc/ha.js"></script>
<script src="/app/static/js/ha.js"></script>
<script src="/inc/overview.js"></script>
<link href="{{ url_for('static', filename='css/servers.css') }}" rel="stylesheet"/>
<link href="{{ url_for('static', filename='css/smon.css') }}" rel="stylesheet">

View File

@ -19,3 +19,5 @@ websockets>=9.0
ansible-core>=2.11.12
ansible-runner==2.3.2
python-whois>=0.8.0
requests==2.27.1

View File

@ -21,3 +21,4 @@ tzlocal==2.0.0
ansible-core>=2.11.12
ansible-runner==2.3.1
python-whois>=0.8.0
requests==2.27.1

View File

@ -2,7 +2,7 @@ configparser>=3.5.0
paramiko-ng>=2.5.0
pytz>=2017.3
tzlocal==2.0.0
requests>=2.22.0
requests==2.27.1
pyTelegramBotAPI>=3.6.3
networkx>=2.6
matplotlib>=2.1.2