I am using [Python SDK][1] for VMware automation tasks e.g. power off, power on and delete VMs in vcenter server.
from com.vmware.vcenter.vm_client import Power
from samples.vsphere.vcenter.helper.vm_helper import get_vm
import requests
import urllib3
from vmware.vapi.vsphere.client import create_vsphere_client
import argparse
Inputs = fetch_inputs()
vm_name = Inputs.VM_Name
action = Inputs.action
session = requests.session()
# Disable cert verification for demo purpose.
# This is not recommended in a production environment.
session.verify = False
# Disable the secure connection warning for demo purpose.
# This is not recommended in a production environment.
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Connect to a vCenter Server using username and password
vsphere_client = create_vsphere_client(server=Inputs.server, username=Inputs.username, password=Inputs.password, session=session)
vsphere_client.vcenter.vm.Power.stop(vm) <<--- It gets stuck here.
However, it does the operation but after that it gets stuck there and never comes out. If I do CTRL+C, then I can see that it seemd to get stuck in SSL_read in OpenSSL library:
^CTraceback (most recent call last):
File "/home/qa1/python_sdk_scripts/manage_vm.py", line 97, in <module>
power_on(vsphere_client, vm_name)
File "/home/qa1/python_sdk_scripts/manage_vm.py", line 40, in power_on
return_value = vsphere_client.vcenter.vm.Power.start(vm)
File "/home/qa1/.local/lib/python3.8/site-packages/com/vmware/vcenter/vm_client.py", line 2141, in start
return self._invoke('start',
File "/home/qa1/.local/lib/python3.8/site-packages/vmware/vapi/bindings/stub.py", line 345, in _invoke
return self._api_interface.native_invoke(ctx, _method_name, kwargs)
File "/home/qa1/.local/lib/python3.8/site-packages/vmware/vapi/bindings/stub.py", line 266, in native_invoke
method_result = self.invoke(ctx, method_id, data_val)
File "/home/qa1/.local/lib/python3.8/site-packages/vmware/vapi/bindings/stub.py", line 199, in invoke
return self._api_provider.invoke(self._iface_id.get_name(),
File "/home/qa1/.local/lib/python3.8/site-packages/vmware/vapi/security/client/security_context_filter.py", line 101, in invoke
method_result = ApiProviderFilter.invoke(
File "/home/qa1/.local/lib/python3.8/site-packages/vmware/vapi/provider/filter.py", line 75, in invoke
method_result = self.next_provider.invoke(
File "/home/qa1/.local/lib/python3.8/site-packages/vmware/vapi/protocol/client/msg/json_connector.py", line 79, in invoke
response = self._do_request(VAPI_INVOKE, ctx, params)
File "/home/qa1/.local/lib/python3.8/site-packages/vmware/vapi/protocol/client/msg/json_connector.py", line 120, in _do_request
http_response = self.http_provider.do_request(
File "/home/qa1/.local/lib/python3.8/site-packages/vmware/vapi/protocol/client/rpc/requests_provider.py", line 95, in do_request
output = self._session.request(
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
response.begin()
File "/usr/lib/python3.8/http/client.py", line 316, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 277, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 313, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/home/qa1/.local/lib/python3.8/site-packages/OpenSSL/SSL.py", line 1733, in recv_into
result = _lib.SSL_read(self._ssl, buf, nbytes)
KeyboardInterrupt
How can I debug this, where is the issue?
[1]: https://github.com/vmware/vsphere-automation-sdk-python
Related
I am trying to use AWS Chalice to upload my Python application to a Lambda function. I need to use a number of dependencies that will exceed the 50MB limit for a Lambda app. I think I can overcome this limit by using Lambda layers for each dependency, provided each layer is below the 50MB limit. For my final app, the total unzipped deployment size is about 225 MB so it is below the 250 MB unzipped limit imposed for Lambda deployments. When I has issues with the full deployment, I decided to try increasing the size by adding dependencies. I have been successful in using Chalice to deploy an app using Lambda layers that has scipy and numpy as dependencies. The deployment size with scipy and numpy dependencies is 48.6 MB zipped and 157 MB unzipped. When I also add matplotlib the size is 66 MB zipped and 210 MB unzipped and causes an error as described below.
My requirements.txt file contains:
scipy>=1.7.0
numpy>=1.19.2
matplotlib>=3.5.0
My chalice config file contains:
{
"automatic_layer": true,
"stages": {
"dev": {
"api_gateway_stage": "api"
}
},
"version": "2.0",
"app_name": "demoapp"
}
My chalice app code looks like this:
from chalice import Chalice
app = Chalice(app_name='demoapp')
app.debug = True
#app.lambda_function()
def numpy_import(event, context):
import numpy
return {'numpy': numpy.__file__}
#app.lambda_function()
def scipy_import(event, context):
import scipy
return {'scipy': scipy.__file__}
#app.lambda_function()
def matplotlib_import(event, context):
import matplotlib
return {'matplotlib': matplotlib.__file__}
#app.route('/myapp', methods=['POST'])
def mufunction():
jsonbody = app.current_request.json_body
# extract data from json
data_array = jsonbody['data_array']
# do stuff. As a test case it is just returning what it was given.
result = data_array
# package output in json
output = {'result': result}
return output
The stack trace of the error I get is:
Creating shared layer deployment package.
Reusing existing shared layer deployment package.
Creating app deployment package.
Creating lambda layer: demoapp-dev-managed-layer
Traceback (most recent call last):
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\awsrequest.py", line 94, in _send_request
rval = super()._send_request(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\awsrequest.py", line 123, in _send_output
self.send(msg)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\awsrequest.py", line 218, in send
return super().send(str)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 971, in send
self.sock.sendall(data)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1204, in sendall
v = self.send(byte_view[count:])
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1173, in send
return self._sslobj.write(data)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\httpsession.py", line 455, in send
urllib_response = conn.urlopen(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 507, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\awsrequest.py", line 94, in _send_request
rval = super()._send_request(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\awsrequest.py", line 123, in _send_output
self.send(msg)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\awsrequest.py", line 218, in send
return super().send(str)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 971, in send
self.sock.sendall(data)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1204, in sendall
v = self.send(byte_view[count:])
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1173, in send
return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionAbortedError(10053, 'An established connection was aborted by the software in your host machine', None, 10053, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\chalice\cli\__init__.py", line 636, in main
return cli(obj={})
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\click\decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\chalice\cli\__init__.py", line 189, in deploy
deployed_values = d.deploy(config, chalice_stage_name=stage)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\chalice\deploy\deployer.py", line 376, in deploy
return self._deploy(config, chalice_stage_name)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\chalice\deploy\deployer.py", line 392, in _deploy
self._executor.execute(plan)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\chalice\deploy\executor.py", line 42, in execute
getattr(self, '_do_%s' % instruction.__class__.__name__.lower(),
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\chalice\deploy\executor.py", line 55, in _do_apicall
result = method(**final_kwargs)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\chalice\awsclient.py", line 334, in publish_layer
return self._client('lambda').publish_layer_version(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\client.py", line 514, in _api_call
return self._make_api_call(operation_name, kwargs)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\client.py", line 921, in _make_api_call
http, parsed_response = self._make_request(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\client.py", line 944, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 119, in make_request
return self._send_request(request_dict, operation_model)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 202, in _send_request
while self._needs_retry(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 354, in _needs_retry
responses = self._event_emitter.emit(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\hooks.py", line 412, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\hooks.py", line 256, in emit
return self._emit(event_name, kwargs)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\hooks.py", line 239, in _emit
response = handler(**kwargs)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 207, in __call__
if self._checker(**checker_kwargs):
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 284, in __call__
should_retry = self._should_retry(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 320, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 363, in __call__
checker_response = checker(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 247, in __call__
return self._check_caught_exception(
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 416, in _check_caught_exception
raise caught_exception
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 281, in _do_get_response
http_response = self._send(request)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 377, in _send
return self.http_session.send(request)
File "C:\Users\Matthew Reid\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\httpsession.py", line 494, in send
raise ConnectionClosedError(
botocore.exceptions.ConnectionClosedError: Connection was closed before we received a valid response from endpoint URL: "https://lambda.ap-southeast-2.amazonaws.com/2018-10-31/layers/demoapp-dev-managed-layer/versions".
I think this error is a connection timeout issue caused by my computer. I have tried to fix this by adjusting the DEFAULT_TIMEOUT variable in botocore from 60 to 600. I also deploy with the command “chalice deploy --connection-timeout 600”.
My internet upload speed is approximately 5 MB/s so for a 66 MB file it should manage that in about 15 seconds.
If you have any suggestions about how to deploy an app that has multiple python dependancies that exceed 50MB when zipped, then I’d love to know your solution.
For reference, I have looked at these similar questions:
How to deploy projects with larger dependencies and exceeding deployment limits on AWS Lambda function?
boto3 ConnectionClosedError python
Since a week I'm facing a weird bug on my python server.
Right now it is running on Requests version 2.23.0 without issue.
Because of vulnerability issue I'd like to bump the Requests version to the 2.26.0.
My servers runs ok until I try to run a piece of code like that:
import requests
from firebase_admin import auth
bearer_token = requests.headers['X-Bearer-Token'] # Usually there is the word `Bearer`, consider we remove it.
decoded_token = auth.verify_id_token(bearer_token, check_revoked=False)
This piece of code will raise:
RecursionError: maximum recursion depth exceeded
Full error:
Traceback (most recent call last):
File "./project/handlers/users.py", line 106, in get_user
decoded_token = auth.verify_id_token(a, check_revoked=False)
File "./project/venv/lib/python3.6/site-packages/firebase_admin/auth.py", line 220, in verify_id_token
return client.verify_id_token(id_token, check_revoked=check_revoked)
File "./project/venv/lib/python3.6/site-packages/firebase_admin/_auth_client.py", line 127, in verify_id_token
verified_claims = self._token_verifier.verify_id_token(id_token)
File "./project/venv/lib/python3.6/site-packages/firebase_admin/_token_gen.py", line 293, in verify_id_token
return self.id_token_verifier.verify(id_token, self.request)
File "./project/venv/lib/python3.6/site-packages/firebase_admin/_token_gen.py", line 396, in verify
certs_url=self.cert_url)
File "./project/venv/lib/python3.6/site-packages/google/oauth2/id_token.py", line 124, in verify_token
certs = _fetch_certs(request, certs_url)
File "./project/venv/lib/python3.6/site-packages/google/oauth2/id_token.py", line 98, in _fetch_certs
response = request(certs_url, method="GET")
File "./project/venv/lib/python3.6/site-packages/firebase_admin/_token_gen.py", line 266, in __call__
url, method=method, body=body, headers=headers, timeout=timeout, **kwargs)
File "./project/venv/lib/python3.6/site-packages/google/auth/transport/requests.py", line 184, in __call__
method, url, data=body, headers=headers, timeout=timeout, **kwargs
File "./project/venv/lib/python3.6/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "./project/venv/lib/python3.6/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "./project/venv/lib/python3.6/site-packages/cachecontrol/adapter.py", line 57, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "./project/venv/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "./project/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "./project/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "./project/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "./project/venv/lib/python3.6/site-packages/urllib3/connection.py", line 332, in connect
cert_reqs=resolve_cert_reqs(self.cert_reqs),
File "./project/venv/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 281, in create_urllib3_context
context.options |= options
File "/usr/local/lib/python3.6/ssl.py", line 465, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/local/lib/python3.6/ssl.py", line 465, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/local/lib/python3.6/ssl.py", line 465, in options
super(SSLContext, SSLContext).options.__set__(self, value)
[Previous line repeated 963 more times]
File "/usr/local/lib/python3.6/ssl.py", line 463, in options
#options.setter
RecursionError: maximum recursion depth exceeded
Librairies:
requests = ^2.24.0
firebase-admin = ^5.0.0
I solved it by removing the Eventlet Monkey patch.
eventlet.monkey_patch()
I am getting the below error in GCP while executing Cloud Functions i.e. Cloud PubSub with Python 3.8, also below is the packages included in the requirements.txt
I have also tried only with jwt installed, but got the same error. tried only with pyjwt, again got the same error. Tried with both, again same error.
Requirements.txt:
atlassian-python-api==3.13.0
google==3.0.0
google-api-python-client==2.18.0
google-auth==2.0.1
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.4.5
oauth2client==4.1.3
oauthlib==3.1.1
sendgrid==6.8.1
gspread==4.0.1
pandas==1.3.2
jwt==1.2.0
PyJWT==2.1.0
cryptography==3.4.8
rsa==4.7.2
Traceback:
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/functions_framework/__init__.py", line 152, in view_func
function(data, context)
File "/workspace/main.py", line 72, in get_data_from_jira
data = jira_instance.jql("project = PROJECTNAME AND issuetype = 'ISSUETYPE' AND status = 'In Progress'")
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/atlassian/jira.py", line 2418, in jql
return self.get(url, params=params)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/atlassian/rest_client.py", line 264, in get
response = self.request(
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/atlassian/rest_client.py", line 218, in request
response = self._session.request(
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/requests/sessions.py", line 528, in request
prep = self.prepare_request(req)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/requests/sessions.py", line 456, in prepare_request
p.prepare(
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/requests/models.py", line 320, in prepare
self.prepare_auth(auth, url)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/requests/models.py", line 556, in prepare_auth
r = auth(self)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/requests_oauthlib/oauth1_auth.py", line 108, in __call__
r.url, headers, _ = self.client.sign(
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 351, in sign
('oauth_signature', self.get_oauth_signature(request)))
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 186, in get_oauth_signature
sig = self.SIGNATURE_METHODS[self.signature_method](base_string, self)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/oauthlib/oauth1/rfc5849/signature.py", line 742, in sign_rsa_sha1_with_client
return _sign_rsa('SHA-1', sig_base_str, client.rsa_key)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/oauthlib/oauth1/rfc5849/signature.py", line 617, in _sign_rsa
alg = _get_jwt_rsa_algorithm(hash_algorithm_name)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/oauthlib/oauth1/rfc5849/signature.py", line 562, in _get_jwt_rsa_algorithm
import jwt.algorithms as jwt_algorithms
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/jwt/algorithms.py", line 5, in <module>
from .exceptions import InvalidKeyError
ImportError: cannot import name 'InvalidKeyError' from 'jwt.exceptions' (/layers/google.python.pip/pip/lib/python3.8/site-packages/jwt/exceptions.py)
I think it's because of the same names in jwt and pyjwt. https://github.com/jazzband/djangorestframework-simplejwt/issues/42
In such this situation:
there is a list on the page
below it have one check for check all of the list item,and a div to receive all of the list,
after click it will pop up a alert,after click accept the page will close.
onclick=checkedalldoc();#check
onclick=responseclick();#div
I need use selenium with IE to automatically these
this is my basepage.py for packaging code:
# 点击元素
def click(self, *selector):
el = self.find_element(*selector)
try:
el.click()
logger.info('元素'%s' 已被点击.' % el.text)
except NameError as e:
logger.error('Failed to click the element with %s' % e)
#运行js脚本
def run_script(self, js):
try:
self.driver.execute_script(js)
logger.info('成功运行脚本,脚本内容为:%s.' % js)
except BaseException:
logger.error('js脚本运行错误.')
#切换至弹窗并点击确定
def accept_alert(self):
try:
WebDriverWait(self.driver, 20).until(EC.alert_is_present())
alert = self.driver.switch_to.alert
alert.accept()
logger.info('获得弹出框并选择确认.')
except BaseException:
logger.error('弹出框失败.')
this is logic function
def receive_all_docs(self):
self.click(*self.chkall_checkbox)
self.click(*self.response_btn)
self.accept_alert()
When it works, it prompts the following error and it does not complete the function:
Traceback (most recent call last):
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 1322, in getresponse
response.begin()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "c:\users\a\appdata\local\programs\python\python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "e:\Dropbox\17.Develop\5.Project\autozboa\run.py", line 22, in <module>
manage()
File "e:\Dropbox\17.Develop\5.Project\autozboa\run.py", line 14, in manage
m.handle_doc() # 处理单个文件
File "e:\Dropbox\17.Develop\5.Project\autozboa\manage.py", line 67, in handle_doc
docs_unid = docs.get_docs_unid()
File "e:\Dropbox\17.Develop\5.Project\autozboa\zboa\pages\docs_page.py", line 38, in get_docs_unid
for doc in self.find_elements(*self.docs_link):
File "e:\Dropbox\17.Develop\5.Project\autozboa\zboa\framework\base_page.py", line 70, in find_elements
elements = self.driver.find_elements(*selector)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1005, in find_elements
return self.execute(Command.FIND_ELEMENTS, {
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 402, in _request
resp = http.request(method, url, body=body, headers=headers)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\request.py", line 79, in request
return self.request_encode_body(
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\request.py", line 171, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\poolmanager.py", line 330, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\util\retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 1322, in getresponse
response.begin()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "c:\users\a\appdata\local\programs\python\python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))
i would try two things here
first, syntax:
as described in selenium-python docs, accepting alert is done by:
from selenium.webdriver.common.alert import Alert
Alert(driver).accept()
second, you should check exectly which row produces the exception.
UnexpectedAlertPresentException occurs when you are trying to preform an action while an alert is open. is it possible that those "click" actions are called when an alert is already open?
When I wanted to install pip, the error just came out:
C:\Users\xd>python get-pip.py install
Collecting install
Exception:
Traceback (most recent call last):
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(finder)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\req\req_set.py", line 554, in _prepare_file
require_hashes
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\req\req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\sessions.py", line 488, in get
return self.request('GET', url, **kwargs)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\cachecontrol\adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\adapters.py", line 423, in send
timeout=timeout
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 589, in urlopen
self._prepare_proxy(conn)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 797, in _prepare_proxy
conn.connect()
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\connection.py", line 254, in connect
conn = self._new_conn()
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\connection.py", line 142, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\util\connection.py", line 66, in create_connection
if host.startswith('['):
AttributeError: 'NoneType' object has no attribute 'startswith'
What can I do?
For recent Python versions (3.4+), you don't need to use the get-pip.py script anymore. Just run python -m ensurepip, and the ensurepip module will do everything the get-pip.py script used to do.