2022-02-14 00:43:48 -06:00
|
|
|
##########################################################################
|
|
|
|
#
|
|
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
|
|
#
|
2024-12-31 23:56:42 -06:00
|
|
|
# Copyright (C) 2013 - 2025, The pgAdmin Development Team
|
2022-02-14 00:43:48 -06:00
|
|
|
# This software is released under the PostgreSQL Licence
|
|
|
|
#
|
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
import json
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
2022-04-26 06:11:10 -05:00
|
|
|
def debug(message):
|
2022-02-14 00:43:48 -06:00
|
|
|
""" Print a debug message """
|
|
|
|
now = datetime.datetime.now()
|
|
|
|
|
|
|
|
print('[{}]: {}'.format(now.strftime("%H:%M:%S"), message),
|
2022-04-26 06:11:10 -05:00
|
|
|
file=sys.stderr)
|
2022-02-14 00:43:48 -06:00
|
|
|
|
|
|
|
|
2022-04-26 06:11:10 -05:00
|
|
|
def error(message):
|
2022-02-14 00:43:48 -06:00
|
|
|
""" Print an error message and exit """
|
2022-04-26 06:11:10 -05:00
|
|
|
debug(message)
|
2022-02-14 00:43:48 -06:00
|
|
|
|
|
|
|
output({'error': message})
|
|
|
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
def output(data):
|
|
|
|
""" Dump JSON output from a dict """
|
2022-04-26 06:11:10 -05:00
|
|
|
print(json.dumps(data))
|