autoverse-cli 0.13.2__tar.gz → 0.13.4__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/PKG-INFO +1 -1
  2. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/pyproject.toml +1 -1
  3. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/autoverse_cli.egg-info/PKG-INFO +1 -1
  4. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/app_version.py +1 -1
  5. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/race_cloud.py +35 -3
  6. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/race_cloud_fwd_api.py +1 -1
  7. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/race_cloud_util.py +31 -2
  8. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/LICENSE +0 -0
  9. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/README.md +0 -0
  10. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/setup.cfg +0 -0
  11. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/autoverse_cli.egg-info/SOURCES.txt +0 -0
  12. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/autoverse_cli.egg-info/dependency_links.txt +0 -0
  13. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/autoverse_cli.egg-info/entry_points.txt +0 -0
  14. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/autoverse_cli.egg-info/requires.txt +0 -0
  15. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/autoverse_cli.egg-info/top_level.txt +0 -0
  16. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/__init__.py +0 -0
  17. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/argparse_help.py +0 -0
  18. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/avrs.py +0 -0
  19. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/can_tool.py +0 -0
  20. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/can_tool_util.py +0 -0
  21. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/cfg.py +0 -0
  22. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/launcher.py +0 -0
  23. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/launcher_util.py +0 -0
  24. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/race_cloud_cfg_util.py +0 -0
  25. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/change_camera.py +0 -0
  26. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/code_booz.py +0 -0
  27. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/demo.py +0 -0
  28. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/dump_sim_config.py +0 -0
  29. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/environment.py +0 -0
  30. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/fault_injection.py +0 -0
  31. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/get_object_config.py +0 -0
  32. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/list_sim_objects.py +0 -0
  33. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/log_path.py +0 -0
  34. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/misc.py +0 -0
  35. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/move_to_landmark.py +0 -0
  36. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/npc.py +0 -0
  37. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/request.py +0 -0
  38. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/reset_to_track.py +0 -0
  39. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/restart.py +0 -0
  40. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/scenario_control.py +0 -0
  41. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/spawn_object.py +0 -0
  42. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/teleport.py +0 -0
  43. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/toggle_hud.py +0 -0
  44. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/vd.py +0 -0
  45. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/vehicle_input.py +0 -0
  46. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/requests/vehicle_replay.py +0 -0
  47. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/simconfig.py +0 -0
  48. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/simconfig_util.py +0 -0
  49. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/tests.py +0 -0
  50. {autoverse_cli-0.13.2 → autoverse_cli-0.13.4}/src/avrs/util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: autoverse-cli
3
- Version: 0.13.2
3
+ Version: 0.13.4
4
4
  Summary: The Autoverse CLI
5
5
  Author-email: Dan Kamrath <dan.kamrath@autonomalabs.com>
6
6
  License: # End-User License Agreement (EULA) of the Autonoma AutoVerse CLI
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "autoverse-cli"
3
- version = "0.13.2"
3
+ version = "0.13.4"
4
4
  dependencies = [
5
5
  "boto3",
6
6
  "cantools"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: autoverse-cli
3
- Version: 0.13.2
3
+ Version: 0.13.4
4
4
  Summary: The Autoverse CLI
5
5
  Author-email: Dan Kamrath <dan.kamrath@autonomalabs.com>
6
6
  License: # End-User License Agreement (EULA) of the Autonoma AutoVerse CLI
@@ -2,7 +2,7 @@ import http.client
2
2
  import json
3
3
 
4
4
  def get_app_version():
5
- return '0.13.2'
5
+ return '0.13.4'
6
6
 
7
7
  def check_app_is_latest():
8
8
  pass
@@ -131,6 +131,23 @@ class AvrsRaceCloud(AvrsApiRequest):
131
131
  help='if true, will run the server in the background')
132
132
  fwd_server_parser.set_defaults(func=self.fwd_api)
133
133
 
134
+ fwd_server_parser = sps.add_parser(
135
+ 'fwd-api',
136
+ help='forwards incoming external api requests to the simulator api')
137
+ fwd_server_parser.add_argument(
138
+ 'mode',
139
+ choices=['bg', 'fg'],
140
+ help='whether to run in forground or background')
141
+ fwd_server_parser.add_argument(
142
+ 'source_port',
143
+ type=int,
144
+ help='the external port to listen to external api requests on')
145
+ fwd_server_parser.add_argument(
146
+ 'target_port',
147
+ type=int,
148
+ help='the local port to forward api requests too')
149
+ fwd_server_parser.set_defaults(func=self.fwd_api)
150
+
134
151
  def race_connect(self, args):
135
152
  logger = logging.getLogger('avrs')
