Changeset 514
- Timestamp:
- Jul 1, 2009, 5:29:45 PM (15 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r513 r514 1 2009-07-01 <rybkin@lal.in2p3.fr> 403 2 3 * mgr/cmt_svn_checkout.py: Introduce a version working on Windows. Do not 4 use module commands, instead, in class Utils, introduce portable (static) 5 methods getstatusoutput, getstatuserror, and make use of them 6 1 7 2009-06-27 <rybkin@lal.in2p3.fr> 402 2 8 -
CMT/HEAD/mgr/cmt_svn_checkout.py
r513 r514 23 23 """ 24 24 25 __version__ = '0. 3.0'26 __date__ = ' Thu Jun 272009'25 __version__ = '0.4.0' 26 __date__ = 'Wed Jul 01 2009' 27 27 __author__ = 'Grigory Rybkin' 28 28 … … 39 39 urlparse.uses_netloc.append(p) 40 40 import tempfile 41 import commands42 41 import re 43 42 … … 49 48 # % (self, str(e)) 50 49 # sys.exit(1) 50 51 class Utils(object): 52 def getstatusoutput(cmd): 53 """Return (status, stdout + stderr) of executing cmd in a shell. 54 55 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. 56 """ 57 p = os.popen('( %s ) 2>&1' % cmd, 'r') 58 out = p.read() 59 sts = p.close() 60 if sts is None: sts = 0 61 if out.endswith(os.linesep): 62 out = out[:out.rindex(os.linesep)] 63 elif out[-1:] == '\n': out = out[:-1] 64 return sts, out 65 getstatusoutput = staticmethod(getstatusoutput) 66 67 def getstatuserror(cmd): 68 """Return (status, stderr) of executing cmd in a shell. 69 70 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. 71 """ 72 fd, p = tempfile.mkstemp() 73 os.close(fd) 74 # print >> sys.stderr, 'Created file %s with fd %i' % (p, fd) 75 # p = os.tempnam() 76 # print >> sys.stderr, 'Created file name %s' % (p) 77 sc = os.system('( %s ) 2>%s' % (cmd, p)) 78 f = open(p) 79 e = f.read() 80 f.close() 81 os.unlink(p) 82 return sc, e 83 getstatuserror = staticmethod(getstatuserror) 51 84 52 85 class ClientContext(object): … … 154 187 message = ': '.join([str(arg) for arg in instance.args]) 155 188 except AttributeError: 156 message = instance189 message = str(instance).rstrip() 157 190 if location: location += ': ' 158 191 print >> file, "%s%s" % (location, message) … … 302 335 cmd = 'svn diff %s %s' % (path1, path2) 303 336 # cmd = 'svn diff --summarize %s %s' % (path1, path2) 304 sc, out = commands.getstatusoutput(cmd)337 sc, out = Utils.getstatusoutput(cmd) 305 338 if sc != 0: 306 339 return 2 … … 341 374 # trunk = posixpath.normpath(posixpath.join(module.url, self.trunk)) 342 375 cmd = 'svn info %s' % trunk 343 sc, out = commands.getstatusoutput(cmd)376 sc, out = Utils.getstatusoutput(cmd) 344 377 if sc != 0: 345 378 return None … … 360 393 # tags = posixpath.normpath(posixpath.join(module.url, self.tags)) 361 394 cmd = 'svn ls -v %s' % tags 362 sc, out = commands.getstatusoutput(cmd)395 sc, out = Utils.getstatusoutput(cmd) 363 396 if sc != 0: 364 397 return None … … 471 504 472 505 def execute(self, cmt_context, client_context): 473 sc = 0506 sce = 0 474 507 475 508 for m in self.modules: … … 478 511 err = [] 479 512 for url in m.URL: 480 # cmd = 'svn checkout -q %s %s 2>/dev/null' % (url, m.path) 481 cmd = 'svn checkout -q %s %s' % (url, m.path) 482 sc, e = commands.getstatusoutput(cmd) 483 #sc = os.system(cmd) 513 cmd = 'svn checkout %s %s' % (url, m.path) 514 # cmd = 'svn checkout -q %s %s' % (url, m.path) 515 sc, e = Utils.getstatuserror(cmd) 516 # cmd = 'svn checkout -q %s %s' % (url, m.path) 517 # sc, e = Utils.getstatusoutput(cmd) 484 518 if 0 == sc: 485 519 # try: … … 508 542 # print >> sys.stderr, 'Failed to checkout %s into %s.' % \ 509 543 # (' or '.join(m.URL), m.path) 510 sc += 1 511 continue 544 sce += 1 512 545 513 546 # print 'Checked out revision %i.' % result_rev … … 516 549 print >> sys.stderr, \ 517 550 '%s %s: configure returned %i.' % (m.path, m.version, scc) 518 sc += scc519 520 return sc 551 sce += scc 552 553 return sce 521 554 522 555 def main(argv=[__name__]):
Note: See TracChangeset
for help on using the changeset viewer.