Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hysop
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
particle_methods
hysop
Commits
443a9ae4
Commit
443a9ae4
authored
11 years ago
by
Franck Pérignon
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug in set default path due to diff between python and ipython behavior
parent
04ba2dd3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
HySoP/hysop/tools/io_utils.py
+30
-2
30 additions, 2 deletions
HySoP/hysop/tools/io_utils.py
HySoP/hysop/tools/sys_utils.py
+18
-0
18 additions, 0 deletions
HySoP/hysop/tools/sys_utils.py
with
48 additions
and
2 deletions
HySoP/hysop/tools/io_utils.py
+
30
−
2
View file @
443a9ae4
...
...
@@ -5,8 +5,10 @@ Tools related to i/o in parmes.
import
os
import
scitools.filetable
as
ft
import
parmepy.tools.numpywrappers
as
npw
import
inspect
from
inspect
import
getouterframes
,
currentframe
import
parmepy.mpi
as
mpi
from
parmepy.tools.sys_utils
import
SysUtils
as
su
from
re
import
findall
,
IGNORECASE
class
io
(
object
):
...
...
@@ -27,7 +29,33 @@ class io(object):
# Memo for getouterframe usage:
# frame, filename, line_number, function_name, lines, index =\
# inspect.getouterframes(inspect.currentframe())[-1]
a
=
inspect
.
getouterframes
(
inspect
.
currentframe
())[
-
1
]
# Warning FP : the behavior of python and ipython is different for
# this command.
a
=
getouterframes
(
currentframe
())
ind
=
-
1
# --- ipython ---
if
su
.
in_ipython
():
sublist
=
[
i
[
1
]
for
i
in
a
]
for
val
in
sublist
:
ll
=
findall
(
'
ipython
'
,
val
,
IGNORECASE
)
if
len
(
ll
)
>
0
:
ind
=
sublist
.
index
(
val
)
-
1
break
if
ind
>
-
1
:
# -- interactive ipython but call with execfile--
if
len
(
findall
(
'
io_utils
'
,
a
[
ind
][
1
]))
>
0
:
return
'
./interactive/p
'
+
str
(
mpi
.
main_size
)
a
=
a
[
ind
]
else
:
# -- interactive ipython without execfile call --
return
'
./interactive/p
'
+
str
(
mpi
.
main_size
)
else
:
# -- python --
a
=
a
[
-
1
]
if
a
[
-
1
]
is
None
:
# interactive python
return
'
./interactive/p
'
+
str
(
mpi
.
main_size
)
return
os
.
path
.
join
(
a
[
1
].
split
(
'
.
'
)[
0
],
'
p
'
+
str
(
mpi
.
main_size
))
@staticmethod
...
...
This diff is collapsed.
Click to expand it.
HySoP/hysop/tools/sys_utils.py
0 → 100644
+
18
−
0
View file @
443a9ae4
"""
@file sys_utils.py
Tools related to global config.
"""
class
SysUtils
(
object
):
"""
Global system check and other utilities
"""
@staticmethod
def
in_ipython
():
try
:
__IPYTHON__
except
NameError
:
return
False
else
:
return
True
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment