Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean autocoders code #1240

Merged
merged 10 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Autocoders/Python/bin/JSONDictionaryGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def pinit():


def main():

parser = pinit()
(opts, args) = parser.parse_args()

Expand All @@ -106,7 +105,6 @@ def main():
PRINT.info("\nUsage: %s [options] xml_filename" % sys.argv[0])
PRINT.info("ERROR: Cannot create dictionary\n")
sys.exit(-1)
return
else:
xmlFilename = args[0]

Expand All @@ -116,7 +114,7 @@ def main():
if not opts.build_root_overwrite is None:
set_build_roots(opts.build_root_overwrite)
else:
if ("BUILD_ROOT" in os.environ.keys()) == False:
if ("BUILD_ROOT" in os.environ.keys()) is False:
print("ERROR: Build root not set to root build path...")
sys.exit(-1)
set_build_roots(os.environ["BUILD_ROOT"])
Expand Down Expand Up @@ -305,19 +303,19 @@ def main():

# Prepend instance name to commands, events, and channels with duplicate component types
# PRINT.info(json.dumps(instanceIDs, indent=4))
for telemetryType, idDict in list(instanceIDs.items()):
for name, ids in list(idDict.items()):
for telemetry_type, id_dict in list(instanceIDs.items()):
for name, ids in list(id_dict.items()):
if len(ids) > 1:
for id in ids:
telem = dictionary[deployment][telemetryType][id]
telem = dictionary[deployment][telemetry_type][id]
name = telem["name"]
instanceName = telem["instance"]
name = "_".join([instanceName, name])
instance_name = telem["instance"]
name = "_".join([instance_name, name])
telem["name"] = name

# Stringify JSON -- indent option makes it readable, can be removed if file
# size is an issue
jsonStr = json.dumps(dictionary, indent=4)
json_str = json.dumps(dictionary, indent=4)

# Create output directory if it doesn't exist
directory = os.path.dirname(outFilepath)
Expand All @@ -326,7 +324,7 @@ def main():

# Write JSON to file
outFile = open(outFilepath, "w")
outFile.write(jsonStr)
outFile.write(json_str)
descriptionFile = open(descriptionFilename, "w")
descriptionFile.write(outFilepath)
PRINT.info("\nJSON output written to %s" % outFilepath)
Expand Down
2 changes: 0 additions & 2 deletions Autocoders/Python/bin/gds_dictgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,10 @@ def main():
#
if len(args) == 0:
print("Usage: %s [options] xml_filename" % sys.argv[0])
return
LeStarch marked this conversation as resolved.
Show resolved Hide resolved
elif len(args) == 1:
xml_filename = args[0]
else:
print("ERROR: Too many filenames, should only have one")
return

#
# Check for BUILD_ROOT variable for XML port searches
Expand Down
2 changes: 0 additions & 2 deletions Autocoders/Python/bin/implgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,10 @@ def main():
#
if len(args) == 0:
print("ERROR: Usage: %s [options] xml_filename" % sys.argv[0])
return
iw4p marked this conversation as resolved.
Show resolved Hide resolved
elif len(args) == 1:
xml_filename = args[0]
else:
print("ERROR: Too many filenames, should only have one")
return
iw4p marked this conversation as resolved.
Show resolved Hide resolved

#
# Check for BUILD_ROOT variable for XML port searches
Expand Down
2 changes: 0 additions & 2 deletions Autocoders/Python/bin/pymod_dictgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,10 @@ def main():
#
if len(args) == 0:
print("ERROR: Usage: %s [options] xml_filename" % sys.argv[0])
return
elif len(args) == 1:
xml_filename = args[0]
else:
print("ERROR: Too many filenames, should only have one")
return

#
# Check for BUILD_ROOT variable for XML port searches
Expand Down
2 changes: 0 additions & 2 deletions Autocoders/Python/bin/tlm_packet_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,12 +613,10 @@ def main():
#
if len(args) == 0:
print("Usage: %s [options] xml_filename" % sys.argv[0])
return
elif len(args) == 1:
xml_filename = args[0]
else:
print("ERROR: Too many filenames, should only have one")
return

print("Processing packet file %s" % xml_filename)
set_build_roots(os.environ.get("BUILD_ROOT"))
Expand Down
16 changes: 8 additions & 8 deletions Autocoders/Python/src/fprime_ac/utils/AddSysPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def AddSysPath(new_path):
new_path = new_path.lower()

# Check against all currently available paths
for x in sys.path:
x = os.path.abspath(x)
for item in sys.path:
item = os.path.abspath(item)

if sys.platform == "win32":
x = x.lower()
item = item.lower()

if new_path in (x, x + os.sep):
if new_path in (item, item + os.sep):
return 0

sys.path.append(new_path)
Expand All @@ -47,8 +47,8 @@ def AddSysPath(new_path):
if __name__ == "__main__":

print("Before:")
for x in sys.path:
print(x)
for item in sys.path:
print(item)

if sys.platform == "win32":
print(AddSysPath("c:\\Temp"))
Expand All @@ -57,5 +57,5 @@ def AddSysPath(new_path):
print(AddSysPath("/usr/lib"))

print("After:")
for x in sys.path:
print(x)
for item in sys.path:
print(item)