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

Running web server on windows does not work due to File issues #570

Closed
villamvadasz opened this issue Jul 7, 2023 · 1 comment
Closed
Labels

Comments

@villamvadasz
Copy link

Describe the bug
I have managed to get the server up and running. I had to modify the code, because on Windows it looks like, that a file created by python is not released as long as python is running. To overcome this, I had to remove some file deletion from the code, and the part that converts files.

To Reproduce
Clone the repository.
Install python-3.11.4-amd64.exe
pip install shapely
pip install markdown
pip install setuptools
pip install Sphinx
pip install Affine
pip install qrcode
Download and install:
gs918w32.exe
pstoeditsetup_x64.exe
inkscape-1.2.2_2022-12-09_732a01da63-x64.msi
gettext-0.14.4-bin.zip
libexpat.zip
libiconv2.zip

Build stuff with
@echo off
cls
set OLD_PATH=%PATH%
set PATH="c:\Progra1\Python311"
set PATH=%PATH%;e:_CNC\boxes_py\gettext-0.14.4-bin\bin
set PATH=%PATH%;C:\Users\kyrk\AppData\Roaming\Python\Python311\Scripts
set PATH=%PATH%;e:_CNC\boxes_py\pstoedit
set PATH=%PATH%;"c:\Progra
1\Inkscape\bin"
set PATH=%PATH%;"c:\Progra~1\Inkscape"

python setup.py build

set PATH=%OLD_PATH%

Then run webserver with:
@echo off
cls
set OLD_PATH=%PATH%
set PATH="c:\Progra1\Python311"
set PATH=%PATH%;e:_CNC\boxes_py\gettext-0.14.4-bin\bin
set PATH=%PATH%;C:\Users\kyrk\AppData\Roaming\Python\Python311\Scripts
set PATH=%PATH%;e:_CNC\boxes_py\pstoedit
set PATH=%PATH%;"c:\Progra
1\Inkscape\bin"
set PATH=%PATH%;"c:\Progra~1\Inkscape"
set PATH=%PATH%;e:_CNC\boxes_py\gs\gs9.18\bin

python scripts\boxesserver

set PATH=%OLD_PATH%

Then generate something with output set to DXF.
Error message:
BoxesServer serving on :8000...
<boxes.formats.Formats object at 0x000001B7FEF02AD0>
pstoedit: version 3.71 / DLL interface 108 (built: Apr 1 2018 - release build - MS VC++ 1912 - 64-bit) : Copyright (C) 1993 - 2018 Wolfgang Glunz
running-win command line: gswin32c -q -dDELAYBIND -dWRITESYSTEMDICT -dNODISPLAY -dNOEPS C:/Users/kyrk/AppData/Local/Temp/psin3
C:\Users\kyrk\AppData\Local\Temp\tmpb_ak3ks4
C:\Users\kyrk\AppData\Local\Temp\tmponzw_7jw
Exception during rendering:
Traceback (most recent call last):
File "e:_CNC\boxes_py\boxes\scripts\boxesserver", line 644, in serve
box.close()
File "e:_CNC\boxes_py\boxes\scripts..\boxes_init_.py", line 754, in close
filename_out = self.formats.convert(self.output, self.format, self.metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "e:_CNC\boxes_py\boxes\scripts..\boxes\formats.py", line 105, in convert
os.rename(tmpfile, filename)
PermissionError: [WinError 32] Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird: 'C:\Users\kyrk\AppData\Local\Temp\tmpb_ak3ks4' -> 'C:\Users\kyrk\AppData\Local\Temp\tmponzw_7jw'
127.0.0.1 - - [07/Jul/2023 21:07:34] "GET /ABox?FingerJoint_angle=90.0&FingerJoint_style=rectangular&FingerJoint_surroundingspaces=2.0&FingerJoint_bottom_lip=0.0&FingerJoint_edge_width=1.0&FingerJoint_extra_length=0.0&FingerJoint_finger=2.0&FingerJoint_play=0.0&FingerJoint_space=2.0&FingerJoint_width=1.0&Lid_handle=none&Lid_style=none&Lid_handle_height=8.0&Lid_height=4.0&Lid_play=0.1&x=100.0&y=100.0&h=100.0&outside=0&outside=1&bottom_edge=h&thickness=3.0&format=dxf&tabs=0.0&qr_code=0&debug=0&labels=0&labels=1&reference=100&inner_corners=loop&burn=0.1&language=de&render=1 HTTP/1.1" 500 794

Expected behavior
On windows somehow the python file creation is locked. The expectation is, that the code does handle this in some way. Not sure how. But it should not crash.

Screenshots or Drawings
N/A

Additional context
Changed the code localy in order to get the stuff up an running:
self.surface.flush()
self.surface.finish(self.inner_corners)
#convert now gives the result file name back, and we use that later one
filename_out = self.formats.convert(self.output, self.format, self.metadata)
self.output = filename_out
if self.inkscapefile:
try:

and here to:
except:
pass
raise ValueError("Conversion failed. pstoedit returned %i" % err)
#causes problem on windows so removed, will generate a lot of tmp files
#os.rename(tmpfile, filename)
return tmpfile
and here too:
start_response(status, http_headers)
result = open(box.output, 'rb').readlines()
os.close(fd)
#causes problem on windows so removed, will generate a lot of tmp files
#os.remove(box.output)
return (l for l in result)

@florianfesti
Copy link
Owner

This should be solved by e1c2259 and a49ac20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants