Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # b_deleteDir.py
- f = r'E:\filename'
- import sys
- import os
- mswindows = (sys.platform == "win32")
- def getstatusoutput(cmd):
- """Return (status, output) of executing cmd in a shell."""
- if not mswindows:
- return commands.getstatusoutput(cmd)
- pipe = os.popen(cmd + ' 2>&1', 'r')
- text = pipe.read()
- sts = pipe.close()
- if sts is None: sts = 0
- if text[-1:] == '\n': text = text[:-1]
- return sts, text
- def deleteDir(path):
- """deletes the path entirely"""
- if mswindows:
- cmd = "RMDIR "+ path +" /s /q"
- else:
- cmd = "rm -rf "+path
- result = getstatusoutput(cmd)
- print result[1]
- print result[0]
- if(result[0]!=0):
- raise RuntimeError(result[1])
- 0
- deleteDir(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement