-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdelete-after-completion.python
26 lines (25 loc) · 1.32 KB
/
delete-after-completion.python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# We will delete Results and Data Directory
#Checking to see if the path exists
if os.path.exists('/home/rstudio/Results') and os.path.exists('home/rstudio/Data'):
#Checking to see if the dir is not empty
if any(os.scandir('/home/rstudio/Results')):
logging.info(" Not Empty, ready for deletion ")
try:
shutil.rmtree('/home/rstudio/Results')
logging.info(" Results Directory (/home/rstudio/Results) have been successfully deleted! ")
except:
logging.info(" Error while deleting Results (/home/rstudio/Results) directory ")
else:
logging.info(" Directory is empty! ")
#Checking to see if the dir is not empty
if any(os.scandir('/home/rstudio/Data')):
logging.info(" Not Empty, ready for deletion ")
try:
shutil.rmtree('home/rstudio/Data')
logging.info("Data Directory (/home/rstudio/Data) have been successfully deleted! ")
except:
logging.info(" Error while deleting Data (/home/rstudio/Data) directory ")
else:
logging.info(" Directory is empty! ")
else:
logging.info(" Path /home/rstudio/Results and home/rstudio/Data doesn't exist! ")