Coverage for lbutils.py: 63%
19 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-04-05 20:41 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-04-05 20:41 +0000
1# The MIT License (MIT)
2#
3# Copyright (c) 2021 RSK Labs Ltd
4#
5# Permission is hereby granted, free of charge, to any person obtaining a copy of
6# this software and associated documentation files (the "Software"), to deal in
7# the Software without restriction, including without limitation the rights to
8# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9# of the Software, and to permit persons to whom the Software is furnished to do
10# so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included in all
13# copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# SOFTWARE.
23import sys
26def main():
27 import runpy
29 utilities = {
30 "load": "loadApp",
31 "delete": "deleteApp",
32 "setupCA": "setupCustomCA",
33 "resetCA": "resetCustomCA",
34 "genCA": "genCAPair",
35 }
37 if len(sys.argv) < 2 or sys.argv[1] not in utilities:
38 commands = ", ".join(utilities.keys())
39 print("Ledgerblue utilities")
40 print(f"usage: {sys.argv[0]} {{{commands}}} [options]")
41 sys.exit(99)
43 try:
44 module = f"ledgerblue.{utilities[sys.argv[1]]}"
45 sys.argv = [f"{sys.argv[0]} {sys.argv[1]}"] + sys.argv[2:]
46 runpy.run_module(module, run_name="__main__")
47 sys.exit(0)
48 except Exception as e:
49 print(f"Error: {str(e)}")
50 sys.exit(1)
53if __name__ == "__main__":
54 main()