Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
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
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
AURA
steering
Commits
1ee75613
Commit
1ee75613
authored
8 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
added management commands to chech and remove stale automation_ids
parent
4cfbc102
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
program/management/commands/check_automation_ids.py
+35
-0
35 additions, 0 deletions
program/management/commands/check_automation_ids.py
program/management/commands/remove_automation_id.py
+16
-0
16 additions, 0 deletions
program/management/commands/remove_automation_id.py
with
51 additions
and
0 deletions
program/management/commands/check_automation_ids.py
0 → 100644
+
35
−
0
View file @
1ee75613
import
json
from
os.path
import
join
from
django.conf
import
settings
from
django.core.management.base
import
NoArgsCommand
from
program.models
import
ProgramSlot
class
Command
(
NoArgsCommand
):
help
=
'
checks the automation_ids used by program slots against the exported
'
def
handle_noargs
(
self
,
**
options
):
cache_dir
=
getattr
(
settings
,
'
AUTOMATION_CACHE_DIR
'
,
'
cache
'
)
cached_shows
=
join
(
cache_dir
,
'
shows.json
'
)
with
open
(
cached_shows
)
as
shows_json
:
shows
=
json
.
loads
(
shows_json
.
read
())[
'
shows
'
]
automation_ids
=
[]
for
show
in
shows
:
automation_ids
.
append
(
show
[
'
id
'
])
automation_ids
.
sort
()
automation_ids2
=
[]
for
programslot
in
ProgramSlot
.
objects
.
filter
(
automation_id__isnull
=
False
):
automation_ids2
.
append
(
int
(
programslot
.
automation_id
))
automation_ids2
.
sort
()
for
automation_id
in
automation_ids
:
if
automation_id
not
in
automation_ids2
:
print
'
+
'
,
automation_id
for
automation_id
in
automation_ids2
:
if
automation_id
not
in
automation_ids
:
print
'
-
'
,
automation_id
This diff is collapsed.
Click to expand it.
program/management/commands/remove_automation_id.py
0 → 100644
+
16
−
0
View file @
1ee75613
from
django.core.management.base
import
BaseCommand
,
CommandError
from
program.models
import
ProgramSlot
class
Command
(
BaseCommand
):
help
=
'
removes the automation_id from the program slots
'
args
=
'
<automation_id>
'
def
handle
(
self
,
*
args
,
**
options
):
if
len
(
args
)
==
1
:
automation_id
=
args
[
0
]
else
:
raise
CommandError
(
'
you must provide the automation_id
'
)
ProgramSlot
.
objects
.
filter
(
automation_id
=
automation_id
).
update
(
automation_id
=
None
)
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