Skip to content

Commit

Permalink
fix: handle permission errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Aug 31, 2024
1 parent 72b69b1 commit 66a0d68
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions vr_address_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,10 @@ async def search_for_ids(
if matches:
for match in matches:
if any(match):
if int(match.get("sse", 0)) < 1 and int(match.get("id", 0)) < 1:
if (
int(match.get("sse", 0)) < 1
and int(match.get("id", 0)) < 1
):
# ids must be >= 0
continue
if match.get("sse") and match.get("ae"):
Expand Down Expand Up @@ -544,8 +547,8 @@ async def search_for_ids(
async def find_known_names(defined_rel_ids, defined_vr_offsets, dirpath, filename):
global id_name
global ae_name
async with aiofiles.open(f"{dirpath}/{filename}", "r+") as f:
try:
try:
async with aiofiles.open(f"{dirpath}/{filename}", "r+") as f:
data = mmap.mmap(f.fileno(), 0).read().decode("utf-8")
for type_key, regex in FUNCTION_REGEX_PARSE_DICT.items():
search = re.finditer(regex, await preProcessData(data), re.I)
Expand Down Expand Up @@ -590,8 +593,8 @@ async def find_known_names(defined_rel_ids, defined_vr_offsets, dirpath, filenam
ae_name[aeid] = name_string
if debug:
print(f"Found AE_ID {aeid}: {ae_name[aeid]}")
except (UnicodeDecodeError, ValueError) as ex:
print(f"Unable to read {dirpath}/{filename}: ", ex)
except (UnicodeDecodeError, ValueError, PermissionError) as ex:
print(f"Unable to read {dirpath}/{filename}: ", ex)


async def parse_offsets(defined_rel_ids, defined_vr_offsets, dirpath, filename):
Expand Down

0 comments on commit 66a0d68

Please sign in to comment.
  翻译: