Bug 1223385 - use in-tree compare-locales in mozharness, r=rail
authorAxel Hecht <axel@pike.org>
Fri, 08 Jan 2016 16:21:24 +0100
changeset 321223 a575f9a6f0d23fc469821192538456c90e13cffa
parent 321222 47e2dfac99d5cbd5c79d4103efc8661199f8a758
child 321224 a87a27864bb88946c005815272f225cb722f83e4
push id9351
push userjdescottes@mozilla.com
push dateWed, 13 Jan 2016 08:24:50 +0000
reviewersrail
bugs1223385
milestone46.0a1
Bug 1223385 - use in-tree compare-locales in mozharness, r=rail
testing/mozharness/mozharness/mozilla/l10n/locales.py
--- a/testing/mozharness/mozharness/mozilla/l10n/locales.py
+++ b/testing/mozharness/mozharness/mozilla/l10n/locales.py
@@ -30,20 +30,22 @@ class LocalesMixin(ChunkingMixin):
         self.locales = None
         self.gecko_locale_revisions = None
         self.l10n_revisions = {}
 
     def _get_mach_executable(self):
         python = self.query_exe('python2.7')
         return [python, 'mach']
 
-    def _mach(self, target, env, halt_on_failure=True, output_parser=None):
+    def _mach(self, target, env, error_list=None, halt_on_failure=True,
+              output_parser=None):
         dirs = self.query_abs_dirs()
         mach = self._get_mach_executable()
         return self.run_command(mach + target,
+                                error_list=error_list,
                                 halt_on_failure=True,
                                 env=env,
                                 cwd=dirs['abs_mozilla_dir'],
                                 output_parser=None)
 
     def query_locales(self):
         if self.locales is not None:
             return self.locales
@@ -149,30 +151,23 @@ class LocalesMixin(ChunkingMixin):
                     self.l10n_revisions[locale] = 'default'
                 locales.append(locale)
         else:
             locales = self.read_from_file(locales_file).split()
         return locales
 
     def run_compare_locales(self, locale, halt_on_failure=False):
         dirs = self.query_abs_dirs()
-        compare_locales_script = os.path.join(dirs['abs_compare_locales_dir'],
-                                              'scripts', 'compare-locales')
-        env = self.query_env(partial_env={'PYTHONPATH':
-                             os.path.join(dirs['abs_compare_locales_dir'],
-                                          'lib')})
+        env = self.query_bootstrap_env()
         compare_locales_error_list = list(PythonErrorList)
-        self.rmtree(dirs['abs_merge_dir'])
-        self.mkdir_p(dirs['abs_merge_dir'])
-        command = "python %s -m %s l10n.ini %s %s" % (compare_locales_script,
-                  dirs['abs_merge_dir'], dirs['abs_l10n_dir'], locale)
+        command = ['compare-locales',
+                  '--merge-dir', dirs['abs_merge_dir'], locale]
         self.info("*** BEGIN compare-locales %s" % locale)
-        status = self.run_command(command, error_list=compare_locales_error_list,
-                                  cwd=dirs['abs_locales_src_dir'], env=env,
-                                  halt_on_failure=halt_on_failure)
+        status = self._mach(command, env, error_list=compare_locales_error_list,
+                            halt_on_failure=halt_on_failure)
         self.info("*** END compare-locales %s" % locale)
         return status
 
     def query_abs_dirs(self):
         if self.abs_dirs:
             return self.abs_dirs
         abs_dirs = super(LocalesMixin, self).query_abs_dirs()
         c = self.config
@@ -195,18 +190,16 @@ class LocalesMixin(ChunkingMixin):
                 dirs['abs_objdir'] = c['objdir']
             else:
                 dirs['abs_objdir'] = os.path.join(dirs['abs_mozilla_dir'],
                                                   c['objdir'])
             dirs['abs_merge_dir'] = os.path.join(dirs['abs_objdir'],
                                                  'merged')
             dirs['abs_locales_dir'] = os.path.join(dirs['abs_objdir'],
                                                    c['locales_dir'])
-        dirs['abs_compare_locales_dir'] = os.path.join(dirs['abs_work_dir'],
-                                                       'compare-locales')
         for key in dirs.keys():
             if key not in abs_dirs:
                 abs_dirs[key] = dirs[key]
         self.abs_dirs = abs_dirs
         return self.abs_dirs
 
     # This requires self to inherit a VCSMixin.
     def pull_locale_source(self, hg_l10n_base=None, parent_dir=None, vcs='hg'):