Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hiboo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACIDES
Hiboo
Commits
3b213898
Commit
3b213898
authored
4 years ago
by
kaiyou
Browse files
Options
Downloads
Patches
Plain Diff
Simplify the tasks cli
parent
98aaaf58
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hiboo/cli.py
+2
-17
2 additions, 17 deletions
hiboo/cli.py
hiboo/profile/common.py
+10
-0
10 additions, 0 deletions
hiboo/profile/common.py
with
12 additions
and
17 deletions
hiboo/cli.py
+
2
−
17
View file @
3b213898
import
click
import
flask
import
time
import
datetime
from
flask
import
cli
from
flask
import
cli
from
hiboo
import
models
from
hiboo.profile
import
common
from
hiboo.profile
import
common
tasks
=
cli
.
AppGroup
(
"
tasks
"
)
tasks
=
cli
.
AppGroup
(
"
tasks
"
)
def
run_transitions
():
for
profile
in
models
.
Profile
.
transition_ready
().
all
():
print
(
"
Applying {}/{} to profile {}@{}
"
.
format
(
profile
.
transition
,
profile
.
transition_step
,
profile
.
username
,
profile
.
service
.
name
))
common
.
apply_transition
(
profile
)
models
.
db
.
session
.
commit
()
@tasks.command
(
"
once
"
)
@tasks.command
(
"
once
"
)
def
tasks_once
():
def
tasks_once
():
"""
Run regular tasks
"""
Run regular tasks
"""
"""
run
_transitions
()
common
.
apply_all
_transitions
()
@tasks.command
(
"
loop
"
)
@tasks.command
(
"
loop
"
)
...
@@ -31,6 +17,5 @@ def tasks_loop():
...
@@ -31,6 +17,5 @@ def tasks_loop():
"""
Run regular tasks at interval
"""
Run regular tasks at interval
"""
"""
while
True
:
while
True
:
run
_transitions
()
common
.
apply_all
_transitions
()
time
.
sleep
(
30
)
time
.
sleep
(
30
)
This diff is collapsed.
Click to expand it.
hiboo/profile/common.py
+
10
−
0
View file @
3b213898
from
hiboo
import
models
from
hiboo
import
models
def
apply_all_transitions
():
"""
Handle profile transitions for all profiles
"""
for
profile
in
models
.
Profile
.
transition_ready
().
all
():
apply_transition
(
profile
)
models
.
db
.
session
.
commit
()
def
apply_transition
(
profile
):
def
apply_transition
(
profile
):
"""
Handle profile transitions as a three step workflow
"""
Handle profile transitions as a three step workflow
...
@@ -13,6 +21,8 @@ def apply_transition(profile):
...
@@ -13,6 +21,8 @@ def apply_transition(profile):
Applying manual action sets the transition as DONE (it never reaches
Applying manual action sets the transition as DONE (it never reaches
the step START)
the step START)
"""
"""
print
(
"
Applying {}/{} to profile {}@{}
"
.
format
(
profile
.
transition
,
profile
.
transition_step
,
profile
.
username
,
profile
.
service
.
name
))
app
=
profile
.
service
.
application
app
=
profile
.
service
.
application
transition
=
profile
.
transition
transition
=
profile
.
transition
_
,
target
,
_
,
_
,
_
=
models
.
Profile
.
TRANSITIONS
[
transition
]
_
,
target
,
_
,
_
,
_
=
models
.
Profile
.
TRANSITIONS
[
transition
]
...
...
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