Skip to content

Commit

Permalink
Rover: Fix parameters versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoolivieri committed Jun 15, 2020
1 parent 95bcda3 commit 6df4a3c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions build_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@

## Dicts for name replacing
vehicle_new_to_old_name = { # Used because "param_parse.py" args expect old names
"Rover": "Rover",
"Rover": "APMrover2",
"Sub": "ArduSub",
"Copter":"ArduCopter",
"Plane":"ArduPlane",
"AntennaTracker":"AntennaTracker", # firmware server calls Tracker as AntennaTracker
}

vehicle_old_to_new_name = { # Used because git-version.txt use APMVersion with old names
"Rover":"Rover",
"APMrover2":"Rover",
"ArduRover":"Rover",
"ArduSub":"Sub",
Expand Down Expand Up @@ -322,7 +321,9 @@ def replace_anchors(source_file, dest_file, version_tag):
file_in = open(source_file, "r")
file_out = open(dest_file, "w")
found_original_title = False
#adjust_title_mark = 0
if "latest" not in version_tag:
file_out.write(':orphan:\n\n')

for line in file_in:
if (re.match("(^.. _)(.*):$", line)) and ("latest" not in version_tag):
file_out.write(line[0:-2] + version_tag + ":\n") # renames the anchors, but leave latest anchors "as-is" to maintaim compatibility with all links across the wiki
Expand All @@ -336,14 +337,8 @@ def replace_anchors(source_file, dest_file, version_tag):
# Pigbacking and inserting the javascript selector
out_line += "\n.. raw:: html\n :file: ../_static/parameters_versioning_script.inc\n\n"
file_out.write(out_line)
# adjust_title_mark = len(out_line) -1

# elif adjust_title_mark > 0: # adjust the size of horizontal '==========' bar
# out_line = "=" * adjust_title_mark
# out_line += "\n"
# file_out.write(out_line)
# adjust_title_mark = 0


elif ("=======================" in line) and (not found_original_title): # Ignores the original mark
found_original_title = True

Expand Down Expand Up @@ -383,7 +378,11 @@ def replace_anchors(source_file, dest_file, version_tag):
# Run param_parse.py tool from Autotest set in the desidered commit id
try:
os.chdir(BASEPATH + "/Tools/autotest/param_metadata")
os.system("python3 ./param_parse.py --vehicle " + vehicle_new_to_old_name[vehicle]) # option "param_parse.py --format rst" is not available in all commits where param_parse.py is found
if ('rover' in vehicle.lower()) and ('v3.' not in version.lower()) and ('v4.0' not in version.lower()): # Workaround the vehicle renaming (Rover, APMRover2 ArduRover...)
os.system("python3 ./param_parse.py --vehicle " + 'Rover')
else: # regular case
os.system("python3 ./param_parse.py --vehicle " + vehicle_new_to_old_name[vehicle]) # option "param_parse.py --format rst" is not available in all commits where param_parse.py is found


# create a filename for new parameters file
filename = "parameters-" + vehicle
Expand All @@ -409,7 +408,7 @@ def replace_anchors(source_file, dest_file, version_tag):
#sys.exit(1)
debug("")

return 1
return 0


def generate_json(vehicles):
Expand Down
2 changes: 1 addition & 1 deletion update.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#print(args.site)
#print(args.clean)

PARAMETER_SITE={'rover':'Rover', 'copter':'ArduCopter','plane':'ArduPlane','antennatracker':'AntennaTracker' }
PARAMETER_SITE={'rover':'APMrover2', 'copter':'ArduCopter','plane':'ArduPlane','antennatracker':'AntennaTracker' }
LOGMESSAGE_SITE={'rover':'Rover', 'copter':'Copter','plane':'Plane','antennatracker':'Tracker' }
error_count = 0

Expand Down

0 comments on commit 6df4a3c

Please sign in to comment.