erk, Bug? ( long post )

David Broadwell dbroadwell at mindspring.com
Mon Jun 26 19:28:51 EDT 2000


All of my text is at the bottom...

import os

filelist = []
subdirlist = []
filetype = 'm3u'
output = 'out.txt'

def main():
    stop = 2
    depth = 0
    path = '.'
    scan(path)
    file(path)
    print subdirlist
    if (subdirlist):
       print 'Crossing the bridge of death.'
       while (depth <= stop):
           print 'Depth now at:',
           print depth
           depth = depth + 1
           temp = []
           print 'Scan path for subdir loop',
           print subdirlist
           if (subdirlist):
              temp = subdirlist
              for dir in temp: 
                  scan(dir)
                  file(dir)
              print 'recycling while loop, wish me luck.'
       else: 
#           print 'Stopping that while loop variable readout: '
#           print 'This is where merge will be called once stable'
           print 'Filelist:',
           print filelist
#           print 'Subdirlist:',
#           print subdirlist
#           print 'Last depth:',
#           print depth
           print 'Stop set at:',
           print stop

def scan(scanpath):
    print 'Checking ( dir ):',
    print scanpath
    os.chdir(scanpath)
    dirtemp = os.listdir('.')
    for item in dirtemp:
        if (os.path.isdir(item)):
           if (scanpath == '.'): 
              subdirlist.append(item)
#              print 'Added: ' +item+ ' to subdirlist'
           else: 
              subdirlist.append(scanpath + '/' + item)
#              print 'Added: ' +(scanpath + '/' + item)+ ' to
subdirlist'
    if (not(scanpath == '.')): os.chdir('..')

def file(filepath):
    print 'Checking ( files ):',
    print filepath
    filetemp = os.listdir(filepath)
    for item in filetemp:
        for x in range(len(item)):
            if (item[x:(x+1)] == '.'):
               if (item[(x+1):] == filetype):
                  if (filepath == '.'):
                     filelist.append(item)
                     print 'Added: ' +item+ ' to filelist'
                  else: 
                     filelist.append(filepath + '/' + item)
                     print 'Added: ' +(filepath + '/' + item)+ ' to
filelist'

def merge(filelist):
    if (filelist):
       print 'Sory dave actually merging the functions is disabled'
#       outbuffer=open(output,'w')
#       for item in filelist:
#           inbuffer=open(item)
#           outbuffer.write(inbuffer.read())
#           inbuffer.close()
#       outbuffer.close()
       print 'But if you want to know, I would have:'
       print 'Merged files:',
       print filelist
       print 'With:',
       print './' + output
    else:
       print 'No ' + filetype + ' files to process, Exiting...'

print 'Good morning Dave.'
main()

ERROR:
Good morning Dave.
Checking ( dir ): .
Checking ( files ): .
['DLLs', 'Lib', 'libs', 'include', 'Tools', 'Doc', 'source']
Crossing the bridge of death (while loop that falls off the net).
Depth now at: 0 (how many directories deep am i? .. fails)
Scan path for subdir loop ['DLLs', 'Lib', 'libs', 'include', 'Tools',
'Doc', 'source']
Checking ( dir ): DLLs
Checking ( files ): DLLs
Checking ( dir ): Lib
Checking ( files ): Lib
Checking ( dir ): libs
Checking ( files ): libs
Checking ( dir ): include
Checking ( files ): include
Checking ( dir ): Tools
Checking ( files ): Tools
Checking ( dir ): Doc
Checking ( files ): Doc
Checking ( dir ): source
Checking ( files ): source
Checking ( dir ): Lib/Plat-Win
Checking ( files ): Lib/Plat-Win
Traceback (innermost last):
  File "C:\PROGRA~1\PYTHON\TOOLS\IDLE\ScriptBinding.py", line 131, in
run_module_event
    execfile(filename, mod.__dict__)
  File "C:\WINDOWS\Profiles\mongoose\Desktop\grope.py", line 112, in ?
    main()
  File "C:\WINDOWS\Profiles\mongoose\Desktop\grope.py", line 29, in main
    file(dir)
  File "C:\WINDOWS\Profiles\mongoose\Desktop\grope.py", line 63, in file
    filetemp = os.listdir(filepath)
OSError: [Errno 3] No such process

Is there a reason that that wrror message fills me with dread? Why is
the interpreter punishing me? What did i do wrong?

It always dies on the first use of the files that calls a directoy that
has a subpath. I tested that ability alone in the interpreter and it
worked perfectly well. I am on python 1.5.2 on a windows 98 box. I did
see aome comments on DejaNews about it, and it was also involving
os.listdir.. But there was only one instance, and i do not see precisely
how they relate...

-- 
        ~We're all fallen angels who've forgotten how to fly~
        Remember how: http://www.cyber-action.com/oed/dbroadwell.html
--



More information about the Python-list mailing list