Skip to content

Commit f7be403

Browse files
catch file read permission denied error
1 parent d928970 commit f7be403

File tree

5 files changed

+221
-264
lines changed

5 files changed

+221
-264
lines changed

example.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
from manim import *
22

3-
from manim_editor import (
4-
EditorBanner,
5-
IconCompleteLoop,
6-
IconLoop,
7-
IconNormal,
8-
IconSkip,
9-
PresentationSectionType,
10-
)
3+
from manim_editor import EditorBanner, IconCompleteLoop, IconLoop, IconNormal, IconSkip, PresentationSectionType
114

125

136
class IconTest(Scene):

manim_editor/app/main/routes.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,9 @@
22
import os
33
from pathlib import Path
44

5-
from flask import (
6-
abort,
7-
current_app,
8-
flash,
9-
jsonify,
10-
redirect,
11-
render_template,
12-
request,
13-
send_file,
14-
url_for,
15-
)
16-
17-
from ...editor import (
18-
create_project_dir,
19-
export_presentation,
20-
get_project,
21-
get_projects,
22-
get_scenes,
23-
populate_project,
24-
)
5+
from flask import abort, current_app, flash, jsonify, redirect, render_template, request, send_file, url_for
6+
7+
from ...editor import create_project_dir, export_presentation, get_project, get_projects, get_scenes, populate_project
258
from . import bp
269

2710

manim_editor/editor/commands.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ def walk(top: Path, maxdepth: int) -> Generator[Tuple[Path, List[str], List[str]
3232
"""Reimplementation of os.walk with max recursion depth."""
3333
dirs: List[str] = []
3434
nondirs: List[str] = []
35-
for name in os.listdir(top):
36-
if os.path.isdir(top / name):
37-
dirs.append(name)
38-
else:
39-
nondirs.append(name)
35+
# check if dir can be read
36+
try:
37+
for name in os.listdir(top):
38+
if os.path.isdir(top / name):
39+
dirs.append(name)
40+
else:
41+
nondirs.append(name)
42+
except PermissionError:
43+
print(f"Warning: can't access dir '{top}'")
4044
yield top, dirs, nondirs
4145
if maxdepth:
4246
for name in dirs:
@@ -50,11 +54,16 @@ def valid_json_load(path: Path, schema: Any) -> Optional[Any]:
5054
"""
5155
if not os.path.isfile(path):
5256
return None
53-
with open(path, "r") as file:
54-
try:
55-
data = json.load(file)
56-
except json.decoder.JSONDecodeError:
57-
return None
57+
# check if file can be read
58+
try:
59+
with open(path, "r") as file:
60+
try:
61+
data = json.load(file)
62+
except json.decoder.JSONDecodeError:
63+
return None
64+
except PermissionError:
65+
print(f"Warning: can't access file '{path}'")
66+
return None
5867
try:
5968
jsonschema.validate(data, schema)
6069
except jsonschema.ValidationError:

0 commit comments

Comments
 (0)