Skip to content

Commit 73cf932

Browse files
authored
Adjust subprocess calls to use new text arg in addvgridowner (#297)
Adjust subprocess calls to use new `text` arg in `addvgridowner` reusing the similar update to the shared `vgrid` module in PR #292 and syncing minor bits while at it. Follow-up to issue #288.
2 parents 826be11 + 696d000 commit 73cf932

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mig/shared/functionality/addvgridowner.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# --- BEGIN_HEADER ---
55
#
66
# addvgridowner - add one or more vgrid owners
7-
# Copyright (C) 2003-2023 The MiG Project lead by Brian Vinter
7+
# Copyright (C) 2003-2025 The MiG Project by the Science HPC Center at UCPH
88
#
99
# This file is part of MiG.
1010
#
@@ -90,13 +90,15 @@ def add_tracker_admin(configuration, cert_id, vgrid_name, tracker_dir,
9090
'permission', 'add', admin_id, 'TRAC_ADMIN']
9191
_logger.info('provide admin rights to owner: %s' % perms_cmd)
9292
# NOTE: We already verified command variables to be shell-safe
93+
# NOTE: we want utf8-encoded output as text str for find below
9394
proc = subprocess_popen(perms_cmd, stdout=subprocess_pipe,
94-
stderr=subprocess_stdout, env=admin_env)
95-
proc.wait()
96-
if proc.returncode != 0:
95+
stderr=subprocess_stdout, text=True,
96+
env=admin_env)
97+
retval = proc.wait()
98+
if retval != 0:
99+
out = proc.stdout.read()
97100
raise Exception("tracker permissions %s failed: %s (%d)" %
98-
(perms_cmd, proc.stdout.read(),
99-
proc.returncode))
101+
(perms_cmd, out, retval))
100102
return True
101103
except Exception as exc:
102104
_logger.error("failed to give %s tracker admin rights: %s" % (cert_id,

0 commit comments

Comments
 (0)