Merge pull request 'Update utils/combine_runs.py' (#5) from Vickram_dev_ into dev
Reviewed-on: #5
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Guys please use the same setup code and put into the imports for consistency
|
# Guys please use the same setup code and put into the imports for consistency
|
||||||
script_names = ["untitled14.py", "untitled13.py"] # This is a list of the files of the mission runs
|
script_names = ["Run1.py", "Run2.py", "Run3.py", "Run5.py", "Run6.py"] # This is a list of the files of the mission runs
|
||||||
content = ""
|
content = ""
|
||||||
imports = """
|
imports = """
|
||||||
from pybricks.hubs import PrimeHub
|
from pybricks.hubs import PrimeHub
|
||||||
@@ -72,7 +72,7 @@ function_calls = []
|
|||||||
|
|
||||||
# Define colors properly - one per script
|
# Define colors properly - one per script
|
||||||
colors = [
|
colors = [
|
||||||
'Color.ORANGE', 'Color.GREEN', 'Color.BLACK', 'Color.WHITE',
|
'Color.ORANGE', 'Color.GREEN', 'Color.WHITE',
|
||||||
'Color.YELLOW', 'Color.BLUE', 'Color.MAGENTA', 'Color.RED', 'Color.BROWN'
|
'Color.YELLOW', 'Color.BLUE', 'Color.MAGENTA', 'Color.RED', 'Color.BROWN'
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ for i, f_name in enumerate(script_names):
|
|||||||
m.write(func_def)
|
m.write(func_def)
|
||||||
|
|
||||||
# Assign one color per script
|
# Assign one color per script
|
||||||
color_condition = colors[i % len(colors)]
|
color_condition = colors[i]
|
||||||
function_calls.append({
|
function_calls.append({
|
||||||
'name': func_name,
|
'name': func_name,
|
||||||
'is_async': is_async,
|
'is_async': is_async,
|
||||||
@@ -120,10 +120,10 @@ with open("main.py", 'a') as m:
|
|||||||
m.write(f" await {func_info['name']}()\n")
|
m.write(f" await {func_info['name']}()\n")
|
||||||
else:
|
else:
|
||||||
m.write(f" {func_info['name']}()\n")
|
m.write(f" {func_info['name']}()\n")
|
||||||
m.write(" return # Exit after running one function\n")
|
m.write(" \n")
|
||||||
|
|
||||||
# Add a default case
|
# Add a default case
|
||||||
m.write(" # Default case - no matching color detected\n")
|
m.write(" \n")
|
||||||
m.write(" print(f'Detected color: {color_sensor.color()}')\n")
|
m.write(" print(f'Detected color: {color_sensor.color()}')\n")
|
||||||
|
|
||||||
# Write the main loop
|
# Write the main loop
|
||||||
@@ -131,9 +131,4 @@ with open("main.py", 'a') as m:
|
|||||||
m.write("\n# Main execution loop\n")
|
m.write("\n# Main execution loop\n")
|
||||||
m.write("while True:\n")
|
m.write("while True:\n")
|
||||||
m.write(" run_task(main())\n")
|
m.write(" run_task(main())\n")
|
||||||
m.write(" wait(100)\n")
|
m.write(" wait(100)\n")
|
||||||
|
|
||||||
print("Script merger completed successfully!")
|
|
||||||
print("Functions created:")
|
|
||||||
for func_info in function_calls:
|
|
||||||
print(f" - {func_info['name']}() triggered by {func_info['color']} (from {func_info['filename']})")
|
|
||||||
Reference in New Issue
Block a user