kjnh10 / saseg_runner

Run egp file from python
MIT License
10 stars 2 forks source link

Access is denied message for egp files on mapped network drive #20

Closed raistlin-akira closed 3 years ago

raistlin-akira commented 3 years ago
>>> from pathlib import Path
>>> Path('X:\Project.egp')
WindowsPath('X:/Project.egp')
>>> Path('X:\Project.egp').resolve()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\CCK083\Anaconda3\lib\pathlib.py", line 1177, in resolve
    s = self._flavour.resolve(self, strict=strict)
  File "C:\Users\CCK083\Anaconda3\lib\pathlib.py", line 205, in resolve
    s = self._ext_to_normal(_getfinalpathname(s))
PermissionError: [WinError 5] Access is denied: 'X:\\Project.egp'

If using absolute path resolution in run_egp program, it seems to have no errors and egp files can be opened

>>> import os
>>> os.path.abspath('X:\Project.egp')
'X:\Project.egp'
>>>
kjnh10 commented 3 years ago

Thanks for reporting.

Now I'm investigating.

kjnh10 commented 3 years ago

Could you tell me below? ・python version ・minimal code to reproduce

raistlin-akira commented 3 years ago

Thanks for the reply.

Python version

Python 3.8.3 (default, Jul  2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

To reproduce on Windows:

  1. Map a network drive X
  2. Create a sample egp (Project.egp) at X with statement '%put Helloworld!'
  3. Run the following code
    from saseg_runner import run_egp
    run_egp(egp_path='X:/Project.egp', profile_name=`{your profile name}`, eg_version='{your eg version}')
kjnh10 commented 3 years ago

X drive is a remote server or a link to a local path which is created by subst command? if it's latter, a workaround is to use the raw local path.

raistlin-akira commented 3 years ago

No. It is from remote server.

My workaround is to copy the egp file from the network to local XD

I think the error is due to that resolving UNC path will require full control to the folder, which causes 'the access denied' error.

Still, I will suggest using os.path.abspath() to get the complete path for egp file in run_egp(). This will save the need to copy file from network drive to local haha

kjnh10 commented 3 years ago

I see.Then, is it possible for you to create the pull request?

This module has many points where Path object is used, so I'm not sure that changing Path.resolve() to os.path.abspath() is enough for your case.

you can make your local development environment like below.

pip uninstall saseg_runner  # to uninstall the current version
cd <anywhere>
git clone https://github.com/kjnh10/saseg_runner # it's better to fork this project and clone it for making a pull request later.
cd saseg_runner
pip install --editable ./
# you can edit the 'run' function in runner.py

If it's not, I will try to modify this issue by myself.

kjnh10 commented 3 years ago

v0.1.13 has been released.