mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
1) Replace utcnow() function with datetime.now(timezone.utc) as it is deprecated from Python v3.12.
2) Correct the URL to log an issue in pgAdmin in the ERD tool script.
This commit is contained in:
parent
6062084128
commit
5f3965ff0a
@ -33,7 +33,7 @@ OUTDIR - Output directory
|
|||||||
# To make print function compatible with python2 & python3
|
# To make print function compatible with python2 & python3
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta, tzinfo
|
from datetime import datetime, timedelta, tzinfo, timezone
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import signal
|
import signal
|
||||||
@ -133,9 +133,7 @@ class UTC(tzinfo):
|
|||||||
|
|
||||||
|
|
||||||
def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'):
|
def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'):
|
||||||
return datetime.utcnow().replace(
|
return datetime.now(timezone.utc).strftime(format)
|
||||||
tzinfo=UTC()
|
|
||||||
).strftime(format)
|
|
||||||
|
|
||||||
|
|
||||||
class ProcessLogger(Thread):
|
class ProcessLogger(Thread):
|
||||||
|
@ -16,7 +16,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import psutil
|
import psutil
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta, timezone
|
||||||
from pickle import dumps, loads
|
from pickle import dumps, loads
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import logging
|
import logging
|
||||||
@ -29,7 +29,6 @@ from pgadmin.utils.constants import KERBEROS
|
|||||||
from pgadmin.utils.locker import ConnectionLocker
|
from pgadmin.utils.locker import ConnectionLocker
|
||||||
from pgadmin.utils.preferences import Preferences
|
from pgadmin.utils.preferences import Preferences
|
||||||
|
|
||||||
import pytz
|
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
from flask import current_app, session
|
from flask import current_app, session
|
||||||
from flask_babel import gettext as _
|
from flask_babel import gettext as _
|
||||||
@ -50,9 +49,7 @@ def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'):
|
|||||||
"""
|
"""
|
||||||
Generate the current time string in the given format.
|
Generate the current time string in the given format.
|
||||||
"""
|
"""
|
||||||
return datetime.utcnow().replace(
|
return datetime.now(timezone.utc).strftime(format)
|
||||||
tzinfo=pytz.utc
|
|
||||||
).strftime(format)
|
|
||||||
|
|
||||||
|
|
||||||
class IProcessDesc(metaclass=ABCMeta):
|
class IProcessDesc(metaclass=ABCMeta):
|
||||||
|
@ -668,7 +668,7 @@ class ERDTool extends React.Component {
|
|||||||
|
|
||||||
onSQLClick(sqlWithDrop=false) {
|
onSQLClick(sqlWithDrop=false) {
|
||||||
let scriptHeader = gettext('-- This script was generated by the ERD tool in pgAdmin 4.\n');
|
let scriptHeader = gettext('-- This script was generated by the ERD tool in pgAdmin 4.\n');
|
||||||
scriptHeader += gettext('-- Please log an issue at https://redmine.postgresql.org/projects/pgadmin4/issues/new if you find any bugs, including reproduction steps.\n');
|
scriptHeader += gettext('-- Please log an issue at https://github.com/pgadmin-org/pgadmin4/issues/new/choose if you find any bugs, including reproduction steps.\n');
|
||||||
|
|
||||||
let url = url_for('erd.sql', {
|
let url = url_for('erd.sql', {
|
||||||
trans_id: this.props.params.trans_id,
|
trans_id: this.props.params.trans_id,
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
|
##########################################################################
|
||||||
|
#
|
||||||
|
# pgAdmin 4 - PostgreSQL Tools
|
||||||
|
#
|
||||||
|
# Copyright (C) 2013 - 2023, The pgAdmin Development Team
|
||||||
|
# This software is released under the PostgreSQL License
|
||||||
|
#
|
||||||
|
##########################################################################
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta, timezone
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
@ -31,7 +37,7 @@ class PasswordExec:
|
|||||||
if not self.cmd:
|
if not self.cmd:
|
||||||
return None
|
return None
|
||||||
current_app.logger.info('Calling passexec')
|
current_app.logger.info('Calling passexec')
|
||||||
now = datetime.utcnow()
|
now = datetime.now(timezone.utc)
|
||||||
try:
|
try:
|
||||||
p = subprocess.run(
|
p = subprocess.run(
|
||||||
self.cmd,
|
self.cmd,
|
||||||
@ -55,7 +61,7 @@ class PasswordExec:
|
|||||||
if self.expiration_seconds is None:
|
if self.expiration_seconds is None:
|
||||||
return False
|
return False
|
||||||
return self.last_result is not None and\
|
return self.last_result is not None and\
|
||||||
datetime.utcnow() - self.last_result \
|
datetime.now(timezone.utc) - self.last_result \
|
||||||
>= timedelta(seconds=self.expiration_seconds)
|
>= timedelta(seconds=self.expiration_seconds)
|
||||||
|
|
||||||
def create_logger(self):
|
def create_logger(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user