mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-05-17 13:20:25 -04:00
App skeleton, setuptools and versioning
This commit is contained in:
parent
471cba316a
commit
3dcd9f5c30
8 changed files with 2570 additions and 5 deletions
39
nomadnet/NomadNetworkApp.py
Normal file
39
nomadnet/NomadNetworkApp.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import os
|
||||
import RNS
|
||||
import atexit
|
||||
|
||||
from .vendor.configobj import ConfigObj
|
||||
|
||||
class NomadNetworkApp:
|
||||
_shared_instance = None
|
||||
|
||||
configdir = os.path.expanduser("~")+"/.nomadnetwork"
|
||||
|
||||
def exit_handler():
|
||||
RNS.log("Nomad Network Client exit handler executing...")
|
||||
|
||||
def __init__(self, configdir = None, rnsconfigdir = None):
|
||||
if configdir == None:
|
||||
self.configdir = NomadNetworkApp.configdir
|
||||
else:
|
||||
self.configdir = configdir
|
||||
|
||||
self.rns = RNS.Reticulum(configdir = rnsconfigdir)
|
||||
|
||||
if NomadNetworkApp._shared_instance == None:
|
||||
NomadNetworkApp._shared_instance = self
|
||||
|
||||
atexit.register(self.exit_handler)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_shared_instance():
|
||||
if NomadNetworkApp._shared_instance != None:
|
||||
return NomadNetworkApp._shared_instance
|
||||
else:
|
||||
raise UnboundLocalError("No Nomad Network applications have been instantiated yet")
|
||||
|
||||
|
||||
def quit(self):
|
||||
RNS.log("Nomad Network Client shutting down...")
|
||||
os._exit(0)
|
Loading…
Add table
Add a link
Reference in a new issue