Merge pull request #3 from smackware/supress_noissue_error
Don't continously output errors if no dockers in ps
This commit is contained in:
commit
ce6a07057b
21
main.py
21
main.py
@ -327,18 +327,21 @@ 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)
|
||||||
containers = output.decode().strip().split("\n")
|
if output.strip():
|
||||||
for container in containers:
|
containers = output.decode().strip().split("\n")
|
||||||
parts = container.split("\t")
|
for container in containers:
|
||||||
id, name, image, status = parts[:4]
|
parts = container.split("\t")
|
||||||
ports = parts[4] if len(parts) > 4 else ""
|
id, name, image, status = parts[:4]
|
||||||
item = QTreeWidgetItem([id, name, image, "", ports]) # Empty string for status column
|
ports = parts[4] if len(parts) > 4 else ""
|
||||||
status_widget = StatusDelegate(status)
|
item = QTreeWidgetItem([id, name, image, "", ports]) # Empty string for status column
|
||||||
self.containers_tree.addTopLevelItem(item)
|
status_widget = StatusDelegate(status)
|
||||||
self.containers_tree.setItemWidget(item, 3, status_widget)
|
self.containers_tree.addTopLevelItem(item)
|
||||||
|
self.containers_tree.setItemWidget(item, 3, status_widget)
|
||||||
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))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user