]> granicus.if.org Git - pgbouncer/commitdiff
pycodestyle (PEP8) pass over Python scripts
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 19 Jun 2019 15:11:41 +0000 (17:11 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 19 Jun 2019 15:11:41 +0000 (17:11 +0200)
etc/mkauth.py
test/stress.py

index 58121f8ed2fba8ccd86edf15f0a0d38c6e505f31..8a74a96b2d8fef74d375de1084841037a754a57a 100755 (executable)
@@ -1,6 +1,9 @@
 #! /usr/bin/env python
 
-import sys, os, tempfile, psycopg2
+import sys
+import os
+import tempfile
+import psycopg2
 
 if len(sys.argv) != 3:
     print('usage: mkauth DSTFN CONNSTR')
@@ -20,7 +23,8 @@ curs.execute("select usename, passwd from pg_shadow order by 1")
 lines = []
 for user, psw in curs.fetchall():
     user = user.replace('"', '""')
-    if not psw: psw = ''
+    if not psw:
+        psw = ''
     psw = psw.replace('"', '""')
     lines.append('"%s" "%s" ""\n' % (user, psw))
 db.commit()
@@ -28,7 +32,7 @@ cur = "".join(lines)
 
 # if changed, replace data securely
 if old != cur:
-    fd, tmpfn = tempfile.mkstemp(dir = os.path.split(fn)[0])
+    fd, tmpfn = tempfile.mkstemp(dir=os.path.split(fn)[0])
     f = os.fdopen(fd, 'w')
     f.write(cur)
     f.close()
index 71a9036fac06fe0497e3a76d04189fb16713f407..8796c3dcde6bb6b7fa6c65e0d7106cadfb2e86f0 100755 (executable)
@@ -1,11 +1,16 @@
 #! /usr/bin/env python
 
-import sys, os, re, time, psycopg2
-import threading, thread, random
+import sys
+import os
+import re
+import time
+import psycopg2
+import threading
+import thread
+import random
 
 n_thread = 100
-longtx = 0
-tx_sleep = 0
+longtx = False
 tx_sleep = 8
 
 conn_data = {
@@ -18,12 +23,14 @@ conn_data = {
     'connect_timeout': '5',
 }
 
+
 def get_connstr():
     tmp = []
     for k, v in conn_data.items():
         tmp.append(k+'='+v)
     return " ".join(tmp)
 
+
 class WorkThread(threading.Thread):
     def __init__(self):
         threading.Thread.__init__(self)
@@ -46,7 +53,8 @@ class WorkThread(threading.Thread):
     def run(self):
         try:
             time.sleep(random.random() * 10.0)
-        except: pass
+        except Exception:
+            pass
         while 1:
             try:
                 self.main_loop()
@@ -58,7 +66,8 @@ class WorkThread(threading.Thread):
                 print d
                 try:
                     time.sleep(5)
-                except: pass
+                except Exception:
+                    pass
 
     def main_loop(self):
         db = psycopg2.connect(get_connstr())
@@ -78,6 +87,7 @@ class WorkThread(threading.Thread):
         if longtx:
             db.commit()
 
+
 def main():
     print "connstr", get_connstr()
 
@@ -102,6 +112,7 @@ def main():
             avg = cnt / dur
             print "avg", avg
 
+
 if __name__ == '__main__':
     try:
         main()