Merge pull request #3 from smackware/supress_noissue_error

Don't continously output errors if no dockers in ps
This commit is contained in:
Salem Yaslem 2024-09-23 14:59:51 +03:00 committed by GitHub
commit ce6a07057b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -327,6 +327,7 @@ class DockerGUI(QMainWindow):
self.containers_tree.clear() self.containers_tree.clear()
try: try:
output = subprocess.check_output(["docker", "ps", "-a", "--format", "{{.ID}}\\t{{.Names}}\\t{{.Image}}\\t{{.Status}}\\t{{.Ports}}"], stderr=subprocess.STDOUT) output = subprocess.check_output(["docker", "ps", "-a", "--format", "{{.ID}}\\t{{.Names}}\\t{{.Image}}\\t{{.Status}}\\t{{.Ports}}"], stderr=subprocess.STDOUT)
if output.strip():
containers = output.decode().strip().split("\n") containers = output.decode().strip().split("\n")
for container in containers: for container in containers:
parts = container.split("\t") parts = container.split("\t")
@ -339,6 +340,8 @@ class DockerGUI(QMainWindow):
self.restore_selection(self.containers_tree, selected_items) self.restore_selection(self.containers_tree, selected_items)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print(f"Error refreshing containers: {e.output.decode()}") print(f"Error refreshing containers: {e.output.decode()}")
except ValueError as e:
print(f"Error parsing container list {repr(containers)}")
except Exception as e: except Exception as e:
print(f"Unexpected error refreshing containers: {str(e)}") print(f"Unexpected error refreshing containers: {str(e)}")
QTimer.singleShot(0, lambda: self.containers_tree.verticalScrollBar().setValue(scroll_position)) QTimer.singleShot(0, lambda: self.containers_tree.verticalScrollBar().setValue(scroll_position))