Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
wtlib
WindEnergyToolbox
Commits
ebf99eef
Commit
ebf99eef
authored
8 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
clean up simulation.py
parent
4fd30d12
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
wetb/hawc2/simulation.py
+1
-14
1 addition, 14 deletions
wetb/hawc2/simulation.py
wetb/utils/caching.py
+2
-0
2 additions, 0 deletions
wetb/utils/caching.py
wetb/utils/cython_compile/cython_compile.py
+2
-1
2 additions, 1 deletion
wetb/utils/cython_compile/cython_compile.py
with
5 additions
and
15 deletions
wetb/hawc2/simulation.py
+
1
−
14
View file @
ebf99eef
...
@@ -458,11 +458,7 @@ class SimulationThread(Thread):
...
@@ -458,11 +458,7 @@ class SimulationThread(Thread):
stdout
=
self
.
sim
.
stdout_filename
stdout
=
self
.
sim
.
stdout_filename
if
not
os
.
path
.
isdir
(
os
.
path
.
dirname
(
self
.
modelpath
+
self
.
sim
.
stdout_filename
)):
if
not
os
.
path
.
isdir
(
os
.
path
.
dirname
(
self
.
modelpath
+
self
.
sim
.
stdout_filename
)):
os
.
makedirs
(
os
.
path
.
dirname
(
self
.
modelpath
+
self
.
sim
.
stdout_filename
))
os
.
makedirs
(
os
.
path
.
dirname
(
self
.
modelpath
+
self
.
sim
.
stdout_filename
))
#if os.name == "nt":
# self.process = subprocess.Popen('"%s" %s 1> %s 2>&1' % (hawc2exe, htcfile, stdout), stdout=None, stderr=None, shell=True, cwd=modelpath) #, creationflags=CREATE_NO_WINDOW)
#else:
# self.process = subprocess.Popen('wine "%s" %s 1> %s 2>&1' % (hawc2exe, htcfile, stdout), stdout=None, stderr=None, shell=True, cwd=modelpath)
with
open
(
os
.
path
.
join
(
self
.
modelpath
,
stdout
),
'
wb
'
)
as
stdout
:
with
open
(
os
.
path
.
join
(
self
.
modelpath
,
stdout
),
'
wb
'
)
as
stdout
:
if
isinstance
(
hawc2exe
,
tuple
):
if
isinstance
(
hawc2exe
,
tuple
):
wine
,
hawc2exe
=
hawc2exe
wine
,
hawc2exe
=
hawc2exe
...
@@ -471,15 +467,6 @@ class SimulationThread(Thread):
...
@@ -471,15 +467,6 @@ class SimulationThread(Thread):
self
.
process
=
subprocess
.
Popen
([
hawc2exe
,
htcfile
],
stdout
=
stdout
,
stderr
=
STDOUT
,
shell
=
False
,
cwd
=
modelpath
)
#, creationflags=CREATE_NO_WINDOW)
self
.
process
=
subprocess
.
Popen
([
hawc2exe
,
htcfile
],
stdout
=
stdout
,
stderr
=
STDOUT
,
shell
=
False
,
cwd
=
modelpath
)
#, creationflags=CREATE_NO_WINDOW)
self
.
process
.
communicate
()
self
.
process
.
communicate
()
# if isinstance(hawc2exe, tuple):
# self.process = subprocess.Popen('%s "%s" %s 1> %s 2>&1' % (hawc2exe + (htcfile, stdout)), stdout=None, stderr=None, shell=False, cwd=modelpath)
# else:
# self.process = subprocess.Popen('"%s" %s 1> %s 2>&1' % (hawc2exe, htcfile, stdout), stdout=None, stderr=None, shell=False, cwd=modelpath) #, creationflags=CREATE_NO_WINDOW)
# with open("cmd.txt", 'w') as fid:
# fid.write("cd %s\n" % modelpath)
# fid.write('"%s" %s 1> %s 2>&1' % (hawc2exe, htcfile, stdout))
import
psutil
import
psutil
try
:
try
:
self
.
sim
.
host
.
resource
.
process_name
=
psutil
.
Process
(
self
.
process
.
pid
).
name
()
self
.
sim
.
host
.
resource
.
process_name
=
psutil
.
Process
(
self
.
process
.
pid
).
name
()
...
...
This diff is collapsed.
Click to expand it.
wetb/utils/caching.py
+
2
−
0
View file @
ebf99eef
...
@@ -35,6 +35,8 @@ def set_cache_property(obj, name, get_func, set_func=None):
...
@@ -35,6 +35,8 @@ def set_cache_property(obj, name, get_func, set_func=None):
>>>
e
=
Example
()
>>>
e
=
Example
()
>>>
e
.
test
# Call, store and return result of e.slow_function
>>>
e
.
test
# Call, store and return result of e.slow_function
>>>
e
.
test
# Return stored result of e.slow_function
>>>
e
.
test
# Return stored result of e.slow_function
>>>
e
.
_test
=
None
# clear cache result
>>>
e
.
test
# Call, store and return result of e.slow_function
"""
"""
_name
=
"
_
"
+
name
_name
=
"
_
"
+
name
setattr
(
obj
,
_name
,
None
)
setattr
(
obj
,
_name
,
None
)
...
...
This diff is collapsed.
Click to expand it.
wetb/utils/cython_compile/cython_compile.py
+
2
−
1
View file @
ebf99eef
...
@@ -382,7 +382,8 @@ def py2pyx(pylines):
...
@@ -382,7 +382,8 @@ def py2pyx(pylines):
cdef
=
l
[
l
.
index
(
"
#c
"
)
+
1
:]
cdef
=
l
[
l
.
index
(
"
#c
"
)
+
1
:]
l
=
indent
+
cdef
l
=
indent
+
cdef
if
"
__future__
"
in
l
:
if
"
__future__
"
in
l
:
pyxlines
.
insert
(
0
,
l
)
# from __future__ import ... must be first
#pyxlines.insert(0, l) # from __future__ import ... must be first
pass
else
:
else
:
pyxlines
.
append
(
l
)
pyxlines
.
append
(
l
)
return
pyxlines
return
pyxlines
...
...
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