mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Bugfix: obviously sys.hexversion was one symbol shorter
plus remove some unneeded code
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ import json
|
||||
import logging
|
||||
import psycopg2
|
||||
import time
|
||||
import dateutil
|
||||
import dateutil.parser
|
||||
import datetime
|
||||
import pytz
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Patroni Control
|
||||
import base64
|
||||
import click
|
||||
import datetime
|
||||
import dateutil
|
||||
import dateutil.parser
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
@@ -33,7 +33,7 @@ import sys
|
||||
import argparse
|
||||
|
||||
|
||||
if sys.hexversion >= 0x03000000:
|
||||
if sys.hexversion >= 0x0300000:
|
||||
long = int
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
+1
-23
@@ -1,39 +1,17 @@
|
||||
import datetime
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
import time
|
||||
import pytz
|
||||
import dateutil.parser
|
||||
|
||||
from patroni.exceptions import PatroniException
|
||||
|
||||
if sys.hexversion >= 0x03000000:
|
||||
if sys.hexversion >= 0x0300000:
|
||||
long = int
|
||||
|
||||
__interrupted_sleep = False
|
||||
__reap_children = False
|
||||
|
||||
|
||||
def calculate_ttl(expiration):
|
||||
"""
|
||||
>>> calculate_ttl(None)
|
||||
>>> calculate_ttl('2015-06-10 12:56:30.552539016Z') < 0
|
||||
True
|
||||
>>> calculate_ttl('2015-06-10T12:56:30.552539016Z') < 0
|
||||
True
|
||||
>>> calculate_ttl('fail-06-10T12:56:30.552539016Z')
|
||||
"""
|
||||
if not expiration:
|
||||
return None
|
||||
try:
|
||||
expiration = dateutil.parser.parse(expiration)
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
now = datetime.datetime.now(pytz.utc)
|
||||
return int((expiration - now).total_seconds())
|
||||
|
||||
|
||||
def deep_compare(obj1, obj2):
|
||||
"""
|
||||
>>> deep_compare({'1': None}, {})
|
||||
|
||||
@@ -336,7 +336,9 @@ class TestPostgresql(unittest.TestCase):
|
||||
|
||||
@patch('os.path.isfile', Mock(return_value=True))
|
||||
@patch('os.kill', Mock(side_effect=Exception))
|
||||
@patch.object(builtins, 'open', mock_open(read_data='-999999999999999'))
|
||||
@patch('os.getpid', Mock(return_value=2))
|
||||
@patch('os.getppid', Mock(return_value=2))
|
||||
@patch.object(builtins, 'open', mock_open(read_data='-1'))
|
||||
@patch.object(Postgresql, '_version_file_exists', Mock(return_value=True))
|
||||
def test_is_running(self):
|
||||
self.assertFalse(self.p.is_running())
|
||||
|
||||
Reference in New Issue
Block a user