/ RNS / Utilities / rnpkg.py
rnpkg.py
 1  #!/usr/bin/env python3
 2  
 3  # Reticulum License
 4  #
 5  # Copyright (c) 2016-2025 Mark Qvist
 6  #
 7  # Permission is hereby granted, free of charge, to any person obtaining a copy
 8  # of this software and associated documentation files (the "Software"), to deal
 9  # in the Software without restriction, including without limitation the rights
10  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  # copies of the Software, and to permit persons to whom the Software is
12  # furnished to do so, subject to the following conditions:
13  #
14  # - The Software shall not be used in any kind of system which includes amongst
15  #   its functions the ability to purposefully do harm to human beings.
16  #
17  # - The Software shall not be used, directly or indirectly, in the creation of
18  #   an artificial intelligence, machine learning or language model training
19  #   dataset, including but not limited to any use that contributes to the
20  #   training or development of such a model or algorithm.
21  #
22  # - The above copyright notice and this permission notice shall be included in
23  #   all copies or substantial portions of the Software.
24  #
25  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  # SOFTWARE.
32  
33  import RNS
34  import argparse
35  import time
36  
37  from RNS._version import __version__
38  
39  def program_setup(configdir, verbosity = 0, quietness = 0, service = False):
40      targetverbosity = verbosity-quietness
41  
42      if service:
43          targetlogdest  = RNS.LOG_FILE
44          targetverbosity = None
45      else:
46          targetlogdest  = RNS.LOG_STDOUT
47  
48      reticulum = RNS.Reticulum(configdir=configdir, verbosity=targetverbosity, logdest=targetlogdest)
49      exit(0)
50  
51  def main():
52      try:
53          parser = argparse.ArgumentParser(description="Reticulum Meta Package Manager")
54          parser.add_argument("--config", action="store", default=None, help="path to alternative Reticulum config directory", type=str)
55          parser.add_argument('-v', '--verbose', action='count', default=0)
56          parser.add_argument('-q', '--quiet', action='count', default=0)
57          parser.add_argument("--exampleconfig", action='store_true', default=False, help="print verbose configuration example to stdout and exit")
58          parser.add_argument("--version", action="version", version="rnpkg {version}".format(version=__version__))
59          
60          args = parser.parse_args()
61  
62          if args.exampleconfig:
63              print(__example_rnpkg_config__)
64              exit()
65  
66          if args.config: configarg = args.config
67          else: configarg = None
68  
69          program_setup(configdir = configarg, verbosity=args.verbose, quietness=args.quiet)
70  
71      except KeyboardInterrupt:
72          print("")
73          exit()
74  
75  __example_rnpkg_config__ = '''# This is an example package manager configuration file.
76  '''
77  
78  if __name__ == "__main__": main()