Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
west-public
westpy
Commits
1f8e5eec
Commit
1f8e5eec
authored
Sep 12, 2018
by
Marco Govoni
Browse files
Added downloads
parent
586d901c
Changes
1
Hide whitespace changes
Inline
Side-by-side
westpy/connection.py
View file @
1f8e5eec
...
...
@@ -73,7 +73,7 @@ class Connection(object):
print
(
'The Executor is not responding.'
,
e
)
return
json
.
loads
(
response
.
text
)
def
run
(
self
,
executable
=
None
,
inputFile
=
None
,
outputFile
=
None
,
number_of_cores
=
2
)
:
def
run
(
self
,
executable
=
None
,
inputFile
=
None
,
outputFile
=
None
,
downloadUrl
=
[],
number_of_cores
=
2
)
:
"""runs the executable using rest api remotely.
:param executable: name of executable
...
...
@@ -82,6 +82,8 @@ class Connection(object):
:type inputFile: string
:param outputFile: name of output file
:type outputFile: string
:param downloadUrl: URLs to be downloaded
:type downloadUrl: list of string
:param number_of_cores: number of cores
:type number_of_cores: int
...
...
@@ -89,14 +91,13 @@ class Connection(object):
>>> from westpy import *
>>> connection = Connection("email@domain.com")
>>> connection.run( "pw", "pw.in", "pw.out", 3 )
>>> connection.run( "pw", "pw.in", "pw.out",
["http://www.quantum-simulation.org/potentials/sg15_oncv/upf/C_ONCV_PBE-1.0.upf"] ,
3 )
>>> connection.stop()
"""
#
import
json
#
download_urls
=
[]
output_dict
=
{}
if
executable
and
(
"pw"
in
str
(
executable
).
lower
()
or
"wstat"
in
str
(
executable
).
lower
()
or
"wfreq"
in
str
(
executable
).
lower
())
:
# set inputs
...
...
@@ -104,10 +105,8 @@ class Connection(object):
inputFile
=
str
(
executable
)
+
".in"
if
outputFile
is
None
:
outputFile
=
str
(
executable
)
+
".out"
for
key
in
self
.
geom
.
species
.
keys
()
:
download_urls
.
append
(
self
.
geom
.
species
[
key
][
"url"
])
try
:
output
=
self
.
__runExecutable
(
executable
,
inputFile
,
download
_u
rl
s
,
number_of_cores
)
output
=
self
.
__runExecutable
(
executable
,
inputFile
,
download
U
rl
,
number_of_cores
)
output_json
=
json
.
loads
(
output
)
if
"Error"
in
output_json
:
print
(
"Execution failed with the following error
\n
"
,
output_json
[
'Error'
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment