Content differences:
--- /usr/local/bin/wmf-beta-autoupdate.py.orig
+++ /usr/local/bin/wmf-beta-autoupdate.py
@@ -1,148 +0,0 @@
-#!/usr/bin/env python
-#######################################################################
-# WARNING: this file is managed by Puppet
-# puppet:///beta/wmf-beta-autoupdate.py.erb
-#######################################################################
-
-"""
-Updates MediaWiki core and extensions on the Beta cluster
-
-MUST be run as the `mwdeploy` user although that is not enforced by the script.
-"""
-
-import argparse
-import logging
-import subprocess
-import sys
-
-PATH_PORTAL = '/srv/mediawiki-staging/portal-master'
-PATH_MWCORE = '/srv/mediawiki-staging/php-master'
-PATH_MWEXT = '/srv/mediawiki-staging/php-master/extensions'
-PATH_MWSKIN = '/srv/mediawiki-staging/php-master/skins'
-PATH_VENDOR = '/srv/mediawiki-staging/php-master/vendor'
-
-
-def main():
- """
- Entry point for the script.
-
- Parse script arguments, initialize the logger withnice colors and trigger
- the updating tasks.
-
- Returns 0 on success of ALL tasks, 1 otherwise
- """
- # Parse arguments, init logger to use some colors
-
- options = parse_args()
- logging.basicConfig(level=options.log_level)
- # Color codes http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
- logging.addLevelName( # cyan
- logging.DEBUG, "\033[36m%s\033[0m" %
- logging.getLevelName(logging.DEBUG))
- logging.addLevelName( # green
- logging.INFO, "\033[32m%s\033[0m" %
- logging.getLevelName(logging.INFO))
- logging.addLevelName( # yellow
- logging.WARNING, "\033[33m%s\033[0m" %
- logging.getLevelName(logging.WARNING))
- logging.addLevelName( # red
- logging.ERROR, "\033[31m%s\033[0m" %
- logging.getLevelName(logging.ERROR))
- logging.addLevelName( # red background
- logging.CRITICAL, "\033[41m%s\033[0m" %
- logging.getLevelName(logging.CRITICAL))
-
- logger = logging.getLogger('main')
-
- logger.info("Starting updating tasks...")
- # TODO refactor to use a dict with 'name' as keys and function value
- exit_codes = [
- pull_repo(name='mwcore', path=PATH_MWCORE),
- pull_repo(name='mwvendor', path=PATH_VENDOR),
- pull_repo(name='mwextpull', path=PATH_MWEXT),
- submodule_sync(name='mwextpull', path=PATH_MWEXT),
- update_repo(name='mwextupdate', path=PATH_MWEXT),
- pull_repo(name='mwskinpull', path=PATH_MWSKIN),
- submodule_sync(name='mwskinupdate', path=PATH_MWSKIN),
- update_repo(name='mwskinupdate', path=PATH_MWSKIN),
- pull_repo(name='portal', path=PATH_PORTAL),
- ]
-
- logger.info("Executions completed %s", exit_codes)
-
- final_exit = 0
- for code in exit_codes:
- if code is not 0:
- final_exit = 1
- break
-
- logger.info("Final exit code: %s", final_exit)
- return final_exit
-
-
-def parse_args():
- """Parse command line arguments using argparse"""
-
- parser = argparse.ArgumentParser(description=__doc__)
-
- log_options = parser.add_mutually_exclusive_group()
- log_options.add_argument(
- '--debug', dest='log_level',
- action='store_const', const=logging.DEBUG,
- help='Print out internal processing')
- log_options.add_argument(
- '-v', '--verbose', '--info', dest='log_level',
- action='store_const', const=logging.INFO,
- help='Give a bit more information about what is going on')
- log_options.add_argument(
- '-q', '--quiet', dest='log_level',
- action='store_const', const=logging.WARNING,
- help='Only shows up warning and errors')
-
- return parser.parse_args()
-
-
-def git_head_ts(git_dir):
- """Returns timestamp of the HEAD committer date"""
- proc = subprocess.check_output(
- ['git', '--git-dir', git_dir, 'log',
- '--pretty=tformat:%ct', '-1', 'HEAD'])
- return proc.rstrip('\n')
-
-
-def pull_repo(name, path):
- """Pull repository at path"""
- return runner(name=name, path=path, cmd=['git', 'pull'])
-
-def submodule_sync(name, path):
- """Syncs the submodules in path"""
- return runner(name=name, path=path, cmd=[
- 'git', 'submodule', 'sync', '--recursive'])
-
-def update_repo(name, path):
- """Registers and updates submodules in path"""
- return runner(name=name, path=path, cmd=[
- 'git', 'submodule', 'update', '--init', '--recursive'])
-
-
-def runner(cmd, path=None, name=None):
- """Wrapper around subprocess.Popen with logging output"""
- log_target = name if name else 'runner'
- logger = logging.getLogger(log_target)
-
- try:
- if path:
- logger.info("cwd: %s", path)
- logger.info("running: %s", ' '.join(cmd))
-
- cmd = subprocess.Popen(args=cmd, cwd=path)
- exit_code = cmd.wait()
- logger.info("Exit code: %s", exit_code)
- except OSError, exception:
- logger.error(exception)
- return False
-
- return exit_code
-
-if __name__ == '__main__':
- sys.exit(main())