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?
Related
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
I have a windows 10 machine, and I am not sure what the problem is, I was able to run everything until a few hours back and now I keep running into SSL certificate Expired error for some reason.
Steps to reproduce:
This is my code.
'''
'''
from datetime import datetime
from influxdb_client import InfluxDBClient
config = {
'start': datetime.date(datetime(2021, 4, 7)),
'stop': datetime.date(datetime(2021, 4, 10)),
'bucket': "hidden",
'org': "hidden",
'url': "hidden",
'token': "hidden",
'measurement-name': "hidden",
}
client = InfluxDBClient(
url="https://eu-central-1-1.aws.cloud2.influxdata.com",
org=config['org'],
bucket=config['bucket'],
token=config['token'],
# verify_ssl=False
)
query_api = client.query_api()
ticker = 'TSLA'
results_df = query_api.query_data_frame(
f'from(bucket:"{config["bucket"]}")'
f'|> range(start: {config["start"]}, stop: {config["stop"]}) '
'|> filter(fn: (r) =>'
f' r._measurement == "{config["measurement-name"]}"'
f' and r.symbol == "{ticker}"'
') '
'|> filter (fn: (r) =>'
' r._field == "price"'
') '
'|> pivot('
' rowKey:["_time"],'
' columnKey: ["_field"],'
' valueColumn: "_value"'
') '
'|> sort(columns: ["_time"], desc: false) '
)
print(results_df)
Expected behavior:
I expect it to give me a dataframe like it always does and as you can see when I keep the ssl_verify=False it works.
result table _time _start _stop _measurement source symbol price
0 _result 0 2021-04-07 00:00:00+00:00 2021-04-07 00:00:00+00:00 2021-04-08 00:00:00+00:00 public_instruments_data YAHOO-FINANCE TSLA 670.969971
Actual behavior:
Traceback (most recent call last):
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "d:\MAIN_ENV\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\rest.py", line 181, in request
r = self.pool_manager.request(
File "d:\MAIN_ENV\lib\site-packages\urllib3\request.py", line 78, in request
return self.request_encode_body(
File "d:\MAIN_ENV\lib\site-packages\urllib3\request.py", line 170, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "d:\MAIN_ENV\lib\site-packages\urllib3\poolmanager.py", line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\retry.py", line 507, in increment
raise six.reraise(type(error), error, _stacktrace)
File "d:\MAIN_ENV\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
raise value.with_traceback(tb)
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "d:\MAIN_ENV\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\backend-dev-plaid\test_app_5.py", line 26, in <module>
results_df = query_api.query_data_frame(
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\client\query_api.py", line 146, in query_data_frame
_generator = self.query_data_frame_stream(query, org=org, data_frame_index=data_frame_index, params=params)
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\client\query_api.py", line 172, in query_data_frame_stream
response = self._query_api.post_query(org=org, query=self._create_query(query, self.default_dialect, params),
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\service\query_service.py", line 260, in post_query
(data) = self.post_query_with_http_info(**kwargs) # noqa: E501
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\service\query_service.py", line 340, in post_query_with_http_info
return self.api_client.call_api(
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\api_client.py", line 341, in call_api
return self.__call_api(resource_path, method,
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\api_client.py", line 171, in __call_api
response_data = self.request(
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\api_client.py", line 386, in request
return self.rest_client.POST(url,
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\rest.py", line 302, in POST
return self.request("POST", url,
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\rest.py", line 238, in request
raise ApiException(status=0, reason=msg)
influxdb_client.rest.ApiException: (0)
Reason: SSLError
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)
Specifications:
Client Version: 1.21.0
InfluxDB Version: 2.0
Platform: Windows 10 home
Python: 3.9.7
I tried reinstalling python and all the libraries again just make sure the problem wasn't at my end and I also followed the urllib3 docs for installing the certificates from certifi and urllib3[secure] as suggested when I keep ssl_verify=False.
Any help would be much appreciated, thanks a lot in advance.
Just use ..., ssl_ca_cert=certifi.where(), ... as a temporary solution, but anyways since posting the question it seems the certificates have been already updated.
We've been using a Python script to pull orders from our BigCommerce store and reformat them into a .csv for use by our warehouse. This method has been working for the past 3 years yet since the 16 September 2020 our connection has started dropping without a response.
Full response is:
Downloading Order: 1541
WPy64-3720\python-3.7.2.amd64\python.exe : Traceback (most recent call last):
At D:\Administration\Scripts\re_orders\reau-orders.ps1:7 char:28
+ $OrdersProcessingOutput = (WPy64-3720\python-3.7.2.amd64\python.exe bcOrdersREAU ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 386, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 382, in _make_request
httplib_response = conn.getresponse()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 1321, in
getresponse
response.begin()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 265, in
_read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Administration\Scripts\re_orders\requests\adapters.py", line 438, in send
timeout=timeout
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\util\retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 386, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 382, in _make_request
httplib_response = conn.getresponse()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 1321, in
getresponse
response.begin()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 265, in
_read_status
raise RemoteDisconnected("Remote end closed connection without"
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed
connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bcOrdersREAU.py", line 1254, in <module>
checkPendingPayments(basePath + pendingPayFile)
File "bcOrdersREAU.py", line 915, in checkPendingPayments
getOrders(orderId,orderId)
File "bcOrdersREAU.py", line 249, in getOrders
orderJSON = getOrder(headers,orderNo)
File "D:\Administration\Scripts\re_orders\tenacity\__init__.py", line 333, in wrapped_f
return self(f, *args, **kw)
File "D:\Administration\Scripts\re_orders\tenacity\__init__.py", line 417, in __call__
do = self.iter(retry_state=retry_state)
File "D:\Administration\Scripts\re_orders\tenacity\__init__.py", line 360, in iter
return fut.result()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\concurrent\futures\_base.py", line 425,
in result
return self.__get_result()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\concurrent\futures\_base.py", line 384,
in __get_result
raise self._exception
File "D:\Administration\Scripts\re_orders\tenacity\__init__.py", line 420, in __call__
result = fn(*args, **kwargs)
File "bc
OrdersREAU.py", line 1155, in getOrder
order = session.get(ApiPath2 + 'orders/' + str(orderNo), headers=headers)
File "D:\Administration\Scripts\re_orders\requests\sessions.py", line 531, in get
return self.request('GET', url, **kwargs)
File "D:\Administration\Scripts\re_orders\requests\sessions.py", line 518, in request
resp = self.send(prep, **send_kwargs)
File "D:\Administration\Scripts\re_orders\requests\sessions.py", line 639, in send
r = adapter.send(request, **kwargs)
File "D:\Administration\Scripts\re_orders\requests\adapters.py", line 488, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without
response'))
The code we're using runs daily and is essentially just iterating through new orders and pulling the details down, including the ordered products. Something like:
requests.get(ApiPath2 + 'orders/' + str(orderNo), headers=headers)
session.get(ApiPath2 + 'orders/' + str(orderNo) + '/products?page=' + str(page), headers=headers)
It doesn't fail every day but has started to be almost a daily occurrence now.
What we have tried:
new API credentials
different servers on a different network (Aus + Europe)
Running the script at different times
Any help would be greatly appreciated. Currently we just keep re running the code manually until it works.
Per python docs
self.send_header('Content-Type', 'blabla' )
self.end_headers()
I am trying to create a program on a Raspberry Pi that will intermittently take pictures and send them to AWS S3.
About half the time, everything works fine. Problem is that the WiFi receiver on the Raspberry Pi that I have is pretty awful, and it loses connection constantly. I know it isn't my WiFi because all other devices on the network are fine. After the connection is lost, it searches until it finds it again, usually 15-30 seconds or so. Then the cycle repeats after a minute or two.
I am trying to create code that will attempt to connect to S3, and on failure, will continue trying until the connection is restored. So far, however, connection errors still cause a hard stop.
import boto3
s3 = boto3.resource('s3')
allbuckets = 0
while allbuckets == 0:
try:
allbuckets = s3.buckets.all()
except:
allbuckets = 0
for bucket in allbuckets:
print(bucket.name)
If the connection is solid, this works fine:
>>> %Run boto_test.py
derek-raspberrypi-pictures
stpaul-academy-middleschool-showcase-2020-part2
If the connection has been temporarily lost, however:
>>> %Run boto_test.py
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/botocore/httpsession.py", line 263, in send
chunked=self._chunked(request.headers),
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 343, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 693, in reraise
raise value
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 841, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 301, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 168, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <botocore.awsrequest.AWSHTTPSConnection object at 0xb52a6950>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Documents/boto_test.py", line 15, in <module>
for bucket in allbuckets:
File "/home/pi/.local/lib/python3.7/site-packages/boto3/resources/collection.py", line 83, in __iter__
for page in self.pages():
File "/home/pi/.local/lib/python3.7/site-packages/boto3/resources/collection.py", line 161, in pages
pages = [getattr(client, self._py_operation_name)(**params)]
File "/home/pi/.local/lib/python3.7/site-packages/botocore/client.py", line 316, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/client.py", line 622, in _make_api_call
operation_model, request_dict, request_context)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/client.py", line 641, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 102, in make_request
return self._send_request(request_dict, operation_model)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 137, in _send_request
success_response, exception):
File "/home/pi/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 256, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/hooks.py", line 356, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/hooks.py", line 211, in _emit
response = handler(**kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/home/pi/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 251, in __call__
caught_exception)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 317, in __call__
caught_exception)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 223, in __call__
attempt_number, caught_exception)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "/home/pi/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 200, in _do_get_response
http_response = self._send(request)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 269, in _send
return self.http_session.send(request)
File "/home/pi/.local/lib/python3.7/site-packages/botocore/httpsession.py", line 283, in send
raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://s3.amazonaws.com/"
Any suggestions on how to make this robust to the intermittent WiFi connection would be greatly appreciated.
Remove the power management from the wifi interface on the RPi which should keep it active.
$ sudo iwconfig wlan0 power off
Anyone has an idea how I can solve this error?
I am trying to download data and I have connected a posgresql server with the database navigator as localhost. Files are successfully downloaded for like 3 minutes and than suddenly the download stops and returns this error message:
.
..
...
run_filing 201500419349300305
run_filing 201540439349301594
Traceback (most recent call last):
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Georg/PycharmProjects/990-xml-database/irsdb/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/Users/Georg/PycharmProjects/990-xml-database/irsdb/return/management/commands/load_filings.py", line 123, in handle
self.run_filing(filing)
File "/Users/Georg/PycharmProjects/990-xml-database/irsdb/return/management/commands/load_filings.py", line 65, in run_filing
parsed_filing = self.xml_runner.run_filing(object_id)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/irsx/xmlrunner.py", line 111, in run_filing
this_filing.process(verbose=verbose)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/irsx/filing.py", line 232, in process
self._download(verbose=verbose)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/irsx/filing.py", line 70, in _download
stream_download(self.URL, self.filepath, verbose=verbose)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/irsx/file_utils.py", line 22, in stream_download
response = requests.get(url, stream=True)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
Attached is a screenshot of the connectionpool.py code.