From 6aca6d671a1bdf45651c6fbf99d79cd828d255d9 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 4 Feb 2023 17:04:16 +0100 Subject: [PATCH] Add node examples on first run --- nomadnet/NomadNetworkApp.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nomadnet/NomadNetworkApp.py b/nomadnet/NomadNetworkApp.py index 2efa8c1..db94ce9 100644 --- a/nomadnet/NomadNetworkApp.py +++ b/nomadnet/NomadNetworkApp.py @@ -168,11 +168,19 @@ class NomadNetworkApp: RNS.log("Check your configuration file for errors!", RNS.LOG_ERROR) nomadnet.panic() else: + if not os.path.isdir(self.examplespath): + try: + os.makedirs(self.examplespath) + from distutils.dir_util import copy_tree + examplespath = os.path.join(os.path.dirname(__file__), "examples") + copy_tree(examplespath, self.examplespath) + + except Exception as e: + RNS.log("Could not copy examples into the "+self.examplespath+" directory.", RNS.LOG_ERROR) + RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR) + RNS.log("Could not load config file, creating default configuration file...") self.createDefaultConfig() - if not os.path.isdir(self.examplespath): - os.makedirs(self.examplespath) - self.firstrun = True if os.path.isfile(self.identitypath):