summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2022-05-27 08:39:54 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2022-05-27 08:39:54 (GMT)
commitf0fec1582434c9218c3a76aef094cc511e353df1 (patch)
tree4b36bf211a5c4bb876a5e44946dbe7fc91dee898
parent003e83457798cc17220f41891cdf1ed9d9568f97 (diff)
downloadmisc-fred-f0fec1582434c9218c3a76aef094cc511e353df1.zip
misc-fred-f0fec1582434c9218c3a76aef094cc511e353df1.tar.gz
misc-fred-f0fec1582434c9218c3a76aef094cc511e353df1.tar.bz2
munin: update for python 3 (#63779)
-rwxr-xr-xmunin/authentic_count_8
-rw-r--r--munin/authentic_count_cmd.py6
-rwxr-xr-xmunin/publik_count20
-rwxr-xr-xmunin/publik_count_24
4 files changed, 29 insertions, 29 deletions
diff --git a/munin/authentic_count_ b/munin/authentic_count_
index dbf94c8..96a4b90 100755
--- a/munin/authentic_count_
+++ b/munin/authentic_count_
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
import os
import sys
@@ -6,16 +6,16 @@ import sys
tenant = os.path.basename(sys.argv[0]).replace('authentic_count_', '')
if len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
- print 'yes'
+ print('yes')
sys.exit(0)
if len(sys.argv) == 2 and sys.argv[1] == 'config':
- print '''graph_title Count of users for %s
+ print('''graph_title Count of users for %s
graph_category entrouvert
total_count.label Total
total_logged_count.label Total once logged
fc_count.label Total FC
-''' % tenant
+''' % tenant)
sys.exit(0)
os.system('machinectl shell authentic.node1.prod.saas.entrouvert.org /usr/bin/authentic2-multitenant-manage tenant_command runscript /home/fred//misc-fred/munin/authentic_count_cmd.py compute -d %s' % tenant)
diff --git a/munin/authentic_count_cmd.py b/munin/authentic_count_cmd.py
index b36acac..660216f 100644
--- a/munin/authentic_count_cmd.py
+++ b/munin/authentic_count_cmd.py
@@ -8,6 +8,6 @@ total_user_count = User.objects.filter(userexternalid__isnull=True, ).count()
total_logged_count = User.objects.filter(userexternalid__isnull=True, last_login__isnull=False).count()
fc_count = FcAccount.objects.all().count()
-print 'total_count.value', total_user_count
-print 'total_logged_count.value', total_logged_count
-print 'fc_count.value', fc_count
+print('total_count.value', total_user_count)
+print('total_logged_count.value', total_logged_count)
+print('fc_count.value', fc_count)
diff --git a/munin/publik_count b/munin/publik_count
index 0cedd7f..1d127b0 100755
--- a/munin/publik_count
+++ b/munin/publik_count
@@ -1,8 +1,8 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
#%# family=auto
#%# capabilities=autoconf
-import cPickle
+import pickle
import os
import psycopg2
import itertools
@@ -16,16 +16,16 @@ for dirname in os.listdir('/var/lib/machines/'):
if len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
if base_dir:
- print 'yes'
+ print('yes')
else:
- print 'no'
+ print('no')
sys.exit(0)
if len(sys.argv) == 2 and sys.argv[1] == 'config':
- print '''graph_title Count of submitted forms
+ print('''graph_title Count of submitted forms
graph_category entrouvert
count.label Count
-'''
+''')
sys.exit(0)
total = 0
@@ -37,12 +37,12 @@ for tenant in itertools.chain(os.listdir(base_dir), os.listdir(os.path.join(base
continue
if not os.path.isdir(os.path.join(base_dir, tenant)):
continue
- cfg = cPickle.load(open(os.path.join(base_dir, tenant, 'config.pck')))
- if not 'postgresql' in cfg:
+ cfg = pickle.load(open(os.path.join(base_dir, tenant, 'config.pck'), 'rb'), encoding='utf-8')
+ if 'postgresql' not in cfg:
continue
psql_cfg = {}
for k, v in cfg['postgresql'].items():
- if v and isinstance(v, basestring):
+ if v and isinstance(v, (int, str)):
psql_cfg[k] = v
pgconn = psycopg2.connect(**psql_cfg)
cur = pgconn.cursor()
@@ -54,4 +54,4 @@ for tenant in itertools.chain(os.listdir(base_dir), os.listdir(os.path.join(base
total += cur.fetchone()[0]
pgconn.close()
-print 'count.value', total
+print('count.value', total)
diff --git a/munin/publik_count_ b/munin/publik_count_
index 37679a9..173c38c 100755
--- a/munin/publik_count_
+++ b/munin/publik_count_
@@ -1,8 +1,8 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
#%# family=auto
#%# capabilities=autoconf
-import cPickle
+import pickle
import itertools
import os
import psycopg2
@@ -16,31 +16,31 @@ for dirname in os.listdir('/var/lib/machines/'):
if len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
if base_dir:
- print 'yes'
+ print('yes')
else:
- print 'no'
+ print('no')
sys.exit(0)
tenant = os.path.basename(sys.argv[0]).replace('publik_count_', '')
if len(sys.argv) == 2 and sys.argv[1] == 'config':
- print '''graph_title Count of forms for %s
+ print('''graph_title Count of forms for %s
graph_category entrouvert
total_count.label Total
total_user_count.label Front
total_logged_user_count.label Front by logged user
-''' % tenant
+''' % tenant)
sys.exit(0)
for tenant_dir in itertools.chain(os.listdir(base_dir), os.listdir(os.path.join(base_dir, 'tenants'))):
if tenant_dir != tenant:
continue
- cfg = cPickle.load(open(os.path.join(base_dir, tenant, 'config.pck')))
- if not 'postgresql' in cfg:
+ cfg = pickle.load(open(os.path.join(base_dir, tenant, 'config.pck'), 'rb'), encoding='utf-8')
+ if 'postgresql' not in cfg:
continue
psql_cfg = {}
for k, v in cfg['postgresql'].items():
- if v and isinstance(v, basestring):
+ if v and isinstance(v, (int, str)):
psql_cfg[k] = v
pgconn = psycopg2.connect(**psql_cfg)
cur = pgconn.cursor()
@@ -53,8 +53,8 @@ for tenant_dir in itertools.chain(os.listdir(base_dir), os.listdir(os.path.join(
cur.execute('''SELECT COUNT(*) from wcs_all_forms WHERE status != 'draft' AND backoffice_submission = FALSE AND user_id is not NULL''')
total_logged_user_count = cur.fetchone()[0]
- print 'total_count.value', total_count
- print 'total_user_count.value', total_user_count
- print 'total_logged_user_count.value', total_logged_user_count
+ print('total_count.value', total_count)
+ print('total_user_count.value', total_user_count)
+ print('total_logged_user_count.value', total_logged_user_count)
pgconn.close()
break