136
153
  logger.info('starting race-cloud connect for team {} to instance {}'.format(
@@ -270,6 +287,14 @@ class AvrsRaceCloud(AvrsApiRequest):
270
287
  'slot': slot
271
288
  }
272
289
 
290
+ # go ahead and restart forwarding script here
291
+ # stop it if its already running
292
+ stop_result = stop_fwd_api()
293
+ logger.info('stopped fwd-api: {}'.format(stop_result))
294
+ start_result = start_fwd_api(args.source_port, args.target_port)
295
+ logger.info('started fwd-api: {}'.format(start_result))
296
+
297
+
273
298
  print(json.dumps(response)) # print this so that when called from the ssh lambda we can get the result
274
299
 
275
300
  def sim_ctrl(self, args):
@@ -346,12 +371,19 @@ class AvrsRaceCloud(AvrsApiRequest):
346
371
  def fwd_api(self, args):
347
372
  # start a server that listens for http on some port and forwards
348
373
  # to the simulator on 30313
374
+ logger = logging.getLogger('avrs')
349
375
 
350
- if args.background:
376
+ if args.mode == 'bg':
351
377
  # call the cli so that it starts the forwarding server in the background
352
- start_exe('avrs race-cloud fwd-api {} {}'.format(
353
- args.source_port, args.target_port))
378
+
379
+ # stop it if its already running
380
+ stop_result = stop_fwd_api()
381
+ logger.info('stopped fwd-api: {}'.format(stop_result))
382
+ start_result = start_fwd_api(args.source_port, args.target_port)
383
+ logger.info('started fwd-api: {}'.format(start_result))
384
+
354
385
  else:
386
+ logger.info('starting fwd-api in forground')
355
387
  handler = ApiForwardHandler(args.target_port)
356
388
  server = HTTPServer(('0.0.0.0', args.source_port), handler)
357
389
  server.serve_forever()
@@ -31,7 +31,7 @@ class ApiForwardHandler(BaseHTTPRequestHandler):
31
31
  headers = {
32
32
  'Content-type': 'application/json',
33
33
  }
34
- body = json.dumps(body).encode('utf-8')
34
+ #body = json.dumps(body).encode('utf-8') # already a string here
35
35
  connection.request('POST', '/post', body, headers)
36
36
  response = connection.getresponse()
37
37
  response_string = ''
@@ -114,6 +114,18 @@ CHECK_VCAN_EXISTS_SCRIPT = '''
114
114
  fi
115
115
  '''
116
116
 
117
+ START_FWD_API_SCRIPT = '''
118
+ nohup python3 -m avrs.avrs race-cloud fwd-api fg {source_port} {target_port} > ~/fwd_api.log 2>&1 < /dev/null &
119
+ echo "$!" > ~/fwd_api_pid
120
+ '''
121
+
122
+ STOP_FWD_API_SCRIPT = '''
123
+ if [[ -e ~/fwd_api_pid ]]; then
124
+ kill $(cat ~/fwd_api_pid)
125
+ fi
126
+ rm ~/fwd_api_pid
127
+ '''
128
+
117
129
  GET_EC2_LOCAL_IP_SCRIPT = '''
118
130
  echo -n $(ec2metadata --local-ipv4)
119
131
  '''
@@ -126,8 +138,9 @@ def bash_kill_process(pname):
126
138
  # start an exectuable in the background, sending output to a file
127
139
  # stored at root with its name
128
140
  def start_exe(exe_path):
141
+ print('running {} and saving under {}'.format(exe_path, os.path.basename(exe_path).replace(' ', '')))
129
142
  return run_process(['bash', '-c',
130
- 'nohup {} > ~/{}_output.log 2>&1 < /dev/null &'.format(exe_path, os.path.basename(exe_path))])
143
+ 'nohup {} > ~/{}_output.log 2>&1 < /dev/null &'.format(exe_path, os.path.basename(exe_path).replace(' ', ''))])
131
144
 
132
145
  def get_sim_install_path():
133
146
  sim_path = os.environ.get('AVRS_INSTALL_PATH',
@@ -174,12 +187,28 @@ def check_vcan_exists(vcan_name):
174
187
  CHECK_VCAN_EXISTS_SCRIPT.format(**pargs)])
175
188
  return pres.out == 'yes'
176
189
 
190
+ def start_fwd_api(source_port, target_port):
191
+ pargs = {
192
+ 'source_port': source_port,
193
+ 'target_port': target_port
194
+ }
195
+ pres = run_process(['bash', '-c', START_FWD_API_SCRIPT.format(**pargs)])
196
+ return pres.out
197
+
198
+ def stop_fwd_api():
199
+ pres = run_process(['bash', '-c', STOP_FWD_API_SCRIPT])
200
+ return pres.out
201
+
202
+ def check_fwd_api_is_running():
203
+ pres = run_process(['bash', '-c', CHECK_FWD_API_IS_RUNNING])
204
+ print(pres.out)
205
+ return pres.out == 'yes'
206
+
177
207
  def get_auto_vcan_name(peer_id, vcan_id):
178
208
  return 'vcan{}_{}'.format(peer_id, vcan_id)
179
209
 
180
210
  def connect_peer_vcan(peer_id, peer_ip, vcan_id, vcan_name=''):
181
211
  logger = logging.getLogger('avrs')
182
- vcan_id = 0
183
212
  pargs = {
184
213
  'peer_id': peer_id,
185
214
  'peer_ip': peer_ip,
File without changes
File without changes
File without changes