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

PEP8 cleanups#2

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 1 commit intopostgrespro:masterfromstalkerg:master
Sep 8, 2016
Merged
Show file tree
Hide file tree
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
58 changes: 36 additions & 22 deletionstestgres/testgres.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,15 +23,15 @@

importos
importrandom
importsocket
#import socket
importsubprocess
importpwd
importtempfile
importshutil
importtime
importsix

# Try to use psycopg2 by default. If psycopg2 isn"t available then use
# Try to use psycopg2 by default. If psycopg2 isn"t available then use
# pg8000 which is slower but much more portable because uses only
# pure-Python code
try:
Expand All@@ -44,21 +44,28 @@


registered_nodes= []
last_assigned_port=int(random.random()*16384)+49152;
last_assigned_port=int(random.random()*16384)+49152
pg_config_data= {}


"""
Predefined exceptions
"""
classClusterException(Exception):pass
classQueryException(Exception):pass
classClusterException(Exception):
"""
Predefined exceptions
"""
pass


classQueryException(Exception):
"""
Predefined exceptions
"""
pass


"""
Transaction wrapper returned by Node
"""
classNodeConnection(object):
"""
Transaction wrapper returned by Node
"""
def__init__(self,parent_node,dbname):
self.parent_node=parent_node

Expand All@@ -78,21 +85,22 @@ def __exit__(self, type, value, tb):
self.connection.close()

defbegin(self,isolation_level=0):
levels= ['read uncommitted',
'read committed',
'repeatable read',
'serializable']
levels= ['read uncommitted',
'read committed',
'repeatable read',
'serializable']

print(type(isolation_level))
# Check if level is int [0..3]
ifisinstance(isolation_level,int)and \
isolation_levelinrange(0,4):
if(isinstance(isolation_level,int)and
isolation_levelinrange(0,4)):

# Replace index with isolation level type
isolation_level=levels[isolation_level]

# Or it might be a string
elifisinstance(isolation_level,str)and \
str.lower(isolation_level)inlevels:
elif(isinstance(isolation_level,six.text_type)and
isolation_level.lower()inlevels):

# Nothing to do here
pass
Expand DownExpand Up@@ -148,13 +156,13 @@ def error_filename(self):

@property
defconnstr(self):
return"port=%s"%self.port
return"port=%s"%self.port
# return "port=%s host=%s" % (self.port, self.host)

defget_bin_path(self,filename):
""" Returns full path to an executable """
pg_config=get_config()
ifnot"BINDIR"inpg_config:
if"BINDIR"notinpg_config:
returnfilename
else:
return"%s/%s"% (pg_config.get("BINDIR"),filename)
Expand DownExpand Up@@ -403,6 +411,7 @@ def get_username():
""" Returns current user name """
returnpwd.getpwuid(os.getuid())[0]


defget_config():
globalpg_config_data

Expand All@@ -422,19 +431,22 @@ def get_config():

returnpg_config_data


defversion_to_num(version):
"""Converts PostgreSQL version to number for easier comparison"""
importre

ifnotversion:
return0
parts=version.split(".")
whilelen(parts)<3:parts.append("0")
whilelen(parts)<3:
parts.append("0")
num=0
forpartinparts:
num=num*100+int(re.sub("[^\d]","",part))
returnnum


defget_new_node(name):
globalregistered_nodes
globallast_assigned_port
Expand DownExpand Up@@ -462,12 +474,14 @@ def get_new_node(name):

returnnode


defclean_all():
globalregistered_nodes
fornodeinregistered_nodes:
node.cleanup()
registered_nodes= []


defstop_all():
globalregistered_nodes
fornodeinregistered_nodes:
Expand Down
6 changes: 4 additions & 2 deletionstestgres/tests/test_simple.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
importunittest
importtime
fromtestgresimportget_new_node,clean_all,stop_all
# import time
# from testgres import clean_all
fromtestgresimportget_new_node,stop_all


classSimpleTest(unittest.TestCase):

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp