Skip to content

Commit a36f485

Browse files
Using an testgres.os_ops
src/operations is deleted. TestgresException, ExecUtilException, InvalidOperationException are gotten from testgres.operations.exceptions
1 parent be36713 commit a36f485

File tree

17 files changed

+33
-1801
lines changed

17 files changed

+33
-1801
lines changed

create_py_env.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ pip install pytest
66
pip install pytest-xdist
77
pip install psycopg2
88
pip install six
9-
pip install psutil
9+
pip install psutil
10+
pip install git+https://git.postgrespro.ru/d.kovalenko/preview-testgres.os_ops.git
11+

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@
2222
if sys.version_info < (3, 3):
2323
install_requires.append("ipaddress")
2424

25+
install_requires.append(
26+
"git+https://git.postgrespro.ru/d.kovalenko/preview-testgres.os_ops.git"
27+
)
28+
2529
# Get contents of README file
2630
with open('README.md', 'r') as f:
2731
readme = f.read()
2832

2933
setup(
3034
version='1.11.0',
3135
name='testgres',
32-
packages=['testgres', 'testgres.operations', 'testgres.impl'],
36+
packages=['testgres', 'testgres.impl'],
3337
package_dir={"testgres": "src"},
3438
description='Testing utility for PostgreSQL and its extensions',
3539
url='https://github.com/postgrespro/testgres',

src/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151

5252
from .config import testgres_config
5353

54-
from .operations.os_ops import OsOperations, ConnectionParams
55-
from .operations.local_ops import LocalOperations
56-
from .operations.remote_ops import RemoteOperations
54+
from testgres.operations.os_ops import OsOperations, ConnectionParams
55+
from testgres.operations.local_ops import LocalOperations
56+
from testgres.operations.remote_ops import RemoteOperations
5757

5858
__all__ = [
5959
"get_new_node",

src/backup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from .exceptions import BackupException
1515

16-
from .operations.os_ops import OsOperations
16+
from testgres.operations.os_ops import OsOperations
1717

1818
from .utils import \
1919
get_bin_path2, \

src/cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
get_bin_path2, \
1717
execute_utility2
1818

19-
from .operations.local_ops import LocalOperations
20-
from .operations.os_ops import OsOperations
19+
from testgres.operations.local_ops import LocalOperations
20+
from testgres.operations.os_ops import OsOperations
2121

2222

2323
def cached_initdb(data_dir, logfile=None, params=None, os_ops: OsOperations = None, bin_path=None, cached=True):

src/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from contextlib import contextmanager
1010

1111
from .consts import TMP_CACHE
12-
from .operations.os_ops import OsOperations
13-
from .operations.local_ops import LocalOperations
12+
from testgres.operations.os_ops import OsOperations
13+
from testgres.operations.local_ops import LocalOperations
1414

1515
log_level = os.getenv('LOGGING_LEVEL', 'WARNING').upper()
1616
log_format = os.getenv('LOGGING_FORMAT', '%(asctime)s - %(levelname)s - %(message)s')

src/exceptions.py

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,15 @@
22

33
import six
44

5-
6-
class TestgresException(Exception):
7-
pass
5+
from testgres.operations.exceptions import TestgresException
6+
from testgres.operations.exceptions import ExecUtilException
7+
from testgres.operations.exceptions import InvalidOperationException
88

99

1010
class PortForException(TestgresException):
1111
pass
1212

1313

14-
@six.python_2_unicode_compatible
15-
class ExecUtilException(TestgresException):
16-
def __init__(self, message=None, command=None, exit_code=0, out=None, error=None):
17-
super(ExecUtilException, self).__init__(message)
18-
19-
self.message = message
20-
self.command = command
21-
self.exit_code = exit_code
22-
self.out = out
23-
self.error = error
24-
25-
def __str__(self):
26-
msg = []
27-
28-
if self.message:
29-
msg.append(self.message)
30-
31-
if self.command:
32-
command_s = ' '.join(self.command) if isinstance(self.command, list) else self.command,
33-
msg.append(u'Command: {}'.format(command_s))
34-
35-
if self.exit_code:
36-
msg.append(u'Exit code: {}'.format(self.exit_code))
37-
38-
if self.error:
39-
msg.append(u'---- Error:\n{}'.format(self.error))
40-
41-
if self.out:
42-
msg.append(u'---- Out:\n{}'.format(self.out))
43-
44-
return self.convert_and_join(msg)
45-
46-
@staticmethod
47-
def convert_and_join(msg_list):
48-
# Convert each byte element in the list to str
49-
str_list = [six.text_type(item, 'utf-8') if isinstance(item, bytes) else six.text_type(item) for item in
50-
msg_list]
51-
52-
# Join the list into a single string with the specified delimiter
53-
return six.text_type('\n').join(str_list)
54-
55-
5614
@six.python_2_unicode_compatible
5715
class QueryException(TestgresException):
5816
def __init__(self, message=None, query=None):
@@ -109,5 +67,5 @@ class BackupException(TestgresException):
10967
pass
11068

11169

112-
class InvalidOperationException(TestgresException):
113-
pass
70+
assert ExecUtilException.__name__ == "ExecUtilException"
71+
assert InvalidOperationException.__name__ == "InvalidOperationException"

src/impl/port_manager__generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ..operations.os_ops import OsOperations
1+
from testgres.operations.os_ops import OsOperations
22

33
from ..port_manager import PortManager
44
from ..exceptions import PortForException

src/node.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@
104104

105105
from .backup import NodeBackup
106106

107-
from .operations.os_ops import ConnectionParams
108-
from .operations.os_ops import OsOperations
109-
from .operations.local_ops import LocalOperations
107+
from testgres.operations.os_ops import ConnectionParams
108+
from testgres.operations.os_ops import OsOperations
109+
from testgres.operations.local_ops import LocalOperations
110110

111111
InternalError = pglib.InternalError
112112
ProgrammingError = pglib.ProgrammingError

src/operations/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)