Changeset 478 for tbroadcast


Ignore:
Timestamp:
Nov 28, 2008, 12:42:04 PM (15 years ago)
Author:
rybkin
Message:

See C.L. 2

Location:
tbroadcast/HEAD
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tbroadcast/HEAD/Changelog

    r398 r478  
     12008-11-28    <rybkin@lal.in2p3.fr> 2
     2       
     3        * python/executer.py: Introduce function getstatusoutput returning
     4        (status, stdout) of executing cmd
     5        * python/tbroadcast.py: Use the introduced getstatusoutput instead of
     6        the function of the same name from the standard module commands so as
     7        not to mix stdout and stderr when parsing commands output
     8
    192007-03-22 Vincent Garonne <garonne@lal.in2p3.fr> 1
    210
  • tbroadcast/HEAD/python/executer.py

    r244 r478  
    209209          return 1, retVal['stdout'], retVal['stderr'], 1
    210210   
     211############################################################################     
     212def getstatusoutput(cmd):
     213    """Return (status, stdout) of executing cmd in a shell.
     214   
     215    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.
     216    """
     217    import os
     218    p = os.popen(cmd, 'r')
     219    out = p.read()
     220    sts = p.close()
     221    if sts is None: sts = 0
     222    if out.endswith(os.linesep):
     223        out = out[:out.rindex(os.linesep)]
     224    return sts, out
     225
    211226#################################################################################
    212227###################################### EoF ######################################
  • tbroadcast/HEAD/python/tbroadcast.py

    r393 r478  
    2424from threadpool import  makeRequests
    2525from executer   import  exeCommand
     26from executer   import  getstatusoutput
    2627
    2728class Scheduler:
     
    7172    def get_current_project(self):
    7273        cmd = 'cmt show projects | grep current'
    73         status, output = commands.getstatusoutput (cmd)
     74        status, output = getstatusoutput (cmd)
     75#        status, output = commands.getstatusoutput (cmd)
    7476        if status != 0:
    7577            print output
     
    98100        cmd = 'cmt -private show cycles'
    99101        cycle_found = False
    100         status, output = commands.getstatusoutput (cmd)
     102        status, output = getstatusoutput (cmd)
     103#        status, output = commands.getstatusoutput (cmd)
    101104        if status != 0:
    102105            print output
     
    249252        else:   
    250253            cmd = 'cat ' + file       
    251         status, output = commands.getstatusoutput (cmd)
     254        status, output = getstatusoutput (cmd)
     255#        status, output = commands.getstatusoutput (cmd)
    252256        if status != 0:
    253257            print output
     
    309313    def get_current_package(self):   
    310314        cmd = 'cmt show macro package'
    311         status, output = commands.getstatusoutput (cmd)
     315        status, output = getstatusoutput (cmd)
     316#        status, output = commands.getstatusoutput (cmd)
    312317        if status != 0:
    313318            print output
     
    326331        #return os.getcwd ()
    327332        cmd = 'cmt -use='+name+' run pwd'
    328         status, output = commands.getstatusoutput (cmd)
     333        status, output = getstatusoutput (cmd)
     334#        status, output = commands.getstatusoutput (cmd)
    329335        if status != 0:
    330336            print output
Note: See TracChangeset for help on using the changeset viewer.