[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: WIP: Simple wrapper around updating the interwiki cache

2017-07-26 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/363970 )

Change subject: WIP: Simple wrapper around updating the interwiki cache
..


WIP: Simple wrapper around updating the interwiki cache

Change-Id: I4a709e8379f7054b1a21a8aff0487403f661b055
---
A scap/plugins/updateinterwikicache.py
1 file changed, 52 insertions(+), 0 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scap/plugins/updateinterwikicache.py 
b/scap/plugins/updateinterwikicache.py
new file mode 100644
index 000..ef428c0
--- /dev/null
+++ b/scap/plugins/updateinterwikicache.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+"""
+scap.plugins.updateinterwikicache
+~
+For updating + syncing the interwiki cache
+"""
+import os
+import subprocess
+
+import scap.cli as cli
+import scap.main as main
+import scap.tasks as tasks
+import scap.utils as utils
+
+
+@cli.command('update-interwiki-cache')
+class UpdateInterwikiCache(main.SyncFile):
+""" Scap sub-command to update and sync the interwiki cache """
+
+def main(self, *extra_args):
+""" Update the latest interwiki cache! """
+self.arguments.message = 'Updating interwiki cache'
+return super(UpdateInterwikiCache, self).main(*extra_args)
+
+def _before_cluster_sync(self):
+interwikifile = os.path.join(self.config['stage_dir'], 'wmf-config',
+ 'interwiki.php')
+self.include = os.path.relpath(interwikifile, self.config['stage_dir'])
+
+with open(interwikifile, 'w') as outfile:
+subprocess.check_call(
+['/usr/local/bin/mwscript',
+ 'extensions/WikimediaMaintenance/dumpInterwiki.php'],
+stdout=outfile
+)
+
+# This shouldn't happen, but let's be safe
+tasks.check_valid_syntax(interwikifile)
+
+subprocess.check_call(['/usr/bin/git', 'add', interwikifile])
+subprocess.check_call(['/usr/bin/git', 'commit', '-q', '-m',
+   self.arguments.message])
+
+subprocess.check_call(['/usr/bin/git', 'push', '-q', 'origin',
+   'HEAD:refs/for/master%l=Code-Review+2'])
+
+if not utils.confirm('Has Jenkins merged your gerrit change yet?'):
+subprocess.check_call(['/usr/bin/git', 'reset', '--hard',
+   'origin/master'])
+raise RuntimeError('Aborting, you should not sync unmerged code')
+
+subprocess.check_call(['/usr/bin/git', 'pull', '-q'])

-- 
To view, visit https://gerrit.wikimedia.org/r/363970
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4a709e8379f7054b1a21a8aff0487403f661b055
Gerrit-PatchSet: 6
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Chad 
Gerrit-Reviewer: Chad 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Thcipriani 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: WIP: Simple wrapper around updating the interwiki cache

2017-07-07 Thread Chad (Code Review)
Chad has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/363970 )

Change subject: WIP: Simple wrapper around updating the interwiki cache
..

WIP: Simple wrapper around updating the interwiki cache

Change-Id: I4a709e8379f7054b1a21a8aff0487403f661b055
---
A scap/plugins/updateinterwikicache.py
1 file changed, 51 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/70/363970/1

diff --git a/scap/plugins/updateinterwikicache.py 
b/scap/plugins/updateinterwikicache.py
new file mode 100644
index 000..29170f6
--- /dev/null
+++ b/scap/plugins/updateinterwikicache.py
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+"""
+scap.plugins.updateinterwikicache
+~
+For updating + syncing the interwiki cache
+"""
+import os
+import subprocess
+
+import scap.cli as cli
+import scap.main as main
+import scap.tasks as tasks
+import scap.utils as utils
+
+
+@cli.command('update-interwiki-cache')
+class UpdateInterwikiCache(main.SyncFile):
+""" Scap sub-command to update and sync the interwiki cache """
+
+def main(self, *extra_args):
+""" Update the latest interwiki cache! """
+self.arguments.message = 'Updating interwiki cache'
+return super(UpdateInterwikiCache, self).main(*extra_args)
+
+def _before_cluster_sync(self):
+interwikifile = os.path.join(self.config['stage_dir'], 'wmf-config',
+ 'interwiki.php')
+self.include = os.path.relpath(interwikifile, self.config['stage_dir'])
+
+with open(interwikifile) as outfile:
+subprocess.check_call(
+['/usr/local/bin/mwscript',
+ 'extensions/WikimediaMaintenance/dumpInterwiki.php'],
+stdout=outfile
+)
+
+# This shouldn't happen, but let's be safe
+tasks.check_valid_syntax(interwikifile)
+
+subprocess.check_call(['/usr/bin/git', 'commit', '-q', '-m',
+   self.arguments.message, self.arguments.include])
+
+subprocess.check_call(['/usr/bin/git', 'push', '-q', 'origin',
+   'HEAD:refs/for/master%l=Code-Review+2'])
+
+if not utils.confirm('Has Jenkins merged your gerrit change yet?'):
+subprocess.check_call(['/usr/bin/git', 'reset', '--hard',
+   'origin/master'])
+raise RuntimeError('Aborting, you should not sync unmerged code')
+
+subprocess.check_call('/usr/bin/git', 'pull')

-- 
To view, visit https://gerrit.wikimedia.org/r/363970
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a709e8379f7054b1a21a8aff0487403f661b055
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Chad 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits