Module for generic platform information: platform.py

Betancourt, Josef Josef.Betancourt at GTECH.COM
Wed Oct 27 12:51:13 EDT 1999


I use the following code.  Its kludgy and I'm a Python newbie, but so far it
works, so.....

def comCmd(log, comlist) :
    global onNT

    if log == None :
        log.prtError("comCmd(log, comlist) passed incorrect logger")
        sendError( "comCmd(log, comlist) passed incorrect logger")
        sys.exit(1)
        
    curcom = comlist[0]
    cmdl = ""
    
    for arg in comlist[1:] :
        cmdl = cmdl + " " + arg
      
    log.prtl(9, "**** call shell with [%s] " % cmdl)
    
    resultlines = []
    
    on98 = 0   # should never run on 98.
     
    if on98 :
        program = os.popen(cmdl, 'r')
    elif onNT :
        program = os.popen('( ' + cmdl + ' ) 2>&1', 'r')
    else:
        program = os.popen('{ ' + cmdl + '; } 2>&1', 'r')
    
    log.prtl(1, " result of call...")
                                                                    
    while 1:                                                        
        line = program.readline()                                   
        if not line:                                                
            break                                                   
        resultlines.append(line)                          
        log.prtl(1, line)
    #end while

    status = program.close()         
                                      
    if status:                                                      
        status = status >> 8                                        
        log.prtWarning('Command exited with abnormal status: %s'% status )

    
    resultlines[0:] = []   # deletes cells
    
    log.prtl(3, " !!!  %s command completed" % curcom)
#end def comCmd


> -----Original Message-----
> From: M.-A. Lemburg [mailto:mal at lemburg.com]
> Sent: Wednesday, October 27, 1999 11:34 AM
> To: Thomas Heller
> Cc: python-list
> Subject: Re: Module for generic platform information: platform.py
> 
> 
> Thomas Heller wrote:
> > 
> > I searched the MSDN again,
> > it seems that winmsd.exe is included in NT 3.5, 3.51, 4.0
> > and installed by default.
> 
> Sound even better ;-) (It doesn't seem to exist on Win95, so I'll
> only use it for WinNT.)
> 
> What command string would I have to pass to os.popen to get the output
> (I only need the first few lines) without any windows popping up ?
> 
> Thanks,
> -- 
> Marc-Andre Lemburg
> ______________________________________________________________________
> Y2000:                                                    65 days left
> Business:                                      http://www.lemburg.com/
> Python Pages:                           http://www.lemburg.com/python/
> 
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 





More information about the Python-list mailing list