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

Commit7153fd3

Browse files
committed
add 'temp_dir' setting to GlobalConfig
1 parent56f79aa commit7153fd3

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

‎testgres/backup.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
importos
44
importshutil
5-
importtempfile
65

76
fromsiximportraise_from
7+
fromtempfileimportmkdtemp
8+
9+
from .configimporttestgres_config
810

911
from .constsimport \
1012
DATA_DIR, \
@@ -49,9 +51,11 @@ def __init__(self,
4951
ifnotnode.status():
5052
raiseBackupException('Node must be running')
5153

54+
# yapf: disable
5255
# Set default arguments
5356
username=usernameordefault_username()
54-
base_dir=base_dirortempfile.mkdtemp(prefix=TMP_BACKUP)
57+
base_dir=base_dirormkdtemp(prefix=TMP_BACKUP,
58+
dir=testgres_config.temp_dir)
5559

5660
# public
5761
self.original_node=node
@@ -98,7 +102,8 @@ def _prepare_dir(self, destroy):
98102
available=notdestroy
99103

100104
ifavailable:
101-
dest_base_dir=tempfile.mkdtemp(prefix=TMP_NODE)
105+
dest_base_dir=mkdtemp(prefix=TMP_NODE,
106+
dir=testgres_config.temp_dir)
102107

103108
data1=os.path.join(self.base_dir,DATA_DIR)
104109
data2=os.path.join(dest_base_dir,DATA_DIR)

‎testgres/config.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
importatexit
44
importcopy
55
importshutil
6-
importtempfile
76

87
fromcontextlibimportcontextmanager
8+
fromtempfileimportmkdtemp
99

1010
from .constsimportTMP_CACHE
1111

@@ -21,6 +21,8 @@ class GlobalConfig(object):
2121
2222
cache_pg_config: shall we cache pg_config results?
2323
24+
temp_dir: base temp dir for nodes with default 'base_dir'.
25+
2426
use_python_logging: use python logging configuration for all nodes.
2527
error_log_lines: N of log lines to be shown in exception (0=inf).
2628
@@ -37,6 +39,8 @@ class GlobalConfig(object):
3739

3840
cache_pg_config=True
3941

42+
temp_dir=None
43+
4044
use_python_logging=False
4145
error_log_lines=20
4246

@@ -166,5 +170,7 @@ def configure_testgres(**options):
166170
testgres_config.update(options)
167171

168172

173+
# yapf: disable
169174
# NOTE: assign initial cached dir for initdb
170-
testgres_config.cached_initdb_dir=tempfile.mkdtemp(prefix=TMP_CACHE)
175+
testgres_config.cached_initdb_dir=mkdtemp(prefix=TMP_CACHE,
176+
dir=testgres_config.temp_dir)

‎testgres/node.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
importshutil
66
importsix
77
importsubprocess
8-
importtempfile
98
importtime
109

1110
fromenumimportEnum
1211
fromsiximportraise_from
12+
fromtempfileimportmkstemp,mkdtemp
1313

1414
from .cacheimportcached_initdb
1515

@@ -200,7 +200,8 @@ def _create_recovery_conf(self, username):
200200

201201
def_prepare_dirs(self):
202202
ifnotself.base_dir:
203-
self.base_dir=tempfile.mkdtemp(prefix=TMP_NODE)
203+
self.base_dir=mkdtemp(prefix=TMP_NODE,
204+
dir=testgres_config.temp_dir)
204205

205206
ifnotos.path.exists(self.base_dir):
206207
os.makedirs(self.base_dir)
@@ -718,7 +719,7 @@ def dump(self, filename=None, dbname=None, username=None):
718719
"""
719720

720721
deftmpfile():
721-
fd,fname=tempfile.mkstemp(prefix=TMP_DUMP)
722+
fd,fname=mkstemp(prefix=TMP_DUMP,dir=testgres_config.temp_dir)
722723
os.close(fd)
723724
returnfname
724725

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp