Spaces:
Sleeping
Sleeping
modified chmod to handle exceptions
Browse files- Background_Substraction.py +10 -3
Background_Substraction.py
CHANGED
|
@@ -57,13 +57,20 @@ present_dir = os.path.dirname(os.path.realpath(__file__))
|
|
| 57 |
input_path = os.path.join(present_dir, 'wetransfer_data-zip_2024-05-17_1431')
|
| 58 |
base_dir = input_path
|
| 59 |
|
| 60 |
-
# Function to change permissions recursively
|
| 61 |
def change_permissions_recursive(path, mode):
|
| 62 |
for root, dirs, files in os.walk(path):
|
| 63 |
for dir in dirs:
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
| 65 |
for file in files:
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
change_permissions_recursive(base_dir, 0o777)
|
| 69 |
|
|
|
|
| 57 |
input_path = os.path.join(present_dir, 'wetransfer_data-zip_2024-05-17_1431')
|
| 58 |
base_dir = input_path
|
| 59 |
|
| 60 |
+
# Function to change permissions recursively with error handling
|
| 61 |
def change_permissions_recursive(path, mode):
|
| 62 |
for root, dirs, files in os.walk(path):
|
| 63 |
for dir in dirs:
|
| 64 |
+
try:
|
| 65 |
+
os.chmod(os.path.join(root, dir), mode)
|
| 66 |
+
except Exception as e:
|
| 67 |
+
print(f"An error occurred while changing permissions for directory {os.path.join(root, dir)}: {e}")
|
| 68 |
for file in files:
|
| 69 |
+
try:
|
| 70 |
+
os.chmod(os.path.join(root, file), mode)
|
| 71 |
+
except Exception as e:
|
| 72 |
+
print(f"An error occurred while changing permissions for file {os.path.join(root, file)}: {e}")
|
| 73 |
+
|
| 74 |
|
| 75 |
change_permissions_recursive(base_dir, 0o777)
|
| 76 |
|