1212LICENSE = "MIT License"
1313TERMS = """
1414TERMS OF SERVICE / DISCLAIMER:
15- This software is provided "as is", without warranty of any kind.
16- The authors are not responsible for any damage to hardware instruments
17- (Keithley, Lakeshore, etc.) caused by improper configuration or
18- misuse of these control scripts.
15+ This software is provided "as is", without warranty of any kind.
16+ The authors are not responsible for any damage to hardware instruments
17+ (Keithley, Lakeshore, etc.) caused by improper configuration or
18+ misuse of these control scripts.
1919Always verify safety limits (Compliance, Max Voltage) before execution.
2020"""
2121
2222def print_banner ():
2323 """Prints the professional header."""
24- print ("\033 [H\033 [J" ) # Clear screen
24+ print ("\033 [H\033 [J" ) # Clear screen
2525 print ("=" * 60 )
2626 print (f" { APP_NAME } (v{ VERSION } )" )
2727 print (f" { AFFILIATION } " )
@@ -33,14 +33,15 @@ def print_banner():
3333 print ("=" * 60 )
3434 print ("\n " )
3535
36+
3637def find_scripts (base_path ):
3738 """
3839 Recursively finds all python files ending with 'Instrument_Control.py'.
3940 Returns a list of tuples: (Display Name, Full Path)
4041 """
4142 scripts = []
4243 base = Path (base_path )
43-
44+
4445 # Exclude development/utility scripts that are not main measurement modules
4546 exclude_list = [
4647 "BasicTest_S830_Instrument_Control.py" ,
@@ -50,21 +51,22 @@ def find_scripts(base_path):
5051 for path in base .rglob ("*Instrument_Control.py" ):
5152 if path .name in exclude_list :
5253 continue
53-
54+
5455 # Create a readable name from the filename
5556 # e.g., 'IV_K2400_Loop_Instrument_Control.py' -> 'IV K2400 Loop'
5657 name = path .stem .replace ("_Instrument_Control" , "" ).replace ("_" , " " )
57-
58+
5859 # Get path relative to the run location for clarity, or absolute
5960 scripts .append ((name , str (path )))
60-
61+
6162 return sorted (scripts )
6263
64+
6365def run_script (script_path ):
6466 """Runs the selected script using the current python interpreter."""
6567 print (f"\n [INFO] Module: { os .path .basename (script_path )} " )
6668 print ("[INFO] Enter arguments below, or press ENTER for defaults." )
67-
69+
6870 args = input ("Arguments > " ).strip ()
6971 cmd = [sys .executable , script_path ]
7072 if args :
@@ -82,42 +84,43 @@ def run_script(script_path):
8284
8385 input ("\n Press ENTER to return to menu..." )
8486
87+
8588def main ():
8689 # Detect where the 'pica' package is located
8790 current_dir = os .path .dirname (os .path .abspath (__file__ ))
88-
91+
8992 while True :
9093 print_banner ()
9194 print ("Scannning for available measurement modules...\n " )
92-
95+
9396 scripts = find_scripts (current_dir )
94-
97+
9598 if not scripts :
9699 print ("[ERROR] No 'Instrument_Control.py' scripts found in pica/ directory." )
97100 sys .exit (1 )
98101
99102 print (f"{ 'No.' :<4} | { 'Module Name' } " )
100103 print ("-" * 40 )
101-
104+
102105 for idx , (name , path ) in enumerate (scripts , 1 ):
103106 print (f"{ idx :<4} | { name } " )
104-
107+
105108 print ("-" * 40 )
106109 print (f"{ 'Q' :<4} | Quit CLI" )
107-
110+
108111 choice = input ("\n Select a module number: " ).strip ().lower ()
109-
112+
110113 if choice == 'q' :
111114 print ("Exiting PICA CLI. Goodbye!" )
112115 sys .exit (0 )
113-
116+
114117 try :
115118 idx = int (choice )
116119 if 1 <= idx <= len (scripts ):
117120 selected_name , selected_path = scripts [idx - 1 ]
118121 run_script (selected_path )
119122 else :
120- print (f"[ERROR] Please enter a number between 1 and { len (scripts )} " )
123+ print (f"[ERROR] Please enter a number between 1 and { len (scripts )} . " )
121124 time .sleep (1.5 )
122125 except ValueError :
123126 print ("[ERROR] Invalid input. Enter a number or 'Q'." )
0 commit comments