mostly adapt the i18n subsystem to limitation wrt redirection handinling in windows, using the -o argument of the utilities 3.5
authorAurélien Campéas
Mon, 07 Sep 2009 17:46:28 +0200
branch3.5
changeset 3117 32686ae66c75
parent 3116 8bf500eb01d6
child 3118 9e7a155bc4e5
mostly adapt the i18n subsystem to limitation wrt redirection handinling in windows, using the -o argument of the utilities
common/i18n.py
cwctl.py
devtools/devctl.py
etwist/server.py
--- a/common/i18n.py	Mon Sep 07 12:23:42 2009 +0200
+++ b/common/i18n.py	Mon Sep 07 17:46:28 2009 +0200
@@ -44,9 +44,10 @@
     status != 0
     """
     print cmd.replace(os.getcwd() + os.sep, '')
-    status = os.system(cmd)
+    from subprocess import call
+    status = call(cmd)
     if status != 0:
-        raise Exception()
+        raise Exception('status = %s' % status)
 
 
 def available_catalogs(i18ndir=None):
@@ -74,8 +75,8 @@
         mergedpo = join(destdir, '%s_merged.po' % lang)
         try:
             # merge instance/cubes messages catalogs with the stdlib's one
-            execute('msgcat --use-first --sort-output --strict %s > %s'
-                    % (' '.join(pofiles), mergedpo))
+            execute('msgcat --use-first --sort-output --strict -o %s %s'
+                    % (mergedpo, ' '.join('"%s"' % f for f in pofiles)))
             # make sure the .mo file is writeable and compile with *msgfmt*
             applmo = join(destdir, lang, 'LC_MESSAGES', 'cubicweb.mo')
             try:
--- a/cwctl.py	Mon Sep 07 12:23:42 2009 +0200
+++ b/cwctl.py	Mon Sep 07 17:46:28 2009 +0200
@@ -29,7 +29,7 @@
     while nbtry < maxtry:
         try:
             kill(pid, signal.SIGUSR1)
-        except OSError:
+        except (OSError, AttributeError): # XXX win32
             break
         nbtry += 1
         sleep(waittime)
--- a/devtools/devctl.py	Mon Sep 07 12:23:42 2009 +0200
+++ b/devtools/devctl.py	Mon Sep 07 17:46:28 2009 +0200
@@ -260,6 +260,7 @@
         from logilab.common.shellutils import globfind, find, rm
         from cubicweb.common.i18n import extract_from_tal, execute
         tempdir = tempfile.mkdtemp()
+        assert exists(tempdir)
         potfiles = [join(I18NDIR, 'static-messages.pot')]
         print '-> extract schema messages.'
         schemapot = join(tempdir, 'schema.pot')
@@ -283,22 +284,23 @@
             if lang is not None:
                 cmd += ' -L %s' % lang
             potfile = join(tempdir, '%s.pot' % id)
-            execute(cmd % (potfile, ' '.join(files)))
+            execute(cmd % (potfile, ' '.join('"%s"' % f for f in files)))
             if exists(potfile):
                 potfiles.append(potfile)
             else:
                 print '-> WARNING: %s file was not generated' % potfile
         print '-> merging %i .pot files' % len(potfiles)
         cubicwebpot = join(tempdir, 'cubicweb.pot')
-        execute('msgcat %s > %s' % (' '.join(potfiles), cubicwebpot))
+        execute('msgcat -o %s %s' % (cubicwebpot, ' '.join('"%s"' % f for f in potfiles)))
         print '-> merging main pot file with existing translations.'
         chdir(I18NDIR)
         toedit = []
         for lang in LANGS:
             target = '%s.po' % lang
-            execute('msgmerge -N --sort-output  %s %s > %snew' % (target, cubicwebpot, target))
+            execute('msgmerge -N --sort-output -o %snew %s %s' % (target, cubicwebpot, target))
             ensure_fs_mode(target)
             shutil.move('%snew' % target, target)
+            assert exists(target)
             toedit.append(abspath(target))
         # cleanup
         rm(tempdir)
@@ -395,7 +397,8 @@
         potfiles.append(tmppotfile)
     potfile = join(tempdir, 'cube.pot')
     print '-> merging %i .pot files:' % len(potfiles)
-    execute('msgcat %s > %s' % (' '.join(potfiles), potfile))
+    execute('msgcat -o %s %s' % (potfile,
+                                 ' '.join('"%s"' % f for f in potfiles)))
     print '-> merging main pot file with existing translations:'
     chdir('i18n')
     for lang in LANGS:
@@ -404,7 +407,7 @@
         if not exists(cubepo):
             shutil.copy(potfile, cubepo)
         else:
-            execute('msgmerge -N -s %s %s > %snew' % (cubepo, potfile, cubepo))
+            execute('msgmerge -N -s -o %snew %s %s' % (cubepo, potfile, cubepo))
             ensure_fs_mode(cubepo)
             shutil.move('%snew' % cubepo, cubepo)
         toedit.append(abspath(cubepo))
--- a/etwist/server.py	Mon Sep 07 12:23:42 2009 +0200
+++ b/etwist/server.py	Mon Sep 07 17:46:28 2009 +0200
@@ -15,11 +15,13 @@
 from urlparse import urlsplit, urlunsplit
 import hotshot
 
-from twisted.application import service, strports
+from twisted.application import strports
 try:
     from twisted.scripts._twistd_unix import daemonize
 except ImportError:
-    pass
+    def daemonize():
+        raise NotImplementedError('not yet for win32')
+
 from twisted.internet import reactor, task, threads
 from twisted.internet.defer import maybeDeferred
 from twisted.web2 import channel, http, server, iweb