autoverse-cli 0.1.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- autoverse_cli-0.1.0.dist-info/LICENSE +33 -0
- autoverse_cli-0.1.0.dist-info/METADATA +47 -0
- autoverse_cli-0.1.0.dist-info/RECORD +25 -0
- autoverse_cli-0.1.0.dist-info/WHEEL +5 -0
- autoverse_cli-0.1.0.dist-info/entry_points.txt +2 -0
- autoverse_cli-0.1.0.dist-info/top_level.txt +1 -0
- avrs/__init__.py +0 -0
- avrs/app_version.py +24 -0
- avrs/avrs.py +64 -0
- avrs/cfg.py +26 -0
- avrs/launcher.py +164 -0
- avrs/launcher_util.py +158 -0
- avrs/requests/can.py +131 -0
- avrs/requests/demo.py +23 -0
- avrs/requests/input.py +46 -0
- avrs/requests/log_path.py +28 -0
- avrs/requests/move_to_landmark.py +16 -0
- avrs/requests/npc.py +289 -0
- avrs/requests/request.py +45 -0
- avrs/requests/reserve_mv_slot.py +111 -0
- avrs/requests/reset_to_track.py +12 -0
- avrs/requests/restart.py +12 -0
- avrs/requests/teleport.py +20 -0
- avrs/requests/vd.py +33 -0
- avrs/tests.py +9 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
# End-User License Agreement (EULA) of the Autonoma AutoVerse CLI
|
2
|
+
|
3
|
+
This End-User License Agreement ("EULA") is a legal agreement between you and Autonoma, Inc.
|
4
|
+
|
5
|
+
## License Grant
|
6
|
+
|
7
|
+
Autonoma, Inc. hereby grants you a personal, non-transferable, non-exclusive licence to use the AutoVerse software in accordance with the terms of this EULA agreement.
|
8
|
+
|
9
|
+
## Limitation of Liability
|
10
|
+
The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of the software.
|
11
|
+
|
12
|
+
### You are NOT permitted to:
|
13
|
+
|
14
|
+
- Edit, alter, modify, adapt, translate or otherwise change the whole or any part of the Software nor permit the whole or any part of the Software to be combined with or become incorporated in any other software, nor decompile, disassemble or reverse engineer the Software or attempt to do any such things
|
15
|
+
- Reproduce, copy, distribute, resell or otherwise use the Software for any commercial purpose
|
16
|
+
- Allow any third party to use the Software on behalf of or for the benefit of any third party
|
17
|
+
- Use the Software in any way which breaches any applicable local, national or international law
|
18
|
+
use the Software for any purpose that Autonoma, Inc. considers is a breach of this EULA agreement
|
19
|
+
Intellectual Property and Ownership
|
20
|
+
|
21
|
+
Autonoma, Inc. shall at all times retain ownership of the Software as originally downloaded by you and all subsequent downloads of the Software by you. The Software (and the copyright, and other intellectual property rights of whatever nature in the Software, including any modifications made thereto) are and shall remain the property of Autonoma, Inc.
|
22
|
+
|
23
|
+
Autonoma, Inc. reserves the right to grant licences to use the Software to third parties.
|
24
|
+
|
25
|
+
## Termination
|
26
|
+
|
27
|
+
This EULA agreement is effective from the date you first use the Software and shall continue until terminated. You may terminate it at any time upon written notice to Autonoma, Inc.
|
28
|
+
|
29
|
+
It will also terminate immediately if you fail to comply with any term of this EULA agreement. Upon such termination, the licenses granted by this EULA agreement will immediately terminate and you agree to stop all access and use of the Software. The provisions that by their nature continue and survive will survive any termination of this EULA agreement.
|
30
|
+
|
31
|
+
## Governing Law
|
32
|
+
|
33
|
+
This EULA agreement, and any dispute arising out of or in connection with this EULA agreement, shall be governed by and construed in accordance with the laws of the USA.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: autoverse-cli
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: The Autoverse CLI
|
5
|
+
Author-email: Dan Kamrath <dan.kamrath@autonomalabs.com>
|
6
|
+
License: # End-User License Agreement (EULA) of the Autonoma AutoVerse CLI
|
7
|
+
|
8
|
+
This End-User License Agreement ("EULA") is a legal agreement between you and Autonoma, Inc.
|
9
|
+
|
10
|
+
## License Grant
|
11
|
+
|
12
|
+
Autonoma, Inc. hereby grants you a personal, non-transferable, non-exclusive licence to use the AutoVerse software in accordance with the terms of this EULA agreement.
|
13
|
+
|
14
|
+
## Limitation of Liability
|
15
|
+
The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of the software.
|
16
|
+
|
17
|
+
### You are NOT permitted to:
|
18
|
+
|
19
|
+
- Edit, alter, modify, adapt, translate or otherwise change the whole or any part of the Software nor permit the whole or any part of the Software to be combined with or become incorporated in any other software, nor decompile, disassemble or reverse engineer the Software or attempt to do any such things
|
20
|
+
- Reproduce, copy, distribute, resell or otherwise use the Software for any commercial purpose
|
21
|
+
- Allow any third party to use the Software on behalf of or for the benefit of any third party
|
22
|
+
- Use the Software in any way which breaches any applicable local, national or international law
|
23
|
+
use the Software for any purpose that Autonoma, Inc. considers is a breach of this EULA agreement
|
24
|
+
Intellectual Property and Ownership
|
25
|
+
|
26
|
+
Autonoma, Inc. shall at all times retain ownership of the Software as originally downloaded by you and all subsequent downloads of the Software by you. The Software (and the copyright, and other intellectual property rights of whatever nature in the Software, including any modifications made thereto) are and shall remain the property of Autonoma, Inc.
|
27
|
+
|
28
|
+
Autonoma, Inc. reserves the right to grant licences to use the Software to third parties.
|
29
|
+
|
30
|
+
## Termination
|
31
|
+
|
32
|
+
This EULA agreement is effective from the date you first use the Software and shall continue until terminated. You may terminate it at any time upon written notice to Autonoma, Inc.
|
33
|
+
|
34
|
+
It will also terminate immediately if you fail to comply with any term of this EULA agreement. Upon such termination, the licenses granted by this EULA agreement will immediately terminate and you agree to stop all access and use of the Software. The provisions that by their nature continue and survive will survive any termination of this EULA agreement.
|
35
|
+
|
36
|
+
## Governing Law
|
37
|
+
|
38
|
+
This EULA agreement, and any dispute arising out of or in connection with this EULA agreement, shall be governed by and construed in accordance with the laws of the USA.
|
39
|
+
Classifier: Programming Language :: Python :: 3
|
40
|
+
Classifier: Operating System :: OS Independent
|
41
|
+
Requires-Python: >=3.8
|
42
|
+
Description-Content-Type: text/markdown
|
43
|
+
License-File: LICENSE
|
44
|
+
|
45
|
+
# Autoverse CLI
|
46
|
+
|
47
|
+
The new implementation of the Autoverse CLI
|
@@ -0,0 +1,25 @@
|
|
1
|
+
avrs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
avrs/app_version.py,sha256=IMNk3KcKKU_iCO3_a4aH4CJfsV65qWg4IeipZY8u8Kg,855
|
3
|
+
avrs/avrs.py,sha256=zkpQRKRFdhN6rmdRGQDPIU6vA5DSH8GZmmEm_w1y3Ro,1655
|
4
|
+
avrs/cfg.py,sha256=9NBtPrJjVN7gj_vxlvO4wOEx3OFw4d2qQgLIVLiccD0,701
|
5
|
+
avrs/launcher.py,sha256=PndqVBIswgh7fAUj8_5v3zUPq035Ats88GAv9p3z3c8,7244
|
6
|
+
avrs/launcher_util.py,sha256=X60Jd2JUXr1MmdEF0lwjUBC5gHZte9uLlSgLWOLofXc,5121
|
7
|
+
avrs/tests.py,sha256=3JeYBjn0tRqHXERDROfzmYuW1KXeCcKur5Bw-EIegto,153
|
8
|
+
avrs/requests/can.py,sha256=iL2Dsk-V4tm37D-F1QoauaxeQtLAbg5br7zJcoR9h0o,5295
|
9
|
+
avrs/requests/demo.py,sha256=TksvKX5YmL8-FQ4h7MWwjyIwcaZQrF9vCQ20PdfgS3Q,1138
|
10
|
+
avrs/requests/input.py,sha256=SkfVjk3LsOhYNXEwn0rcSS6kZK3g8DXoMPX8Zc9LnCo,1855
|
11
|
+
avrs/requests/log_path.py,sha256=Ur24C9VqPVx78MfpicgQu2uOEe-0dXbGoWF_7dzMtZE,1326
|
12
|
+
avrs/requests/move_to_landmark.py,sha256=cLRBKu9XEDsmCoftBJ8JwoBLqzb0IZsxFMBnus4T-kc,702
|
13
|
+
avrs/requests/npc.py,sha256=Y_WovbcLomCCcOLAMMO_DHZtc1crAzWo97qEIGS3SvU,9691
|
14
|
+
avrs/requests/request.py,sha256=d0DB8tXXK9iQI-j5WmCNWA0f_8B6zU6gWeTLNHpwh_w,1511
|
15
|
+
avrs/requests/reserve_mv_slot.py,sha256=51MuiQgu22NF4wl-Y-0wjvozIpe1GPBBk_QfvG7FS4k,3763
|
16
|
+
avrs/requests/reset_to_track.py,sha256=lSd2YavBxDV_hQMhVoi08_TpTFEq7G2MA18xosFYa1g,450
|
17
|
+
avrs/requests/restart.py,sha256=ih5mnWiU34q3-xhOth45CtOUXxKI0PoMDCnFJV0JbwE,415
|
18
|
+
avrs/requests/teleport.py,sha256=Y0pAQ4DjqtWTkr_E1QDvvl22EiTpoA4u69dhks0qcZw,825
|
19
|
+
avrs/requests/vd.py,sha256=ZF00jJ0VUVPwnLABp_LiDg3UDC4kvxeLg1dqh7wJrzQ,1414
|
20
|
+
autoverse_cli-0.1.0.dist-info/LICENSE,sha256=d4eWXho-u18HkBsX4K21uHX_bBb2UXZSrJdsb7Z_JlM,2647
|
21
|
+
autoverse_cli-0.1.0.dist-info/METADATA,sha256=9cFqdZUtM2wyuces-IP1euA035ZGB_tUImoXsxTyDDs,3296
|
22
|
+
autoverse_cli-0.1.0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
23
|
+
autoverse_cli-0.1.0.dist-info/entry_points.txt,sha256=Cb9qsUyU5AKkklehCcvtfT0-N3SXbUEqvjze4iEU5kE,40
|
24
|
+
autoverse_cli-0.1.0.dist-info/top_level.txt,sha256=-AJO2e4MCVej6hY0U84pu5NfMeMW5qaAPSMisDT5rmA,5
|
25
|
+
autoverse_cli-0.1.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
avrs
|
avrs/__init__.py
ADDED
File without changes
|
avrs/app_version.py
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
import http.client
|
2
|
+
import json
|
3
|
+
|
4
|
+
def get_app_version():
|
5
|
+
return '0.1.0'
|
6
|
+
|
7
|
+
def check_app_is_latest():
|
8
|
+
pass
|
9
|
+
# contact API to examine version
|
10
|
+
|
11
|
+
# This is slow, which will make the CLI annoying to use. This means
|
12
|
+
# we need an approach that can try to do this in the background and then
|
13
|
+
# caches somewhere so that the user is notified on the next run
|
14
|
+
|
15
|
+
# api_url = 'zn5boqqk60.execute-api.us-east-1.amazonaws.com'
|
16
|
+
|
17
|
+
# connection = http.client.HTTPSConnection(api_url)
|
18
|
+
# headers = {'Content-type': 'application/json'}
|
19
|
+
# body = json.dumps({'hello': 'hello'}).encode('utf-8')
|
20
|
+
# connection.request('POST', '/test', body, headers)
|
21
|
+
# response = connection.getresponse()
|
22
|
+
# if response.status != 200:
|
23
|
+
# print('response had status code {}'.format(response))
|
24
|
+
# print('{}'.format(response.read().decode('utf-8')))
|
avrs/avrs.py
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
import argparse
|
3
|
+
from argparse import RawDescriptionHelpFormatter
|
4
|
+
from argparse import RawTextHelpFormatter
|
5
|
+
|
6
|
+
from avrs.app_version import *
|
7
|
+
from avrs.cfg import *
|
8
|
+
from avrs.launcher import *
|
9
|
+
|
10
|
+
from avrs.requests.move_to_landmark import MoveToLandmarkRequest
|
11
|
+
from avrs.requests.restart import Restart
|
12
|
+
from avrs.requests.reset_to_track import ResetToTrack
|
13
|
+
from avrs.requests.teleport import Teleport
|
14
|
+
#from src.requests.can import Can
|
15
|
+
from avrs.requests.npc import Npc
|
16
|
+
from avrs.requests.reserve_mv_slot import ReserveMvSlot
|
17
|
+
from avrs.requests.vd import Vd
|
18
|
+
from avrs.requests.input import InputRequest
|
19
|
+
from avrs.requests.log_path import LogPath
|
20
|
+
from avrs.requests.demo import AvrsDemoRequest
|
21
|
+
|
22
|
+
|
23
|
+
def get_version():
|
24
|
+
return get_app_version()
|
25
|
+
|
26
|
+
def main():
|
27
|
+
parser = argparse.ArgumentParser(
|
28
|
+
prog='avrs',
|
29
|
+
description='Autoverse CLI',
|
30
|
+
epilog='',
|
31
|
+
formatter_class=RawDescriptionHelpFormatter)
|
32
|
+
|
33
|
+
version_psr = parser.add_argument(
|
34
|
+
'--version',
|
35
|
+
help='show the cli version',
|
36
|
+
action='version',
|
37
|
+
version=get_version())
|
38
|
+
|
39
|
+
sps = parser.add_subparsers(required=True, help='sub-command help')
|
40
|
+
|
41
|
+
cfg = load_cfg('avrs')
|
42
|
+
check_app_is_latest()
|
43
|
+
|
44
|
+
AvrsLauncher(sps, cfg)
|
45
|
+
|
46
|
+
|
47
|
+
MoveToLandmarkRequest(sps, cfg)
|
48
|
+
Restart(sps, cfg)
|
49
|
+
ResetToTrack(sps, cfg)
|
50
|
+
#Can(sps, cfg)
|
51
|
+
Teleport(sps, cfg)
|
52
|
+
Npc(sps, cfg)
|
53
|
+
ReserveMvSlot(sps, cfg)
|
54
|
+
Vd(sps, cfg)
|
55
|
+
#InputRequest(sps, cfg)
|
56
|
+
LogPath(sps, cfg)
|
57
|
+
#AvrsDemoRequest(sps, cfg)
|
58
|
+
|
59
|
+
|
60
|
+
args = parser.parse_args()
|
61
|
+
args.func(args)
|
62
|
+
|
63
|
+
if __name__ == '__main__':
|
64
|
+
main()
|
avrs/cfg.py
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
import json
|
2
|
+
import os
|
3
|
+
|
4
|
+
def get_cfg_dir(cli_name):
|
5
|
+
return os.path.join(os.environ['HOME'], '.config', cli_name)
|
6
|
+
|
7
|
+
def get_cfg_file(cli_name):
|
8
|
+
return os.path.join(get_cfg_dir(cli_name), 'config.json')
|
9
|
+
|
10
|
+
def load_cfg(cli_name):
|
11
|
+
cfg_dir = get_cfg_dir(cli_name)
|
12
|
+
if not os.path.exists(cfg_dir):
|
13
|
+
os.makedirs(cfg_dir)
|
14
|
+
|
15
|
+
cfg_path = get_cfg_file(cli_name)
|
16
|
+
cfg = {}
|
17
|
+
|
18
|
+
if os.path.exists(cfg_path):
|
19
|
+
with open(cfg_path, 'r', encoding='utf-8') as f:
|
20
|
+
cfg = json.load(f)
|
21
|
+
return cfg
|
22
|
+
|
23
|
+
def save_cfg(cli_name, cfg):
|
24
|
+
cfg_path = get_cfg_file(cli_name)
|
25
|
+
with open(cfg_path, 'w', encoding='utf-8') as f:
|
26
|
+
json.dump(cfg, f, ensure_ascii=False, indent=4)
|
avrs/launcher.py
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
import os
|
2
|
+
import json
|
3
|
+
import http.client
|
4
|
+
import boto3
|
5
|
+
from avrs.cfg import *
|
6
|
+
from avrs.launcher_util import *
|
7
|
+
|
8
|
+
class AvrsLauncher:
|
9
|
+
def __init__(self, parent_parser, cfg):
|
10
|
+
self.cfg = cfg
|
11
|
+
provision_parser = parent_parser.add_parser(
|
12
|
+
'launcher',
|
13
|
+
help='launcher operations, such as license registration or updating a sim install')
|
14
|
+
sps = provision_parser.add_subparsers(required=True, help='launcher options')
|
15
|
+
|
16
|
+
register_license_psr = sps.add_parser(
|
17
|
+
'register-license',
|
18
|
+
help='registers a user license, allowing certain functionaility')
|
19
|
+
register_license_psr.add_argument(
|
20
|
+
'license_path',
|
21
|
+
help='the path to the license file to register')
|
22
|
+
register_license_psr.set_defaults(func=self.register_license)
|
23
|
+
|
24
|
+
license_status_psr = sps.add_parser(
|
25
|
+
'license-status',
|
26
|
+
help='shows information related to a user license')
|
27
|
+
license_status_psr.set_defaults(func=self.license_status)
|
28
|
+
|
29
|
+
get_latest_psr = sps.add_parser(
|
30
|
+
'get-latest-sim-version',
|
31
|
+
help='ask the build info api for the latest sim version')
|
32
|
+
get_latest_psr.set_defaults(func=self.get_latest_sim_version)
|
33
|
+
|
34
|
+
download_sim_psr = sps.add_parser('download-simulator', help='download the simulator')
|
35
|
+
download_sim_psr.add_argument('install_path', help='path to install the simulator')
|
36
|
+
download_sim_psr.add_argument(
|
37
|
+
'--copy-saved-from',
|
38
|
+
default='',
|
39
|
+
help='path to an existing installation from which to copy saved information')
|
40
|
+
download_sim_psr.add_argument(
|
41
|
+
'--update-existing',
|
42
|
+
action='store_true',
|
43
|
+
help='indicates that the user understands that they are updating an existing installation')
|
44
|
+
download_sim_psr.set_defaults(func=self.download_simulator)
|
45
|
+
|
46
|
+
def register_license(self, args):
|
47
|
+
print('Trying to Register License File: {}'.format(args.license_path))
|
48
|
+
|
49
|
+
# Load and validate provided license file
|
50
|
+
license_ok, license_status, license = validate_license_file(args.license_path)
|
51
|
+
if not license_ok:
|
52
|
+
print('Error Reading License File: {}'.format(license_status))
|
53
|
+
return
|
54
|
+
|
55
|
+
# Cache license info in config
|
56
|
+
license_name = os.path.basename(args.license_path)
|
57
|
+
self.cfg['license'] = {
|
58
|
+
'filename': os.path.basename(license_name),
|
59
|
+
'data': license
|
60
|
+
}
|
61
|
+
save_cfg('avrs', self.cfg)
|
62
|
+
print('License Registration Success: {}'.format(self.cfg['license']['filename']))
|
63
|
+
|
64
|
+
# Try to exchange license info for download keys
|
65
|
+
print('Retrieving Launcher Download Keys...')
|
66
|
+
(dl_keys_ok, dl_keys_status, self.cfg) = try_get_launcher_download_keys(self.cfg)
|
67
|
+
if not dl_keys_ok:
|
68
|
+
print('Error Getting Launcher Download Keys: {}'.format(dl_keys_status))
|
69
|
+
return
|
70
|
+
save_cfg('avrs', self.cfg)
|
71
|
+
print('Download Key Retrieval Success')
|
72
|
+
|
73
|
+
def license_status(self, args):
|
74
|
+
status = get_launcher_license_status_string(self.cfg)
|
75
|
+
print('Launcher License Status: {}'.format(status))
|
76
|
+
|
77
|
+
def get_available_sim_versions(self, args):
|
78
|
+
pass
|
79
|
+
|
80
|
+
# query something to find out what versions of the sim we can download
|
81
|
+
|
82
|
+
def get_latest_sim_version(self, args):
|
83
|
+
# Validate status of download keys
|
84
|
+
dl_keys_ok, dl_keys_status = has_launcher_download_keys(self.cfg)
|
85
|
+
if not dl_keys_ok:
|
86
|
+
print('Launcher Download Keys Error: {}'.format(dl_keys_status))
|
87
|
+
return
|
88
|
+
|
89
|
+
# Get latest build info from API
|
90
|
+
build_info_ok, build_info_status, latest_version, latest_url = get_launcher_build_info(self.cfg)
|
91
|
+
if not build_info_ok:
|
92
|
+
print('Error Getting Latest Version Info: {}'.format(build_info_status))
|
93
|
+
return
|
94
|
+
print('{}'.format(latest_version))
|
95
|
+
|
96
|
+
def download_simulator(self, args):
|
97
|
+
|
98
|
+
file_path = args.install_path
|
99
|
+
if not os.path.exists(file_path):
|
100
|
+
print('Cannot Install Simulator at: {} (Invalid Path)'.format(file_path))
|
101
|
+
return
|
102
|
+
|
103
|
+
# Validate status of download keys
|
104
|
+
dl_keys_ok, dl_keys_status = has_launcher_download_keys(self.cfg)
|
105
|
+
if not dl_keys_ok:
|
106
|
+
print('Launcher Download Keys Error: {}'.format(dl_keys_status))
|
107
|
+
return
|
108
|
+
|
109
|
+
# Get latest build info from API
|
110
|
+
build_info_ok, build_info_status, latest_version, latest_url = get_launcher_build_info(self.cfg)
|
111
|
+
if not build_info_ok:
|
112
|
+
print('Error Getting Latest Version Info: {}'.format(build_info_status))
|
113
|
+
return
|
114
|
+
|
115
|
+
# If we want to copy saved info from another installation
|
116
|
+
copy_saved = False
|
117
|
+
copy_saved_cache = ''
|
118
|
+
if args.copy_saved_from != '':
|
119
|
+
if not is_installed_sim(args.copy_saved_from):
|
120
|
+
print('The Path: {} Is not an Existing Installation. Cannot Copy Saved'.format(args.copy_saved_from))
|
121
|
+
return
|
122
|
+
else:
|
123
|
+
copy_saved = True
|
124
|
+
|
125
|
+
if copy_saved:
|
126
|
+
print('Caching Saved from Existing Installation at: {}'.format(args.copy_saved_from))
|
127
|
+
copy_from_saved_dir = os.path.join(args.copy_saved_from, 'Linux', 'Autoverse', 'Saved')
|
128
|
+
copy_saved_cache = os.path.join(args.install_path, 'autoverse-saved-cache')
|
129
|
+
shutil.copytree(copy_from_saved_dir, copy_saved_cache)
|
130
|
+
|
131
|
+
package_zip_name = 'autoverse-linux-{}.zip'.format(latest_version)
|
132
|
+
package_name = 'autoverse-linux'
|
133
|
+
bucket_path = 'mainline/{}'.format(package_zip_name)
|
134
|
+
dl_path = os.path.join(args.install_path, package_zip_name)
|
135
|
+
unzip_path = os.path.join(args.install_path, package_name)
|
136
|
+
|
137
|
+
if is_installed_sim(unzip_path) and not args.update_existing:
|
138
|
+
print('''
|
139
|
+
Downloading at {} will update an existing installation and override its saved information.
|
140
|
+
make sure you have backups of any configuration or use the --copy-saved-from option.
|
141
|
+
If you are sure, re-run with the --update-existing flag
|
142
|
+
'''.format(unzip_path))
|
143
|
+
return
|
144
|
+
|
145
|
+
print('Downloading {} to {}. This May Take Several Minutes Depending on Connection Speed'.format(bucket_path, dl_path))
|
146
|
+
#download_simulator_archive(self.cfg, bucket_path, dl_path)
|
147
|
+
|
148
|
+
print('Extracting {} to {}'.format(dl_path, unzip_path))
|
149
|
+
shutil.unpack_archive(dl_path, unzip_path)
|
150
|
+
|
151
|
+
if copy_saved:
|
152
|
+
print('Migrating Saved Files')
|
153
|
+
shutil.copytree(copy_saved_cache, os.path.join(unzip_path, 'Linux', 'Autoverse', 'Saved'), dirs_exist_ok=True)
|
154
|
+
shutil.rmtree(copy_saved_cache)
|
155
|
+
|
156
|
+
# Install license if missing
|
157
|
+
if not copy_saved:
|
158
|
+
print('Installing Registered License: {}'.format(self.cfg['license']['filename']))
|
159
|
+
license_install_path = os.path.join(unzip_path, 'Linux', 'Autoverse', 'Saved', self.cfg['license']['filename'])
|
160
|
+
with open(license_install_path, 'w', encoding='utf-8') as f:
|
161
|
+
json.dump(self.cfg['license']['data'], f, ensure_ascii=False, indent=4)
|
162
|
+
|
163
|
+
print('Cleaning up')
|
164
|
+
os.remove(dl_path)
|
avrs/launcher_util.py
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
import os
|
2
|
+
import json
|
3
|
+
import http.client
|
4
|
+
import boto3
|
5
|
+
import sys
|
6
|
+
import shutil
|
7
|
+
|
8
|
+
def validate_license_file(file_path):
|
9
|
+
"""
|
10
|
+
Given file path, load and validate license info. Returns tuple of bool
|
11
|
+
indicating success, string for status, and dict of license info from file
|
12
|
+
"""
|
13
|
+
status = ''
|
14
|
+
license = {}
|
15
|
+
|
16
|
+
# Ensure it's a file
|
17
|
+
if not os.path.isfile(file_path):
|
18
|
+
status = 'no license file at {}'.format(file_path)
|
19
|
+
return (False, status, license)
|
20
|
+
|
21
|
+
# Parse it and check format
|
22
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
23
|
+
license = json.load(f)
|
24
|
+
|
25
|
+
if 'id' not in license:
|
26
|
+
status = 'malformed license file. missing id field'
|
27
|
+
return (False, status, license)
|
28
|
+
if 'public_key' not in license:
|
29
|
+
status = 'malformed license file. missing public key field'
|
30
|
+
return (False, status, license)
|
31
|
+
if 'shipping_signature' not in license:
|
32
|
+
status = 'malformed license file. missing shipping signature'
|
33
|
+
return (False, status, license)
|
34
|
+
return (True, status, license)
|
35
|
+
|
36
|
+
|
37
|
+
def try_get_launcher_download_keys(cfg):
|
38
|
+
"""
|
39
|
+
Uses license info stored in config to requrest download keys from API.
|
40
|
+
These keys can be used to authenticate downloads from bucket
|
41
|
+
"""
|
42
|
+
status = ''
|
43
|
+
out_cfg = cfg
|
44
|
+
|
45
|
+
api_url = 'uu6fmbvrhk.execute-api.us-east-1.amazonaws.com'
|
46
|
+
connection = http.client.HTTPSConnection(api_url)
|
47
|
+
headers = {'Content-type': 'application/json'}
|
48
|
+
body = json.dumps({
|
49
|
+
'id': cfg['license']['data']['id'],
|
50
|
+
'licenseSignature': cfg['license']['data']['shipping_signature']
|
51
|
+
}).encode('utf-8')
|
52
|
+
connection.request('POST', '/test', body, headers)
|
53
|
+
response = connection.getresponse()
|
54
|
+
if response.status != 200:
|
55
|
+
status = 'response had status code {}'.format(response)
|
56
|
+
return (False, status, out_cfg)
|
57
|
+
dlinfo = json.loads(json.loads(response.read().decode('utf-8'))['body'])
|
58
|
+
|
59
|
+
out_cfg['dlkey_id'] = dlinfo['dlkey_id']
|
60
|
+
out_cfg['dlkey'] = dlinfo['dlkey']
|
61
|
+
return (True, status, out_cfg)
|
62
|
+
|
63
|
+
def has_launcher_download_keys(cfg):
|
64
|
+
"""
|
65
|
+
Checks for required config values for download keys
|
66
|
+
"""
|
67
|
+
status = ''
|
68
|
+
if 'dlkey_id' not in cfg or 'dlkey' not in cfg:
|
69
|
+
status += 'Config has no Download Keys'
|
70
|
+
return (False, status)
|
71
|
+
return (True, status)
|
72
|
+
|
73
|
+
def get_launcher_license_status_string(cfg):
|
74
|
+
"""
|
75
|
+
Builds a string representation of where the CLI stands
|
76
|
+
as far as being configured as a launcher able to download simulator builds
|
77
|
+
"""
|
78
|
+
status = ''
|
79
|
+
if 'license' not in cfg:
|
80
|
+
status += 'no license has been registered\n'
|
81
|
+
else:
|
82
|
+
status += 'license registered as {}\n'.format(cfg['license']['filename'])
|
83
|
+
|
84
|
+
if 'dlkey_id' not in cfg:
|
85
|
+
status += 'no download key ID found\n'
|
86
|
+
else:
|
87
|
+
status += 'download key id obtained\n'
|
88
|
+
|
89
|
+
if 'dlkey' not in cfg:
|
90
|
+
status += 'no download key found\n'
|
91
|
+
else:
|
92
|
+
status += 'download key obtained\n'
|
93
|
+
return status
|
94
|
+
|
95
|
+
def get_launcher_build_info(cfg):
|
96
|
+
"""
|
97
|
+
Contacts API to discover the current latest build version
|
98
|
+
"""
|
99
|
+
status = ''
|
100
|
+
db_resource = boto3.resource(
|
101
|
+
'dynamodb',
|
102
|
+
'us-east-1',
|
103
|
+
aws_access_key_id=cfg['dlkey_id'],
|
104
|
+
aws_secret_access_key=cfg['dlkey'])
|
105
|
+
|
106
|
+
table = db_resource.Table('autoverse-ci-meta')
|
107
|
+
item = table.get_item(Key={'package-name': 'autoverse'})
|
108
|
+
|
109
|
+
if not 'Item' in item or 'latest' not in item['Item']:
|
110
|
+
status = 'Unable to Retrieve Latest Version'
|
111
|
+
return (False, status, '', '')
|
112
|
+
|
113
|
+
latest_version = item['Item']['latest']
|
114
|
+
version_url = item['Item']['package-url']
|
115
|
+
return (True, status, latest_version, version_url)
|
116
|
+
|
117
|
+
def download_simulator_archive(cfg, source_path, target_path):
|
118
|
+
"""
|
119
|
+
Downloads the latest version of the simulator from the builds bucket
|
120
|
+
"""
|
121
|
+
s3_client = boto3.client(
|
122
|
+
's3',
|
123
|
+
aws_access_key_id=cfg['dlkey_id'],
|
124
|
+
aws_secret_access_key=cfg['dlkey'])
|
125
|
+
s3_download_with_progress(s3_client, 'autoverse-builds', source_path, target_path)
|
126
|
+
|
127
|
+
def is_installed_sim(file_path):
|
128
|
+
"""
|
129
|
+
Check if the given path appears to be the root of
|
130
|
+
a simulator installation
|
131
|
+
"""
|
132
|
+
if not os.path.exists(file_path):
|
133
|
+
return False
|
134
|
+
|
135
|
+
if not os.path.isdir(os.path.join(file_path, 'Linux', 'Autoverse')):
|
136
|
+
return False
|
137
|
+
|
138
|
+
if not os.path.isfile(os.path.join(file_path, 'Linux', 'Autoverse', 'Saved', 'simconfig.json')):
|
139
|
+
return False
|
140
|
+
|
141
|
+
return True
|
142
|
+
|
143
|
+
def s3_download_with_progress(s3_client, s3_bucket, s3_object_key, local_file_path):
|
144
|
+
|
145
|
+
meta_data = s3_client.head_object(Bucket=s3_bucket, Key=s3_object_key)
|
146
|
+
total_length = int(meta_data.get('ContentLength', 0))
|
147
|
+
downloaded = 0
|
148
|
+
|
149
|
+
def progress(chunk):
|
150
|
+
nonlocal downloaded
|
151
|
+
downloaded += chunk
|
152
|
+
done = int(50 * downloaded / total_length)
|
153
|
+
sys.stdout.write("\r[%s%s]" % ('=' * done, ' ' * (50-done)) )
|
154
|
+
sys.stdout.flush()
|
155
|
+
|
156
|
+
with open(local_file_path, 'wb') as f:
|
157
|
+
s3_client.download_fileobj(s3_bucket, s3_object_key, f, Callback=progress)
|
158
|
+
print('\n')
|