[MediaWiki-commits] [Gerrit] Check for l10n cache before sync-wikiversions - change (mediawiki...scap)

2015-07-28 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Check for l10n cache before sync-wikiversions
..


Check for l10n cache before sync-wikiversions

Abort sync-wikiversions if critical files are missing.

This fixes T100573 by testing for the existence of:
* STAGE/php-$VERSION/cache/l10n/l10n_cache-en.cdb
* STAGE/wmf-config/ExtensionMessages-$VERSION.php

Bug: T100573
Change-Id: I50adefa19c0e3916d25703d78934b743a5f64da7
---
M scap/main.py
M scap/utils.py
2 files changed, 32 insertions(+), 0 deletions(-)

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



diff --git a/scap/main.py b/scap/main.py
index 70402b0..7861ca4 100644
--- a/scap/main.py
+++ b/scap/main.py
@@ -455,6 +455,20 @@
 def main(self, *extra_args):
 self._assert_auth_sock()
 
+# check for the presence of ExtensionMessages and l10n cache
+# for every branch of mediawiki that is referenced in wikiversions.json
+# to avoid syncing a branch that is lacking these critical files.
+for version, wikidb in self.active_wikiversions().items():
+ext_msg = os.path.join(self.config['stage_dir'],
+'wmf-config', 'ExtensionMessages-%s.php' % version)
+err_msg = 'ExtensionMessages not found in {}' % ext_msg
+utils.check_file_exists(ext_msg, err_msg)
+
+cache_file = os.path.join(self.config['stage_dir'],
+'php-%s' % version, 'cache', 'l10n', 'l10n_cache-en.cdb')
+err_msg = 'l10n cache missing for {}' % version
+utils.check_file_exists(cache_file, err_msg)
+
 mw_install_hosts = utils.read_dsh_hosts_file(
 self.config['dsh_targets'])
 tasks.sync_wikiversions(mw_install_hosts, self.config)
diff --git a/scap/utils.py b/scap/utils.py
index ff1a31d..d4ed209 100644
--- a/scap/utils.py
+++ b/scap/utils.py
@@ -323,6 +323,24 @@
 )
 
 
+def check_exists(path, message=False):
+if not os.path.isfile(path):
+raise IOError(
+errno.ENOENT,
+message or 'Error: %s is not a file.' % path,
+path
+)
+
+
+def check_dir_exists(path, message=False):
+if not os.path.isdir(path):
+raise IOError(
+errno.ENOTDIR,
+message or 'Error: %s is not a directory.' % path,
+path
+)
+
+
 def check_php_opening_tag(path):
 Checks a PHP file to make sure nothing is before the opening ?php
 except for shebangs.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I50adefa19c0e3916d25703d78934b743a5f64da7
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/tools/scap
Gerrit-Branch: master
Gerrit-Owner: 20after4 mmod...@wikimedia.org
Gerrit-Reviewer: 20after4 mmod...@wikimedia.org
Gerrit-Reviewer: BryanDavis bda...@wikimedia.org
Gerrit-Reviewer: Reedy re...@wikimedia.org
Gerrit-Reviewer: jenkins-bot 

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


[MediaWiki-commits] [Gerrit] Check for l10n cache before sync-wikiversions - change (mediawiki...scap)

2015-07-22 Thread 20after4 (Code Review)
20after4 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/226353

Change subject: Check for l10n cache before sync-wikiversions
..

Check for l10n cache before sync-wikiversions

Abort sync-wikiversions if critical files are missing.

This fixes T100573 by testing for the existence of:
* STAGE/php-$VERSION/cache/l10n/l10n_cache-en.cdb
* STAGE/wmf-config/ExtensionMessages-$VERSION.php

Bug: T100573
Change-Id: I50adefa19c0e3916d25703d78934b743a5f64da7
---
M scap/main.py
1 file changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/scap 
refs/changes/53/226353/1

diff --git a/scap/main.py b/scap/main.py
index 70402b0..ffb128e 100644
--- a/scap/main.py
+++ b/scap/main.py
@@ -455,6 +455,24 @@
 def main(self, *extra_args):
 self._assert_auth_sock()
 
+for version, wikidb in self.active_wikiversions().items():
+extension_messages = os.path.join(
+self.config['stage_dir'],
+'wmf-config', 'ExtensionMessages-%s.php' % version)
+
+if not os.path.isfile(extension_messages):
+raise IOError(errno.ENOENT, 'File not found',
+extension_messages)
+
+cache_dir = os.path.join(
+self.config['stage_dir'],
+'php-%s' % version, 'cache', 'l10n')
+cache_file = os.path.join(cache_dir, 'l10n_cache-en.cdb')
+
+if not os.path.isfile(cache_file):
+raise IOError(errno.ENOENT,
+'l10n cache missing for %s' % version, cache_file)
+
 mw_install_hosts = utils.read_dsh_hosts_file(
 self.config['dsh_targets'])
 tasks.sync_wikiversions(mw_install_hosts, self.config)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I50adefa19c0e3916d25703d78934b743a5f64da7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/scap
Gerrit-Branch: master
Gerrit-Owner: 20after4 mmod...@wikimedia.org

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