This issue is a result of a Codex global repository scan.
aveElecStatPot.py exits as soon as it sees the first OUT.* directory without ElecStaticPot.cube, even if a later OUT.* directory contains the file. If no root-level cube and no matching OUT.* cube are found, the script can also fall through to open(input_file) with input_file undefined.
|
if os.path.exists(os.path.join(current_dir, "ElecStaticPot.cube")): |
|
input_file = os.path.join(current_dir, "ElecStaticPot.cube") |
|
output_file = os.path.join(current_dir, "ElecStaticPot_AVE") |
|
output_png = os.path.join(current_dir, "ElecStaticPot-vs-Z.png") |
|
else: |
|
for dir_name in os.listdir(current_dir): |
|
dir_path = os.path.join(current_dir, dir_name) |
|
|
|
if os.path.isdir(dir_path) and dir_name.startswith("OUT."): |
|
input_file = os.path.join(dir_path, "ElecStaticPot.cube") |
|
output_file = os.path.join(dir_path, "ElecStaticPot_AVE") |
|
output_png = os.path.join(dir_path, "ElecStaticPot-vs-Z.png") |
|
if os.path.exists(input_file): |
|
print(f"Processeding: {input_file}") |
|
break |
|
else: |
|
print(f"File does not exist: {input_file}") |
|
sys.exit() |
|
|
|
with open(input_file, 'r') as inpt: |
Relevant code:
for dir_name in os.listdir(current_dir):
dir_path = os.path.join(current_dir, dir_name)
if os.path.isdir(dir_path) and dir_name.startswith("OUT."):
input_file = os.path.join(dir_path, "ElecStaticPot.cube")
...
if os.path.exists(input_file):
break
else:
print(f"File does not exist: {input_file}")
sys.exit()
with open(input_file, 'r') as inpt:
Suggested fix:
Scan all candidate locations first, select the first existing ElecStaticPot.cube, and emit one clear error after the loop if no cube was found.
This issue is a result of a Codex global repository scan.
aveElecStatPot.pyexits as soon as it sees the firstOUT.*directory withoutElecStaticPot.cube, even if a laterOUT.*directory contains the file. If no root-level cube and no matchingOUT.*cube are found, the script can also fall through toopen(input_file)withinput_fileundefined.abacus-develop/tools/02_postprocessing/average_pot/aveElecStatPot.py
Lines 9 to 28 in 84ca04b
Relevant code:
Suggested fix:
Scan all candidate locations first, select the first existing
ElecStaticPot.cube, and emit one clear error after the loop if no cube was found.