Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use kwargs for several functions to move through all possible arguments#36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
funbringer merged 3 commits intopostgrespro:masterfromildus:master
Feb 28, 2018
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 14 additions & 30 deletionstestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,8 +30,7 @@
HBA_CONF_FILE, \
RECOVERY_CONF_FILE, \
PG_LOG_FILE, \
UTILS_LOG_FILE, \
DEFAULT_XLOG_METHOD
UTILS_LOG_FILE

from .decorators import \
method_decorator, \
Expand DownExpand Up@@ -112,7 +111,7 @@ def __enter__(self):
def __exit__(self, type, value, traceback):
self.free_port()

# NOTE:ctrl+C does not count!
# NOTE:Ctrl+C does not count!
got_exception = type is not None and type != KeyboardInterrupt

c1 = self.cleanup_on_good_exit and not got_exception
Expand DownExpand Up@@ -254,19 +253,15 @@ def _collect_special_files(self):

return result

def init(self,
fsync=False,
unix_sockets=True,
allow_streaming=True,
initdb_params=None):
def init(self, initdb_params=None, **kwargs):
"""
Perform initdb for this node.

Args:
initdb_params: parameters for initdb (list).
fsync: should this node use fsync to keep data safe?
unix_sockets: should we enable UNIX sockets?
allow_streaming: should this node add a hba entry for replication?
initdb_params: parameters for initdb (list).

Returns:
This instance of PostgresNode.
Expand All@@ -281,9 +276,7 @@ def init(self,
params=initdb_params)

# initialize default config files
self.default_conf(fsync=fsync,
unix_sockets=unix_sockets,
allow_streaming=allow_streaming)
self.default_conf(**kwargs)

return self

Expand DownExpand Up@@ -681,16 +674,13 @@ def psql(self,
return process.returncode, out, err

@method_decorator(positional_args_hack(['dbname', 'query']))
def safe_psql(self,
query,
dbname=None,
username=None,
input=None):
def safe_psql(self, query=None, **kwargs):
"""
Execute a query using psql.

Args:
query: query to be executed.
filename: file with a query.
dbname: database name to connect to.
username: database user name.
input: raw input to be passed.
Expand All@@ -699,10 +689,7 @@ def safe_psql(self,
psql's output as str.
"""

ret, out, err = self.psql(query=query,
dbname=dbname,
username=username,
input=input)
ret, out, err = self.psql(query=query, **kwargs)
if ret:
raise QueryException((err or b'').decode('utf-8'), query)

Expand DownExpand Up@@ -858,37 +845,34 @@ def execute(self,

return res

def backup(self,username=None, xlog_method=DEFAULT_XLOG_METHOD):
def backup(self,**kwargs):
"""
Perform pg_basebackup.

Args:
username: database user name.
xlog_method: a method for collecting the logs ('fetch' | 'stream').
base_dir: the base directory for data files and logs

Returns:
A smart object of type NodeBackup.
"""

from .backup import NodeBackup
return NodeBackup(node=self,
username=username,
xlog_method=xlog_method)
return NodeBackup(node=self, **kwargs)

def replicate(self,
name=None,
username=None,
xlog_method=DEFAULT_XLOG_METHOD):
def replicate(self, name=None, **kwargs):
"""
Create a binary replica of this node.

Args:
name: replica's application name.
username: database user name.
xlog_method: a method for collecting the logs ('fetch' | 'stream').
base_dir: the base directory for data files and logs
"""

backup = self.backup(username=username, xlog_method=xlog_method)
backup = self.backup(**kwargs)

# transform backup into a replica
return backup.spawn_replica(name=name, destroy=True)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp