-
Notifications
You must be signed in to change notification settings - Fork 92
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
local:///path is causing xml to save to C:\ and triggering permission denied errors #126
Comments
It seems like at one point saving this file was optional. 88151ca |
Looks like if the path isn't set, its supposed to create a temp directory, adding print statements to _save_file, mkdtemp seems to be returning None print("save_file")
print(file_dir) # None
if file_dir is not None:
# Create the directory if it didn't exist:
if not os.path.exists(file_dir):
os.makedirs(file_dir)
else:
file_dir = tempfile.mkdtemp(
prefix=datetime.now().strftime('%Y%m%d%H%M%S_'),
)
print(file_dir) # None
#
print(file_name) # ///criticallink_systemgentl.xml
file_path = os.path.join(file_dir, file_name)
print(file_path) # c:///criticallink_systemgentl.xml if I set HARVESTERS_XML_FILE_DIR=c:/Users/jcormier/Documents, I still get the same output path. Though it would seem our local path from the camera is confusing os.path.join. Should slashes be stripped from a "local:" path? print("save_file")
print(file_dir) # c://Users//jcormier//Documents
if file_dir is not None:
# Create the directory if it didn't exist:
if not os.path.exists(file_dir):
os.makedirs(file_dir)
else:
file_dir = tempfile.mkdtemp(
prefix=datetime.now().strftime('%Y%m%d%H%M%S_'),
)
print(file_dir) # c://Users//jcormier//Documents
#
print(file_name) # ///criticallink_systemgentl.xml
file_path = os.path.join(file_dir, file_name)
print(file_path) # c:///criticallink_systemgentl.xml |
Making the following change, allows the script to continue whether HARVESTERS_XML_FILE_DIR is set or not. file_path = os.path.join(file_dir, file_name.strip("/")) |
Though I think it really should be done under possibly related to #121 |
According to the GenICam standard 1.4, the /// after local should be a valid configuration.
|
if location == 'local':
file_name, address, size = others.split(';')
address = int(address, 16)
# Remove optional /// after local: See section 4.1.2 in GenTL v1.4 Standard
file_name = file_name.lstrip('/') |
@jcormier Thank you for the feedback. Okay, I will take a look at the detail and merge the suggested changeset into the trunk. However, does not the suggested changeset resolve the permission issue, does it? /Kazunari |
@jcormier Just to make it sure, could you tell me the location where you launch the Python script? In addition, it would be nice if you could show me the command you executed. Thanks. |
That should all be in the original post. The traceback triggered when calling create_image_acquirer(). And the permission denied was because it was trying to write directly to the C:/ drive which it shouldn't be doing. But the local:///path was getting interpreted as access file in the root directory. |
Fixes: genicam#126 According to the GenICam standard 1.4, the /// after local: should be a valid configuration. But we need to strip it out so it doesn't affect saving the file on the local machine. 4.1.2.1 Module Register Map (Recommended) A URL in the form “local:[///]filename.extension;address;length[?SchemaVersion=x.x.x]” indicates that the XML description file is located in the module’s virtual register map. The square brackets are optional.
Describe the bug
Running example code using miniconda environment. Camera returns "local:///criticallink_systemgentl.xml;0;0" and harvesters tries to save the xml to the c:/ directory. Tried changing the directory by setting "HARVESTERS_XML_FILE_DIR=c:/Users/jcormier/Documents" but had no effect to reported error
Expected behavior
Expect xml to be saved to cwd() or not saved
Screenshots
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: