Merge branch 'master' of github.com:zalando/patroni into feature/confd

This commit is contained in:
Alexander Kukushkin
2016-06-17 12:21:13 +02:00
6 changed files with 12 additions and 29 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ import json
import logging
import psycopg2
import time
import dateutil
import dateutil.parser
import datetime
import pytz
+1 -1
View File
@@ -5,7 +5,7 @@ Patroni Control
import base64
import click
import datetime
import dateutil
import dateutil.parser
import json
import logging
import os
+1 -1
View File
@@ -33,7 +33,7 @@ import sys
import argparse
if sys.hexversion >= 0x03000000:
if sys.hexversion >= 0x0300000:
long = int
logger = logging.getLogger(__name__)
+5 -24
View File
@@ -1,36 +1,17 @@
import datetime
import os
import random
import six
import sys
import time
import pytz
import dateutil.parser
from patroni.exceptions import PatroniException
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}, {})
@@ -134,7 +115,7 @@ def strtol(value, strict=True):
while i < l:
try: # try to find maximally long number
i += 1 # by giving to `int` longer and longer strings
ret = int(value[:i], base) if six.PY3 else long(value[:i], base)
ret = long(value[:i], base)
except ValueError: # until we will not get an exception or end of the string
i -= 1
break
+1 -1
View File
@@ -33,7 +33,7 @@ LICENSE = 'The MIT License'
URL = 'https://github.com/zalando/patroni'
AUTHOR = 'Alexander Kukushkin, Oleksii Kliukin, Feike Steenbergen'
AUTHOR_EMAIL = '[email protected], [email protected], [email protected]'
KEYWORDS = 'etcd governor patroni postgresql postgres ha zookeeper streaming replication'
KEYWORDS = 'etcd governor patroni postgresql postgres ha haproxy confd zookeeper exhibitor consul streaming replication'
COVERAGE_XML = True
COVERAGE_HTML = False
+3 -1
View File
@@ -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())