Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F64831507
slurmaccount.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, May 29, 19:02
Size
2 KB
Mime Type
text/x-python
Expires
Fri, May 31, 19:02 (2 d)
Engine
blob
Format
Raw Data
Handle
17964695
Attached To
R11586 sausage-api
slurmaccount.py
View Options
# © All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE,
# Switzerland
# SCITAS - Scientific IT and Application Support, 2021
# See the LICENSE.txt file for more details.
import
falcon
from
sausage.esoperations
import
ESOp
from
sausage.dboperations
import
DBOp
from
sausage.printer
import
PrintJson
class
SlurmAccount
(
object
):
def
on_get_account
(
self
,
req
,
resp
,
account
):
response
=
{
"name"
:
account
,
"null"
:
{
"time"
:
0
,
"chf"
:
0
,
"co2"
:
0
,
}
}
try
:
newdb
=
DBOp
()
record
=
newdb
.
get_account
(
account
)
if
record
:
pjson
=
PrintJson
(
"account"
,
record
)
response
=
pjson
.
response
except
BaseException
:
response
=
{
"except"
:
{
"time"
:
-
1
,
"chf"
:
-
1
,
"co2"
:
-
1
,
}
}
resp
.
status
=
falcon
.
HTTP_200
resp
.
media
=
response
def
on_get_user
(
self
,
req
,
resp
,
username
,
account
=
'null'
):
response
=
{
"name"
:
username
,
account
:
{
"null"
:
{
"time"
:
0
,
"chf"
:
0
,
"co2"
:
0
,
}
}
}
try
:
newdb
=
DBOp
()
record
=
newdb
.
get_user
(
username
,
account
)
if
record
:
if
username
==
"all"
:
pjson
=
PrintJson
(
"all"
,
record
)
else
:
pjson
=
PrintJson
(
"user"
,
record
)
response
=
pjson
.
response
except
BaseException
:
response
=
{
"name"
:
username
,
account
:
{
"null"
:
{
"time"
:
0
,
"chf"
:
0
,
"co2"
:
0
,
}
}
}
resp
.
status
=
falcon
.
HTTP_200
resp
.
media
=
response
Event Timeline
Log In to Comment