Index: CMT/HEAD/ChangeLog
===================================================================
--- CMT/HEAD/ChangeLog	(revision 513)
+++ CMT/HEAD/ChangeLog	(revision 514)
@@ -1,2 +1,8 @@
+2009-07-01    <rybkin@lal.in2p3.fr> 403
+	
+	* mgr/cmt_svn_checkout.py: Introduce a version working on Windows. Do not
+	use module commands, instead, in class Utils, introduce portable (static)
+	methods	getstatusoutput, getstatuserror, and make use of them
+	
 2009-06-27    <rybkin@lal.in2p3.fr> 402
 	
Index: CMT/HEAD/mgr/cmt_svn_checkout.py
===================================================================
--- CMT/HEAD/mgr/cmt_svn_checkout.py	(revision 513)
+++ CMT/HEAD/mgr/cmt_svn_checkout.py	(revision 514)
@@ -23,6 +23,6 @@
 """
 
-__version__ = '0.3.0'
-__date__ = 'Thu Jun 27 2009'
+__version__ = '0.4.0'
+__date__ = 'Wed Jul 01 2009'
 __author__ = 'Grigory Rybkin'
 
@@ -39,5 +39,4 @@
             urlparse.uses_netloc.append(p)
 import tempfile
-import commands
 import re
 
@@ -49,4 +48,38 @@
 #           % (self, str(e))
 #     sys.exit(1)
+
+class Utils(object):
+    def getstatusoutput(cmd):
+        """Return (status, stdout + stderr) of executing cmd in a shell.
+        
+        A trailing line separator is removed from the output string. The exit status of the command is encoded in the format specified for wait(), when the exit status is zero (termination without errors), 0 is returned.
+        """
+        p = os.popen('( %s ) 2>&1' % cmd, 'r')
+        out = p.read()
+        sts = p.close()
+        if sts is None: sts = 0
+        if out.endswith(os.linesep):
+            out = out[:out.rindex(os.linesep)]
+        elif out[-1:] == '\n': out = out[:-1]
+        return sts, out
+    getstatusoutput = staticmethod(getstatusoutput)
+    
+    def getstatuserror(cmd):
+        """Return (status, stderr) of executing cmd in a shell.
+        
+        On Unix, the return value is the exit status of the command is encoded in the format specified for wait(). On Windows, on command.com systems (Windows 95, 98 and ME) this is always 0; on cmd.exe systems (Windows NT, 2000 and XP) this is the exit status of the command run.
+        """
+        fd, p = tempfile.mkstemp()
+        os.close(fd)
+#        print >> sys.stderr, 'Created file %s with fd %i' % (p, fd)
+#        p = os.tempnam()
+#        print >> sys.stderr, 'Created file name %s' % (p)
+        sc = os.system('( %s ) 2>%s' % (cmd, p))
+        f = open(p)
+        e = f.read()
+        f.close()
+        os.unlink(p)
+        return sc, e
+    getstatuserror = staticmethod(getstatuserror)
 
 class ClientContext(object):
@@ -154,5 +187,5 @@
         message = ': '.join([str(arg) for arg in instance.args])
     except AttributeError:
-        message = instance
+        message = str(instance).rstrip()
     if location: location += ': '
     print >> file, "%s%s" % (location, message)
@@ -302,5 +335,5 @@
         cmd = 'svn diff %s %s' % (path1, path2)
 #        cmd = 'svn diff --summarize %s %s' % (path1, path2)
-        sc, out = commands.getstatusoutput(cmd)
+        sc, out = Utils.getstatusoutput(cmd)
         if sc != 0:
             return 2
@@ -341,5 +374,5 @@
 #        trunk = posixpath.normpath(posixpath.join(module.url, self.trunk))
         cmd = 'svn info %s' % trunk
-        sc, out = commands.getstatusoutput(cmd)
+        sc, out = Utils.getstatusoutput(cmd)
         if sc != 0:
             return None
@@ -360,5 +393,5 @@
 #        tags = posixpath.normpath(posixpath.join(module.url, self.tags))
         cmd = 'svn ls -v %s' % tags
-        sc, out = commands.getstatusoutput(cmd)
+        sc, out = Utils.getstatusoutput(cmd)
         if sc != 0:
             return None
@@ -471,5 +504,5 @@
 
     def execute(self, cmt_context, client_context):
-        sc = 0
+        sce = 0
 
         for m in self.modules:
@@ -478,8 +511,9 @@
             err = []
             for url in m.URL:
-#                cmd = 'svn checkout -q %s %s 2>/dev/null' % (url, m.path)
-                cmd = 'svn checkout -q %s %s' % (url, m.path)
-                sc, e = commands.getstatusoutput(cmd)
-                #sc = os.system(cmd)
+                cmd = 'svn checkout %s %s' % (url, m.path)
+#                cmd = 'svn checkout -q %s %s' % (url, m.path)
+                sc, e = Utils.getstatuserror(cmd)
+#                 cmd = 'svn checkout -q %s %s' % (url, m.path)
+#                 sc, e = Utils.getstatusoutput(cmd)
                 if 0 == sc:
 #                 try:
@@ -508,6 +542,5 @@
 #                 print >> sys.stderr, 'Failed to checkout %s into %s.' % \
 #                       (' or '.join(m.URL), m.path)
-                sc += 1
-                continue
+                sce += 1
 
 #            print 'Checked out revision %i.' % result_rev
@@ -516,7 +549,7 @@
                 print >> sys.stderr, \
                       '%s %s: configure returned %i.' % (m.path, m.version, scc)
-            sc += scc
-
-        return sc
+            sce += scc
+
+        return sce
 
 def main(argv=[__name__]):
