Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"asar": false,
"target": "nsis",
"icon": "src/electron/frontend/assets/app-icon/logo-guide-draft.ico",
"requestedExecutionLevel": "requireAdministrator"
"requestedExecutionLevel": "asInvoker"
},
"mac": {
"asar": true,
Expand Down
36 changes: 34 additions & 2 deletions src/pyflask/manageNeuroconv/manage_neuroconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import math
import os
import re
import sys
import traceback
import zoneinfo
from datetime import datetime, timedelta
Expand All @@ -28,6 +29,37 @@

progress_handler = TQDMProgressHandler()


def create_link(target, link, target_is_dir=False):
"""Create a filesystem link, using junctions/hard links on Windows when symlinks aren't available."""
target = str(target)
link = str(link)

if sys.platform != "win32":
os.symlink(target, link, target_is_dir=target_is_dir)
return

try:
os.symlink(target, link, target_is_dir=target_is_dir)
return
except OSError:
pass

if target_is_dir:
import _winapi

_winapi.CreateJunction(target, link)
else:
try:
os.link(target, link)
except OSError:
raise OSError(
f"Cannot create a link from '{link}' to '{target}'. "
"On Windows, either run NWB GUIDE as Administrator, "
"or ensure the source and destination are on the same drive."
)


EXCLUDED_RECORDING_INTERFACE_PROPERTIES = ["contact_vector", "contact_shapes", "group", "location"]

EXTRA_INTERFACE_PROPERTIES = {
Expand Down Expand Up @@ -1341,7 +1373,7 @@ def convert_to_nwb(

# Create a pointer to the actual conversion outputs
if not default_output_directory.exists():
os.symlink(resolved_output_directory, default_output_directory)
create_link(resolved_output_directory, default_output_directory, target_is_dir=True)

return dict(file=str(output_path))

Expand Down Expand Up @@ -1675,7 +1707,7 @@ def _aggregate_symlinks_in_new_directory(paths, reason="", folder_path=None) ->
list(map(lambda name: os.path.join(path, name), os.listdir(path))), None, new_path
)
else:
new_path.symlink_to(path, path.is_dir())
create_link(path, new_path, target_is_dir=path.is_dir())

return folder_path

Expand Down