43 | | items = os.listdir(tmpdir) |
44 | | for f in items: |
45 | | if f == '.' or f == '..': continue |
46 | | file = tmpdir + os.sep + f |
47 | | print "Deleting " + file |
48 | | os.remove(file) |
49 | | os.rmdir(tmpdir) |
| 41 | # Delete a directory, recursively |
| 42 | def delete_dir(dir): |
| 43 | items = os.listdir(dir) |
| 44 | for item in items: |
| 45 | if item == '.' or item == '..': continue |
| 46 | file = dir + os.sep + item |
| 47 | if os.path.isdir(file): |
| 48 | # if this file is actually a dir, delete the dir |
| 49 | delete_dir(file) |
| 50 | else: # it's just a file |
| 51 | print "Deleting " + file |
| 52 | os.remove(file) |
| 53 | os.rmdir(dir) |