Skip to content

Commit

Permalink
Feb 2019 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
PauAndrio committed Feb 4, 2019
1 parent 265b1dc commit 5a72e83
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions biobb_common/tools/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
import os
import re
import time
import pathlib
import shutil
import zipfile
Expand Down Expand Up @@ -287,11 +288,22 @@ def write_failed_output(file_name):

def rm(file_name):
file_path = pathlib.Path(file_name)
if file_path.exists():
if file_path.is_dir():
shutil.rmtree(file_name)
return file_name
if file_path.is_file():
os.remove(file_name)
return file_name
try:
if file_path.exists():
if file_path.is_dir():
shutil.rmtree(file_name)
return file_name
if file_path.is_file():
os.remove(file_name)
return file_name
except:
# Giving the file system some time to consolidate
time.sleep(2)
if file_path.exists():
if file_path.is_dir():
shutil.rmtree(file_name)
return file_name
if file_path.is_file():
os.remove(file_name)
return file_name
return None

0 comments on commit 5a72e83

Please sign in to comment.