Python os.popen in Linux

Sami Viitanen sami.viitanen at pp6.inet.fi
Mon Sep 29 12:10:06 EDT 2003


Hello,

I was using os.popen function to get CVS command output to string from
script..

Same commands worked well with Windows, but Linux seems to have problem with
those. Whole CVS commands seem to froze or given commands aren't executed
right
at all. I had to replace os.popen commands with os.system. os.system
commands just
print additional information to screen that is not necessary at all.

Any ideas what may cause this ?

Example of "os.popens" that were not executed correctly:

# Freezes files one at the time
def sfnFreezeFiles(sModFiles,sTagOld):
    lModFiles = string.split(sModFiles)                 # Makes list out of
string
    x = 0
    while x < len(lModFiles):                                       # While
files in list
        iFilePoint = string.rfind(lModFiles[x],'/',1)               # Seeks
last '/' -char from string
        sModFile = lModFiles[x]
        sDir = sModFile[:iFilePoint]                                #
Directory = from start to last '/'
        sModFile = sModFile[iFilePoint+1:]                          # File =
from last '/' to end of string
        ColorPrint.fnPrintExecute('Freezing: %s %s' % (sDir,sModFile))
        sCurrentDir = os.getcwd()                                   # Get
current working directory
        os.chdir(sDir)                                              # Change
directory
        os.popen('cvs update -A %s' % sModFile)                     # Remove
sticky-tag from file   <----- OS.POPEN
        os.popen('cvs ci '+sModFile)                                #
Checkin file                                    <----- OS.POPEN
        os.chdir(sCurrentDir)                                       # Change
directory back
        x = x+1
    return len(lModFiles)


Thanks in advance. --SV






More information about the Python-list mailing list