Skip to content

Commit

Permalink
issue #88
Browse files Browse the repository at this point in the history
Do not open .txt file with an entirely new subprocess.
  • Loading branch information
BBC-Esq authored Jan 7, 2024
1 parent 9948a73 commit 7810bfa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/server_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def format_metadata_as_citations(metadata_list):
return "\n".join(citations)

def write_contexts_to_file_and_open(contexts):
contexts_output_file_path = Path('contexts.txt')

with contexts_output_file_path.open('w', encoding='utf-8') as file:
for index, context in enumerate(contexts, start=1):
file.write(f"------------ Context {index} ---------------\n\n")
Expand All @@ -52,9 +54,9 @@ def write_contexts_to_file_and_open(contexts):
if os.name == 'nt':
os.startfile(contexts_output_file_path)
elif sys.platform == 'darwin':
subprocess.Popen(['open', str(contexts_output_file_path)])
os.system(f'open {contexts_output_file_path}')
elif sys.platform.startswith('linux'):
subprocess.Popen(['xdg-open', str(contexts_output_file_path)])
os.system(f'xdg-open {contexts_output_file_path}')
else:
raise NotImplementedError("Unsupported operating system")

Expand Down

0 comments on commit 7810bfa

Please sign in to comment.