|
1 | 1 | import numpy as np |
2 | | -import subprocess |
3 | 2 | import sys |
4 | 3 | import os |
5 | 4 | import pickle |
6 | | -import itertools |
| 5 | +import itertools |
| 6 | +import re |
| 7 | +import ntpath |
| 8 | +import subprocess |
7 | 9 | from subprocess import call |
8 | 10 |
|
9 | 11 | # Check if we are using python 3 |
@@ -106,18 +108,28 @@ class pythonProgramOptions: |
106 | 108 | grid_filename = None # grid file name (e.g. 'mygrid.txt') |
107 | 109 |
|
108 | 110 | 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("'\"") |
113 | 120 |
|
114 | 121 | logfile_definitions = "COMPAS_Output_Definitions.txt" # logfile record definitions file name (e.g. 'logdefs.txt') |
115 | 122 |
|
116 | 123 | 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("'\"") |
121 | 133 |
|
122 | 134 | initial_mass = None # initial mass for SSE |
123 | 135 | initial_mass_1 = None # primary initial mass for BSE |
|
0 commit comments