mirror of
https://github.com/markqvist/NomadNet.git
synced 2024-12-24 22:59:32 -05:00
App skeleton, setuptools and versioning
This commit is contained in:
parent
471cba316a
commit
3dcd9f5c30
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)
|
@ -1,7 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
from .nomadnet import *
|
|
||||||
|
|
||||||
modules = glob.glob(os.path.dirname(__file__)+"/*.py")
|
modules = glob.glob(os.path.dirname(__file__)+"/*.py")
|
||||||
__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]
|
__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]
|
1
nomadnet/_version.py
Normal file
1
nomadnet/_version.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
__version__ = "0.0.1"
|
@ -1,7 +1,39 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from ._version import __version__
|
||||||
|
from .NomadNetworkApp import NomadNetworkApp
|
||||||
|
|
||||||
|
def program_setup(configdir, rnsconfigdir):
|
||||||
|
app = NomadNetworkApp(configdir = configdir, rnsconfigdir = rnsconfigdir)
|
||||||
|
input()
|
||||||
|
app.quit()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
pass
|
try:
|
||||||
|
parser = argparse.ArgumentParser(description="Nomad Network Client")
|
||||||
|
parser.add_argument("--config", action="store", default=None, help="path to alternative Nomad Network config directory", type=str)
|
||||||
|
parser.add_argument("--rnsconfig", action="store", default=None, help="path to alternative Reticulum config directory", type=str)
|
||||||
|
parser.add_argument("--version", action="version", version="Nomad Network Client {version}".format(version=__version__))
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.config:
|
||||||
|
configarg = args.config
|
||||||
|
else:
|
||||||
|
configarg = None
|
||||||
|
|
||||||
|
if args.rnsconfig:
|
||||||
|
rnsconfigarg = args.rnsconfig
|
||||||
|
else:
|
||||||
|
rnsconfigarg = None
|
||||||
|
|
||||||
|
program_setup(configarg, rnsconfigarg)
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("")
|
||||||
|
exit()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
5
nomadnet/ui/__init__.py
Normal file
5
nomadnet/ui/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import os
|
||||||
|
import glob
|
||||||
|
|
||||||
|
modules = glob.glob(os.path.dirname(__file__)+"/*.py")
|
||||||
|
__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]
|
5
nomadnet/vendor/__init__.py
vendored
Normal file
5
nomadnet/vendor/__init__.py
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import os
|
||||||
|
import glob
|
||||||
|
|
||||||
|
modules = glob.glob(os.path.dirname(__file__)+"/*.py")
|
||||||
|
__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]
|
2483
nomadnet/vendor/configobj.py
vendored
Normal file
2483
nomadnet/vendor/configobj.py
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
setup.py
4
setup.py
@ -1,11 +1,13 @@
|
|||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
|
exec(open("nomadnet/_version.py", "r").read())
|
||||||
|
|
||||||
with open("README.md", "r") as fh:
|
with open("README.md", "r") as fh:
|
||||||
long_description = fh.read()
|
long_description = fh.read()
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="nomadnet",
|
name="nomadnet",
|
||||||
version="0.0.1",
|
version=__version__,
|
||||||
author="Mark Qvist",
|
author="Mark Qvist",
|
||||||
author_email="mark@unsigned.io",
|
author_email="mark@unsigned.io",
|
||||||
description="Communicate freely",
|
description="Communicate freely",
|
||||||
|
Loading…
Reference in New Issue
Block a user