Skip to content

Commit 463ed1e

Browse files
authored
Merge pull request #678 from jeffriley/more-minor-fixes
Minor fixes
2 parents a025b65 + d1daacd commit 463ed1e

File tree

12 files changed

+153
-4294
lines changed

12 files changed

+153
-4294
lines changed

examples/methods_paper_plots/chirpmass_distribution/pythonSubmit.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import numpy as np
2-
import subprocess
32
import sys
43
import os
54
import pickle
6-
import itertools
5+
import itertools
6+
import re
7+
import ntpath
8+
import subprocess
79
from subprocess import call
810

911
# Check if we are using python 3
@@ -106,18 +108,28 @@ class pythonProgramOptions:
106108
grid_filename = None # grid file name (e.g. 'mygrid.txt')
107109

108110
if grid_filename != None:
109-
if compas_input_path_override == None:
110-
grid_filename = os.getcwd() + '/' + grid_filename
111-
else:
112-
grid_filename = compas_input_path_override + '/' + grid_filename
111+
# if the grid filename supplied is already fully-qualified, leave it as is
112+
head, tail = ntpath.split(grid_filename) # split into pathname and base filename
113+
114+
if head == '' or head == '.': # no path (or CWD) - add path as required
115+
grid_filename = tail or ntpath.basename(head)
116+
if compas_input_path_override == None:
117+
grid_filename = os.getcwd() + '/' + grid_filename.strip("'\"")
118+
else:
119+
grid_filename = compas_input_path_override + '/' + grid_filename.strip("'\"")
113120

114121
logfile_definitions = "COMPAS_Output_Definitions.txt" # logfile record definitions file name (e.g. 'logdefs.txt')
115122

116123
if logfile_definitions != None:
117-
if compas_input_path_override == None:
118-
logfile_definitions = os.getcwd() + '/' + logfile_definitions
119-
else:
120-
logfile_definitions = compas_input_path_override + '/' + logfile_definitions
124+
# if the grid filename supplied is already fully-qualified, leave it as is
125+
head, tail = ntpath.split(logfile_definitions) # split into pathname and base filename
126+
127+
if head == '' or head == '.': # no path (or CWD) - add path as required
128+
logfile_definitions = tail or ntpath.basename(head)
129+
if compas_input_path_override == None:
130+
logfile_definitions = os.getcwd() + '/' + logfile_definitions.strip("'\"")
131+
else:
132+
logfile_definitions = compas_input_path_override + '/' + logfile_definitions.strip("'\"")
121133

122134
initial_mass = None # initial mass for SSE
123135
initial_mass_1 = None # primary initial mass for BSE

0 commit comments

Comments
 (0)