django-raster icon indicating copy to clipboard operation
django-raster copied to clipboard

PermissionError at /admin/raster/rasterlayer/add/

Open maulanarachmat opened this issue 5 years ago • 7 comments

I'm trying to add raster into Raster layers using admin page, but everytime i tried it always give [WinError 32], I already tried to change permission on admin page and remove the file on temp data but still got the error.

I'm using Windows 10, PostgreSQL 11.4, PostGIS 2.5.3 and Python 3 using virtual env from conda. My data only have 1 band (grayscale)

Here's the traceback error:

Environment:

Request Method: POST Request URL: http://127.0.0.1:8000/admin/raster/rasterlayer/add/

Django Version: 2.2.6 Python Version: 3.7.3 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.gis', 'raster', 'ras.apps.RasConfig'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\raster\tasks.py" in create_tiles 40. parser.reproject_rasterfile()

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\raster\tiles\parser.py" in reproject_rasterfile 206. dest_zip = zipfile.ZipFile(dest.name, 'w', allowZip64=True)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\zipfile.py" in init 1204. self.fp = io.open(file, filemode)

During handling of the above exception ([Errno 13] Permission denied: 'C:\Users\DELL\AppData\Local\Temp\tmpaadzqk14\tmpmp_6awy2.zip'), another exception occurred:

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\core\handlers\base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\core\handlers\base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\contrib\admin\options.py" in wrapper 606. return self.admin_site.admin_view(view)(*args, **kwargs)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\utils\decorators.py" in _wrapped_view 142. response = view_func(request, *args, **kwargs)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\contrib\admin\sites.py" in inner 223. return view(request, *args, **kwargs)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\contrib\admin\options.py" in add_view 1634. return self.changeform_view(request, None, form_url, extra_context)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\utils\decorators.py" in _wrapper 45. return bound_method(*args, **kwargs)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\utils\decorators.py" in _wrapped_view 142. response = view_func(request, *args, **kwargs)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\contrib\admin\options.py" in changeform_view 1522. return self._changeform_view(request, object_id, form_url, extra_context)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\contrib\admin\options.py" in _changeform_view 1561. self.save_model(request, new_object, form, not add)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\contrib\admin\options.py" in save_model 1088. obj.save()

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\db\models\base.py" in save 741. force_update=force_update, update_fields=update_fields)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\db\models\base.py" in save_base 790. update_fields=update_fields, raw=raw, using=using,

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\dispatch\dispatcher.py" in send 175. for receiver in self._live_receivers(sender)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\django\dispatch\dispatcher.py" in 175. for receiver in self._live_receivers(sender)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\raster\models.py" in parse_raster_layer_if_status_is_unparsed 243. parse(instance.id)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\raster\tasks.py" in parse 131. all_in_one(rasterlayer_id, zoom_range)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\celery\local.py" in call 191. return self._get_current_object()(*a, **kw)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\celery\app\task.py" in call 392. return self.run(*args, **kwargs)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\raster\tasks.py" in all_in_one 77. create_tiles(rasterlayer_id, zoom_range, True)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\celery\local.py" in call 191. return self._get_current_object()(*a, **kw)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\celery\app\task.py" in call 392. return self.run(*args, **kwargs)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\site-packages\raster\tasks.py" in create_tiles 50. shutil.rmtree(parser.tmpdir)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\shutil.py" in rmtree 513. return _rmtree_unsafe(path, onerror)

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\shutil.py" in _rmtree_unsafe 397. onerror(os.unlink, fullname, sys.exc_info())

File "C:\Users\DELL\Anaconda3\envs\earth-analytics-python\lib\shutil.py" in _rmtree_unsafe 395. os.unlink(fullname)

Exception Type: PermissionError at /admin/raster/rasterlayer/add/ Exception Value: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\DELL\AppData\Local\Temp\tmpaadzqk14\test.tif_copy.GTiff'

maulanarachmat avatar Jan 02 '20 07:01 maulanarachmat

Any solutions?

Yottox avatar Feb 24 '20 21:02 Yottox

I don't have access to a Windows computer so I can't really debug this. It looks like the "closing" of a file from one function might not be registered properly and so the final removing of the intermediate files fails. Maybe when Celery tries to access it after the admin form uploaded it to the web server?

yellowcap avatar Mar 01 '20 16:03 yellowcap

Could you try to run django-raster without celery (RASTER_USE_CELERY=False) https://django-raster.readthedocs.io/en/stable/settings.html#asynchronous-raster-parsing and see if it works that way just to see if its a celery related problem?

yellowcap avatar Mar 01 '20 16:03 yellowcap

Still same problem occurs any solution found ? image

kshitijrajsharma avatar Apr 01 '20 07:04 kshitijrajsharma

Hi, Any ideas how to solve this problem on windows. I am also stuck in the same problem. Help me how to to debug this issue.

dksivagis avatar Jul 31 '20 07:07 dksivagis

Hi, Any ideas how to solve this problem on windows. I am also stuck in the same problem. Help me how to to debug this issue.

I shifted to ubuntu yet couldn't solve the issue

kshitijrajsharma avatar Jul 31 '20 10:07 kshitijrajsharma

Hi, I am also stuck with the same problem. Is anybody found the solution? image

seema30fresher avatar Oct 20 '21 06:10 seema30fresher