Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 632dd35

Browse files
committed
Merge pull request alphagov#80 from alphagov/add-whitehall-de-dupe
Add tasks for deduping stats announcements
2 parents 38bce63 + b82fec4 commit 632dd35

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

fabfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import search
3535
import statsd
3636
import vm
37+
import whitehall
3738

3839
HERE = os.path.dirname(__file__)
3940
SSH_DIR = os.path.join(HERE, '.ssh')

whitehall.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from fabric.api import task, hosts, sudo, cd, execute
2+
3+
4+
@task
5+
def dedupe_stats_announcement_from_file(filename):
6+
"""De-duplicate Whitehall statistics accouncements from a CSV file"""
7+
with open(filename) as fd:
8+
duplicates = [line.strip().split(',') for line in fd]
9+
for duplicate_slug, authoritative_slug in duplicates:
10+
execute(
11+
dedupe_stats_announcement, duplicate_slug, authoritative_slug)
12+
13+
14+
@task
15+
@hosts('whitehall-backend-1.backend')
16+
def dedupe_stats_announcement(duplicate_slug, authoritative_slug):
17+
"""De-duplicate Whitehall statistics announcement"""
18+
command = 'govuk_setenv whitehall ./script/dedupe_stats_announcement {} {}'
19+
with cd('/var/apps/whitehall'):
20+
sudo(command.format(duplicate_slug, authoritative_slug),
21+
user='deploy')

0 commit comments

Comments
 (0)