Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
GRID LRT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ASTRON SDC
GRID LRT
Commits
b5d5b599
Commit
b5d5b599
authored
4 years ago
by
Frits Sweijen
Browse files
Options
Downloads
Patches
Plain Diff
Change __setitem__ calls to []
parent
80d7bacd
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
Update design doc picas api
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GRID_LRT/token.py
+14
-14
14 additions, 14 deletions
GRID_LRT/token.py
with
14 additions
and
14 deletions
GRID_LRT/token.py
+
14
−
14
View file @
b5d5b599
...
...
@@ -129,14 +129,14 @@ class Token(dict):
using the python __get__ method, i.e. token[
'
field
'
]. Each token has a token_id that is unique
in the database, which it is part of, however the database interface is only defined in the
child classes of Token
"""
self
.
__setitem__
(
"
type
"
,
token_type
)
self
[
'
type
'
]
=
token_type
if
not
token_id
:
self
.
__setitem__
(
"
_id
"
,
token_type
)
self
[
'
_id
'
]
=
token_type
else
:
self
.
__setitem__
(
"
_id
"
,
token_id
)
self
.
__setitem__
(
"
PICAS_API_VERSION
"
,
GRID_LRT
.
__version__
)
self
.
__setitem__
(
"
lock
"
,
0
)
self
.
__setitem__
(
"
done
"
,
0
)
self
[
'
_id
'
]
=
token_id
self
[
'
PICAS_API_VERSION
'
]
=
GRID_LRT
.
__version__
self
[
'
lock
'
]
=
0
self
[
'
done
'
]
=
0
@property
def
database
(
self
):
...
...
@@ -173,15 +173,15 @@ class Token(dict):
"""
General interface to
'
reset
'
a Token as defined in PiCaS Standards.
The lock and done fields are timestamps and if are set to 0, the token will be
considered in the
'
todo
'
state
"""
self
.
__setitem__
(
"
lock
"
,
0
)
self
.
__setitem__
(
"
done
"
,
0
)
self
[
'
lock
'
]
=
0
self
[
'
done
'
]
=
0
scrub_count
=
self
.
get
(
"
scrub_count
"
,
0
)
##TODO: Get function override to get from db
self
.
__setitem__
(
"
scrub_count
"
,
scrub_count
+
1
)
self
.
__setitem__
(
"
hostname
"
,
""
)
self
.
__setitem__
(
"
output
"
,
""
)
self
.
__setitem__
(
"
status
"
,
"
reset
"
)
self
[
'
scrub_count
'
]
=
scrub_count
+
1
self
[
'
hostname
'
]
=
''
self
[
'
output
'
]
=
''
self
[
'
status
'
]
=
'
reset
'
def
archive
(
self
,
delete
=
False
):
"""
Archives all tokens, given a database. Deletes them if the delete flag is set to True
"""
...
...
@@ -330,7 +330,7 @@ class TokenList(list):
if
design_doc_name
not
in
self
.
database
:
self
.
_design_doc
.
save
()
self
.
_design_doc
.
fetch
()
self
.
_design_doc
.
__setitem__
(
"
PICAS_API_VERSION
"
,
GRID_LRT
.
__version__
)
self
.
_design_doc
[
'
PICAS_API_VERSION
'
]
=
GRID_LRT
.
__version__
self
.
_design_doc
.
save
()
def
add_attachment
(
self
,
filename
,
attachment_name
):
...
...
@@ -347,7 +347,7 @@ class TokenList(list):
if
isinstance
(
item
,
Token
):
if
'
PICAS_API_VERSION
'
in
item
:
# Custom version specified in the config file, update design doc PICAS_API_VERSION from token.
self
.
_design_doc
.
__setitem__
(
'
PICAS_API_VERSION
'
,
item
[
'
PICAS_API_VERSION
'
]
)
self
.
_design_doc
[
'
PICAS_API_VERSION
'
]
=
item
[
'
PICAS_API_VERSION
'
]
self
.
_design_doc
.
save
()
if
not
hasattr
(
self
,
'
database
'
):
self
.
database
=
item
.
database
...
...
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