I've created a web application using Django 3.2.3 and Python 3.6.8. The application runs without errors in my developer environment on Windows 10 and, on the Windows Server 2019. The problem starts when I try to integrate my app with IIS for production, I get two different errors.
The first error happens when I initially submit the form and the second after I click the browsers back button and re-submit the form again:
The first error is:
[WinError 5] Access is denied: 'C:\\windows\\system32\\config\\systemprofile\\AppData\\Local\\.certifi'
If I click the browser back button and re-submit the form, I then get this error:
Error occurred: Traceback (most recent call last):File "C:\Tools\VirtualEnvironments\podbv2\Lib\site-packages\wfastcgi.py", line 849, in mainfor part in result:File ".\PODBWeb\PODBInterfaces\pod.py", line 19, in searchSPs.get_file("Monthly Reports/", "Inventory Report.xlsx", output_location='c:/!test/')File ".\POD\PODInterfaces\sharepoint.py", line 134, in get_filer = self.retry_loop(self.session.get(rest_call))File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\sessions.py", line 555, in getreturn self.request('GET', url, **kwargs)File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\sessions.py", line 542, in requestresp = self.send(prep, **send_kwargs)File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\sessions.py", line 655, in sendr = adapter.send(request, **kwargs)File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\adapters.py", line 416, in sendself.cert_verify(conn, request.url, verify, cert)File "C:\Tools\VirtualEnvironments\pod\lib\site-packages\requests\adapters.py", line 228, in cert_verify"invalid path: {}".format(cert_loc)) OSError: Could not find a suitable TLS CA certificate bundle, invalid path: C:\windows\system32\config\systemprofile\AppData\Local\.certifi\cacert.pem StdOut: StdErr:
I could be wrong but something about the IIS configuration is preventing python from reading the Windows certificate store which is why its complaining about not being able to find a certificate bundle. My app reads the windows certificate store natively as I have the "python-certifi-win32" library installed so my app shouldn't be trying to find a certificate bundle on the file system.
Can anyone help me understand why this might be happening please and how I can fix the issue without having to deploy a certificate bundle i.e. how can I get my app working "as is". It works without IIS but of course, all the docs suggest I shouldn't really deploy my Django app into a production environment without a proper web server fronting it.
Please respect the fact that the business prefers I use IIS and Windows for support purposes.
Thank you in advance for help.
Related
It's the first time I'm trying to run scripts on the Abaqus server from my university. The IT team provided me the credentials to access the server, but they don't know how to run scripts from there. I'm using Putty to connect to the server, and Filezilla to transfer files.
I tried to run Python scripts from the work directory on the server, but this error came out:
Traceback (most recent call last):
File "SMAPylModules/SMAPylDriverPy.m/src/driverEnv.py", line 324, in envRunFile
File "/home/gd00357/abaqus_v6.env", line 208, in <module>
raise 'Cannot find the graphics configuration environment file (graphicsConfig.env)'
I couldn't find any documentation on how to run Python scripts, I hope it's possible in some way.
How could I solve that error?
EDIT:
Ok, apparently remote servers don't support any scripts that make use of the GUI.
Now my question is: how do I import a model as input file (.inp) using a Python script? Is there a way that avoids that a Python script uses the GUI?
Abaqus has some built-in tools for scripting parametric studies.
Please read about parametric studies in the Abaqus manual here.
Context:
We run Cypress tests which use instances of our application started using manage.py test package.test.suite. The test fixtures and environment are all set up using a class extended from django.contrib.staticfiles.testing.StaticLiveServerTestCase. A unit test/method is added to the extended class which invokes Cypress as a subprocess to run the tests and asserts against the exit code of the subprocess.
Versions:
Python: 3.6.8
Django: 2.2.3
macOS: Mojave 10.14.6
The problem:
This worked well until yesterday when I updated Cypress via npm. Now when I start a server using manage.py test some.test.suite the server will fail to serve all of the static resources requested by the browser. Specifically, it almost always fails to serve some .woff fonts and a random javascript/css file or two. The rest of the files are served but those 5 or 6 which the browser never receives a response for. Eventually I'll get a ConnectionResetError: [Errno 54] Connection reset by peer error (stack trace below) in the terminal. Additionally, if I enable the cache in my browser and attempt a few refreshes things will work fine, almost as if theres a limit to the number of files that can be served at once and once some files are cached in the browser the number of requested files falls below that limit.
When I do python manage.py runserver, however, I don't seem to have this problem at all with or without caching enabled.
Stack Trace:
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52655)
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.6.8/lib/python3.6/socketserver.py", line 320, in _handle_request_noblock
self.process_request(request, client_address)
File "/Users/myuser/.pyenv/versions/3.6.8/lib/python3.6/socketserver.py", line 351, in process_request
self.finish_request(request, client_address)
File "/Users/myuser/.pyenv/versions/3.6.8/lib/python3.6/socketserver.py", line 364, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Users/myuser/.pyenv/versions/3.6.8/lib/python3.6/socketserver.py", line 724, in __init__
self.handle()
File "/Users/myuser/Path/To/Project/venv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 171, in handle
self.handle_one_request()
File "/Users/myuser/Path/To/Project/venv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/Users/myuser/.pyenv/versions/3.6.8/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
----------------------------------------
Additional Notes/Observations
The problem also occurs when I run the tests headless.
Installing Cypress did run into a hitch that required me to reinstall Electron and Cypress, clear the npm cache and delete the Cypress cache folder.
It's also strange that the problem seems to be with the python environment and not Cypress itself since accessing the web server via my browser and not Cypress produces the same behaviour; so perhaps Cypress is just a red herring and some sort of shared dependency was changed/updated in the process.
If I attempt to directly access one of the files that doesn't get served during a request, which is displayed as 'pending' in Chrome Developer's tools network tab, directly via a second tab it will succeed (but sometimes be lagged by several seconds).
After closing the test server and attempting to run it again I will get an [OSError: [Errno 48] Address already in use] error for up to a minute or two. Previously the server would relinquish the address/port immediately upon closing (or I'm assuming as such since I've never seen this before and had rapidly closed and re-ran tests to test fixture changes in the past).
Things I've Tried:
Rebuilding my virtualenv from scratch
Copying my old venv folder from a Time Machine backup from a time when things worked
Reverting the version of Cypress back to what it was prior to the problem
Looking into timeouts and connection limits of using manage.py test vs manage.py runserver (Didn't find anything).
Toggling DEBUG mode and profiling on/off.
Switching between Chrome and Chromium in Cypress
Building new environments with different python versions (3.6.5, 3.6.7 and 3.6.8)
Switching Django back to 2.2.2 from 2.2.3
Any help would be appreciated!
Update
Looking into this further it looks like the requests for the files that don't get a response never make it to the WSGIHandler form the Socket layer (or even if they make it to the socket layer, I'd assume they do though).
Update 2
I see the same behaviour with manage.py runserver if I include the --nothreading switch. I had a co-worker give it a test and he indeed saw the same behaviour with manage.py runserver --nothreading but manage.py test test.to.run still functioned fine for him.
Also removing the font references from the css/templates just results in a different set of 5 files that aren't served.
When I try to create a Python file (.py) in my Django application, I get an error 500. The file is created, and the code isn't the problem. I can create a text file or any other format. It would need to be a Python file because I need it for further steps.
I am using Windows 10 and running the Django application on IIS. Windows, IIS and Django are all up-to-date.
I already tried to add permission to the folder I will edit. I tested around with some other settings but haven't figured out the problem yet. I think it should be something with permission of IIS or Django.
This is my error message:
d:\django\virtualenv0\scripts\python.exe - The FastCGI process exited unexpectedly
Most likely causes:
IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
IIS was not able to process configuration for the Web site or application.
The authenticated user does not have permission to use this DLL.
The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
Things you can try:
Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.
Check the event logs to see if any additional information was logged.
Verify the permissions for the DLL.
Install the .NET Extensibility feature if the request is mapped to a managed handler.
Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:
Module FastCgiModule
Notification ExecuteRequestHandler
Handler Python FastCGI
Error Code 0x00000000
Requested URL https://alpha.truningerag.ch:443/projects/realtest/
Physical Path D:\django\projects\realtest\
Logon Method Anonymous
Logon User Anonymous
More Information:
This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error.
View more information ยป
Microsoft Knowledge Base Articles:
294807
I was able to solve my problem. I switch from IIS to Apache which didnt had any problem with creating a .py file anymore. After that I got an empty models file. The only thing left to do was to add in the absolute path python in the os.system(command).
Now everything works fine.
you need to check some below settings:
1)you enable iis CGI feature.
2)ensure pip and setup tools are fully upgraded:
python -m pip install pip --upgrade && pip install setuptools --upgrade
3)install the virtualenv tool:
pip install virtualenv
4)Activate the virtualenv so all our commands affect this interpreter.
C:\inetpub\wwwroot\mydjangoproject\> venv\scripts\activate
5)Configured the WFast CGI in iis.
6)"d:\django\virtualenv0\" path has iis_iusrs and iusr full control permission.
7)check iis application pool identity which server Django project.
for more detail, you could refer this link.
and please share your web.config file for more detail about the issue.
I have a script that uses Neo4j for tracking user taste preferences on alcohol types. So, basically when a user sets his preferences via an API endpoint the response is buffered to Kafka and I pick it from there. I am getting the following error when trying to read/write to Neo4j via the neo4j python driver:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/ssl.py", line 787, in recv_into
return self.read(nbytes, buffer)
File "/usr/local/lib/python2.7/ssl.py", line 657, in read
v = self.\_sslobj.read(len, buffer)
socket.error: \[Errno 104\] Connection reset by peer
Exception socket.error: error(104, 'Connection reset by peer') in 'neo4j.bolt.\_io.ChunkedInputBuffer.receive' ignored
INFO:UserSettingsProcessorProduction:2018-09-25 13:01:34 Type:<class 'neo4j.exceptions.ServiceUnavailable'> Filename:user_settings_processor.py Line:258 ERROR: Failed to write to closed connection Address(host='54.225.50.91', port=24786)
Strange is that I cannot reproduce it on local but I am getting it often while it is running in
a Docker container. I read somewhere that it could be Docker configuration issue. If the container is private for an example or something like that. I deployed it via AWS / ECS(Elastic Container Service) and it is running on a EC2 instance which is Amazon Linux AMI. If you have any suggestions what may fix it I will be very thankful!
I will keep the thread updated if I find an answer also.
We decided to use GraphQL for communicating with Neo4j and this doesn't seem to be an issue any more. I couldn't find any solution or a clue why actually it is behaving like this, while working perfectly fine on my computer. The service is deployed on a docker container, using ECS.
I am working on Google Cloud IoT core and there I came across a problem in one of the samples (end-to-end example) provided in the online docs: google cloud iot exercise
There are two scripts, for Server and Device, and while running the device script I am facing this problem:
From the commandline args, it looks like you're passing in rsa_cert.pem, which is your SSL private key. As #class said, you need to wget the Google root certificate (wget https://pki.google.com/roots.pem) and then pass the path to downloaded roots.pem for the --ca_certs argument.
error image
Traceback (most recent call last):
File "cloudiot_pubsub_example_mqtt_device.py", line 249, in <module>
main()
File "cloudiot_pubsub_example_mqtt_device.py", line 213, in main
client.connect(args.mqtt_bridge_hostname, args.mqtt_bridge_port)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line
768, in connect
return self.reconnect()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line
927, in reconnect
sock.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 788, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:581)
It's possible that your firewall (e.g. the Cloud Shell Machine) is blocking Python from connecting via port 8883. Can you try calling the cloudiot_pubsub_example_mqtt_device.py script with the port set to 443, e.g.
python <your_existing_parameters> --mqtt_bridge_port=443
You may also want to try using the HTTP device sample to publish messages as it also doesn't use port 8883, which may be blocked on your network.
In my tests, I was only able to run the exercise from the Google Cloud Shell after setting my port to 443, this hopefully will resolve the issue for you.
Note If you're encountering issues with verifying the server certificate, you need to download the Google root certificate by calling:
wget https://pki.google.com/roots.pem
Update You may also want to try to set the Python version in your virtual environment to Python 2 by setting up the virtual environment as:
virtualenv env --python=python2