From 68c221eccea3e3eee16dff8188defcab5510fe43 Mon Sep 17 00:00:00 2001 From: Hugo Posnic Date: Tue, 9 May 2017 20:09:44 +0200 Subject: [PATCH] Handle errors of subprocess --- src/manjaro_hello.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/manjaro_hello.py b/src/manjaro_hello.py index 120c026..926830f 100644 --- a/src/manjaro_hello.py +++ b/src/manjaro_hello.py @@ -54,14 +54,19 @@ class ManjaroHello(): self.window = self.builder.get_object("window") # Subtitle of headerbar - codename = subprocess.Popen("lsb_release -c", stdout=subprocess.PIPE, shell=True).communicate() - codename = codename[0].decode("utf-8").split(":")[1].strip().capitalize() - release = subprocess.Popen("lsb_release -r", stdout=subprocess.PIPE, shell=True).communicate() - release = release[0].decode("utf-8").split(":")[1].strip() - if codename and release: - arch = "64-bits" if sys.maxsize > 2**32 else "32-bits" - subtitle = codename + " " + release + " " + arch - self.builder.get_object("headerbar").props.subtitle = subtitle + try: + codename = subprocess.Popen("lsb_release -c", stdout=subprocess.PIPE, shell=True).communicate() + codename = codename[0].decode("utf-8") + release = subprocess.Popen("lsb_release -r", stdout=subprocess.PIPE, shell=True).communicate() + release = release[0].decode("utf-8") + if ":" in codename and ":" in release: + codename = codename.split(":")[1].strip().capitalize() + release = release.split(":")[1].strip() + arch = "64-bits" if sys.maxsize > 2**32 else "32-bits" + subtitle = codename + " " + release + " " + arch + self.builder.get_object("headerbar").props.subtitle = subtitle + except subprocess.CalledProcessError as e: + pass # Load logo if os.path.isfile(logo_path):