Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issue #277 #288

Merged
merged 1 commit into from
Feb 27, 2022
Merged
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
3 changes: 3 additions & 0 deletions src/harvesters/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
# Local application/library specific imports
from harvesters._private.core.port import ConcretePort
from harvesters._private.core.statistics import Statistics
from harvesters._private.core.helper.system import is_running_on_windows
from harvesters.util.logging import get_logger
from harvesters.util.pfnc import dict_by_names, dict_by_ints
from harvesters.util.pfnc import Dictionary, _PixelFormat
Expand Down Expand Up @@ -1889,6 +1890,8 @@ def _retrieve_file_path(

elif location == 'file':
file_path_to_load = urlparse(url).path
if is_running_on_windows():
file_path_to_load = re.sub(r'^/+', '', file_path_to_load)

elif location == 'http' or location == 'https':
raise NotImplementedError(
Expand Down
11 changes: 11 additions & 0 deletions src/harvesters/test/test_harvester_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import numpy as np

# Local application/library specific imports
from harvesters._private.core.helper.system import is_running_on_windows
from harvesters.test.base_harvester import TestHarvester, \
TestHarvesterNoCleanUp
from harvesters.test.base_harvester import get_cti_file_path
Expand Down Expand Up @@ -1045,6 +1046,16 @@ def test_issue_207(self):
)
self.assertEqual(data, result)

def test_issue_277(self):
if not is_running_on_windows():
return

prefix = 'file:///'
path = 'C:/ProgramData/GenICam/xml/cache/Optronis_Cyclone_V1_7_8.xml'
url = prefix + path
result = ImageAcquirer._retrieve_file_path(url=url)
self.assertEqual(path, result)


if __name__ == '__main__':
unittest.main()