-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.py
40 lines (30 loc) · 999 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import tkinter as tk
import threading
import subprocess
def update_readonly_textbox(textbox: tk.Text, content: str) -> None:
textbox.configure(state=tk.NORMAL)
textbox.delete('1.0', 'end')
textbox.insert('end', content)
textbox.configure(state=tk.DISABLED)
def string_is_float(string: str) -> bool:
try:
float(string)
return True
except ValueError:
return False
# Define a custom Thread class that can return a result
class ThreadWithResult(threading.Thread):
def __init__(self, target, args=()):
super(ThreadWithResult, self).__init__()
self.target = target
self.args = args
self.result = None
def run(self):
self.result = self.target(*self.args)
def check_docker_exists() -> bool:
try:
subprocess.run(["docker", "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return True
except FileNotFoundError:
return False
check_docker_exists()