Skip to content

Commit 5952798

Browse files
committed
Expand wildcards with glob and use list command sequence instead of string command with shell=True
1 parent 29907fb commit 5952798

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

arcflow/main.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from asnake.client import ASnakeClient
1818
from multiprocessing.pool import ThreadPool as Pool
1919
from utils.stage_classifications import extract_labels
20-
20+
import glob
2121

2222
base_dir = os.path.abspath((__file__) + "/../../")
2323
log_file = os.path.join(base_dir, 'logs/arcflow.log')
@@ -577,7 +577,7 @@ def index_collections(self, repo_id, xml_file_path, indent_size=0):
577577
return
578578

579579
traject_config = f'{arclight_path}/lib/arclight/traject/ead2_config.rb'
580-
580+
xml_files = glob.glob(xml_file_path) # Returns list of matching files
581581
cmd = [
582582
'bundle', 'exec', 'traject',
583583
'-u', self.solr_url,
@@ -586,23 +586,20 @@ def index_collections(self, repo_id, xml_file_path, indent_size=0):
586586
'-s', f'solr_writer.batch_size={self.batch_size}',
587587
'-s', 'solr_writer.commit_on_close=true',
588588
'-i', 'xml',
589-
'-c', traject_config
590-
]
589+
'-c', traject_config,
590+
] + xml_files
591591

592592
if self.traject_extra_config:
593593
if isinstance(self.traject_extra_config, (list, tuple)):
594594
cmd.extend(self.traject_extra_config)
595595
else:
596596
# Treat a string extra config as a path and pass it with -c
597597
cmd.extend(['-c', self.traject_extra_config])
598-
599-
cmd.append(xml_file_path)
600-
598+
601599
env = os.environ.copy()
602600
env['REPOSITORY_ID'] = str(repo_id)
603-
cmd_string = ' '.join(cmd)
604601
result = subprocess.run(
605-
cmd_string,
602+
cmd,
606603
cwd=self.arclight_dir,
607604
env=env,
608605
stderr=subprocess.PIPE,

0 commit comments

Comments
 (0)