Some cleanup

This commit is contained in:
Wim Pomp
2022-08-30 13:23:00 +02:00
parent 225f3fc40a
commit 50b2d12f54

View File

@@ -39,13 +39,13 @@ class Hub(dict):
super().__init__()
self.update({matlab.port: matlab for matlab in self.find_running()})
def find_running(self):
@staticmethod
def find_running():
p = subprocess.run('screen -list', shell=True, capture_output=True)
return [Matlab(port, group) for group, port in re.findall(r'\.matlab_([^_]+)_(\d+)', str(p.stdout))]
def new(self, group=None):
group = re.escape(re.sub(r'[^\w]|_', '', group))
group = re.escape(re.sub(r'\W|_', '', group))
ports = list(range(*config['port_range']))
random.shuffle(ports)
for port in ports: