aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/examples/howto/groups.py
diff options
context:
space:
mode:
Diffstat (limited to 'lang/python/examples/howto/groups.py')
-rw-r--r--lang/python/examples/howto/groups.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/lang/python/examples/howto/groups.py b/lang/python/examples/howto/groups.py
index 0418abd7..98659cce 100644
--- a/lang/python/examples/howto/groups.py
+++ b/lang/python/examples/howto/groups.py
@@ -37,21 +37,17 @@ if sys.platform == "win32":
else:
gpgconfcmd = "gpgconf --list-options gpg"
-try:
- lines = subprocess.getoutput(gpgconfcmd).splitlines()
-except:
- process = subprocess.Popen(gpgconfcmd.split(), stdout=subprocess.PIPE)
- procom = process.communicate()
- if sys.version_info[0] == 2:
- lines = procom[0].splitlines()
- else:
- lines = procom[0].decode().splitlines()
+process = subprocess.Popen(gpgconfcmd.split(), stdout=subprocess.PIPE)
+procom = process.communicate()
-for i in range(len(lines)):
- if lines[i].startswith("group") is True:
- line = lines[i]
- else:
- pass
+if sys.version_info[0] == 2:
+ lines = procom[0].splitlines()
+else:
+ lines = procom[0].decode().splitlines()
+
+for line in lines:
+ if line.startswith("group") is True:
+ break
groups = line.split(":")[-1].replace('"', '').split(',')