From 09c2fbc5a0a770deaaae47dd8fb94495ddc6d5c3 Mon Sep 17 00:00:00 2001 From: Nils <> Date: Thu, 8 Jul 2021 09:34:29 +0200 Subject: [PATCH] Add convenience new-timestamped-session to api --- engine/api.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/engine/api.py b/engine/api.py index bc96090..bb7a830 100644 --- a/engine/api.py +++ b/engine/api.py @@ -23,6 +23,8 @@ along with this program. If not, see . import logging; logger = logging.getLogger(__name__); logger.info("import") #Standard Library +import datetime + #Our Modules from engine.start import PATHS @@ -256,6 +258,23 @@ def getUnfilteredExecutables()->list: #No project running #There is no callback for _sessionsChanged because we poll that in the event loop. +def sessionNewTimestampe(): + """convenience function. Create a new session without requiring a name and add + suggested infrastructure clients""" + nsmExecutables = getNsmExecutables() #type set, cached, very fast. + connectionSaver = METADATA["preferredClients"]["data"] + dataMeta = METADATA["preferredClients"]["connections"] + startclients = [] + if connectionSaver in nsmExecutables: + startclients.append(connectionSaver) + if dataMeta in nsmExecutables: + startclients.append(dataMeta) + + #now = datetime.datetime.now().replace(second=0, microsecond=0).isoformat()[:-3] + now = datetime.datetime.now().replace(microsecond=0).isoformat() + name = now + sessionNew(name, startclients) + def sessionNew(newName:str, startClients:list=[]): nsmServerControl.new(newName, startClients)