Created
January 28, 2015 14:15
-
-
Save sheagcraig/0c8cca1deb3c859bfd39 to your computer and use it in GitHub Desktop.
Down and dirty reposado Voice product cleansing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
"""Down and dirty removal of deprecated voice products and addition of | |
new voice products for reposado. It makes a few mistakes (products that | |
have 'voice' in the title that aren't properly a Voice Product. | |
Don't just go and run this! | |
""" | |
import shlex | |
import subprocess | |
# Remove Deprecated voice products | |
repoutil_products = subprocess.Popen(['/nfs/lsfiles/reposado/code/repoutil', | |
'--deprecated'], stdout=subprocess.PIPE) | |
deprecated_products = repoutil_products.communicate()[0].splitlines() | |
dep_voice_products = [dep_prod for dep_prod in deprecated_products if 'Voice' | |
in dep_prod] | |
product_numbers = [line.split(' ')[0] for line in dep_voice_products] | |
remove_cmd_production = shlex.split( | |
'/nfs/lsfiles/reposado/code/repoutil --purge-products=%s' % | |
product_numbers.pop()) + product_numbers | |
# Use Popen rather than check_call because our reposado server is CentOS 6.5 | |
# with Python 2.6 (sad trumpet) | |
remove_process = subprocess.Popen(remove_cmd_production, | |
stdout=subprocess.PIPE) | |
for line in remove_process.communicate()[0].splitlines(): | |
print(line) | |
# Add new voice products | |
repoutil_products = subprocess.Popen(['/nfs/lsfiles/reposado/code/repoutil', | |
'--products'], stdout=subprocess.PIPE) | |
products = repoutil_products.communicate()[0].splitlines() | |
voice_products = [prod for prod in products if 'Voice' in prod and | |
'production' not in prod and 'testing' not in prod] | |
product_numbers = [line.split(' ')[0] for line in voice_products] | |
add_cmd_production = shlex.split( | |
'/nfs/lsfiles/reposado/code/repoutil --add-products=%s' % | |
product_numbers.pop()) + product_numbers + ['production'] | |
add_process = subprocess.Popen(add_cmd_production, stdout=subprocess.PIPE) | |
for line in add_process.communicate()[0].splitlines(): | |
print(line) | |
add_cmd_testing = shlex.split( | |
'/nfs/lsfiles/reposado/code/repoutil --add-products=%s' % | |
product_numbers.pop()) + product_numbers + ['testing'] | |
add_process = subprocess.Popen(add_cmd_testing, stdout=subprocess.PIPE) | |
for line in add_process.communicate()[0].splitlines(): | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't feel the need to keep old copies of Voice updates, so I just purge them. It's no big deal to do this in bash and just have it recreate the catalogs for each product number that gets updated. This way, it only does one
repoutil --remove-products=
rather than a bazillionrepoutil --remove-product=
Uses Popen instead of check_call because CentOS 6.5 is still on python 2.6 😊