Skip to content

Commit

Permalink
fix(docs): fix import on linux machine
Browse files Browse the repository at this point in the history
  • Loading branch information
mostaphaRoudsari committed Sep 11, 2020
1 parent 887ef1d commit c8fc0bb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
19 changes: 14 additions & 5 deletions butterfly/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import re
import os
import warnings


def set_config(_ofrunners):
"""set config for butterfly run manager."""
BASEFOLDERS = {
'ESI': r'C:\Program Files (x86)',
'blueCFD': r'C:\Program Files'
}

if not _ofrunners:
raise ImportError('Set your installation flavor in confing.yml.')

# look up for folders
for of_runner in _ofrunners:
try:
Expand All @@ -19,6 +21,8 @@ def set_config(_ofrunners):
# invalid installation option
pass
else:
if not os.path.isdir(base_folder):
continue
for f in os.listdir(base_folder):
of_folder = os.path.join(base_folder, f)
if not os.path.isdir(of_folder):
Expand All @@ -27,12 +31,17 @@ def set_config(_ofrunners):
# in case of two installation finds the older one but for now
# it is fine.
return {'runner': of_runner, 'of_folder': of_folder}

raise ImportError('Set your installation flavor in confing.yml.')

warnings.warn(
'Failed to find the OpenFOAM installation.'
' Set your installation flavor in confing.yml.'
)


os.chdir(os.path.dirname(__file__))
with open('config.yml') as inst:
_ofrunners = re.findall(r'\s- (.*)', inst.read(),re.MULTILINE )

config = set_config(_ofrunners)
print('OpenFOAM installation: {}'.format(config['runner']))
if config:
print('OpenFOAM installation: {}'.format(config['runner']))
2 changes: 1 addition & 1 deletion butterfly/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import butterfly

if butterfly.config['runner'] == 'blueCFD':
if butterfly.config and butterfly.config['runner'] == 'blueCFD':
from .runmanager_bluecfd import RunManagerBlueCFD as RunManager
else:
from .runmanager import RunManager
Expand Down
4 changes: 4 additions & 0 deletions butterfly/gradingutil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from collections import namedtuple
try:
xrange(10)
except:
xrange = range


def secant(f, x0, x1, eps, ds, ln, n):
Expand Down

0 comments on commit c8fc0bb

Please sign in to comment.