python-3.5

Requests Library Force Use of HTTP/1.1 On HTTPS Proxy CONNECT

非 Y 不嫁゛ 提交于 2021-01-27 13:12:21
问题 I am having a problem with a misbehaving HTTP Proxy server. I have no control over the proxy server, unfortunately -- it's an 'enterprise' product from IBM. The proxy server is part of a service virtualization solution being leveraged for software testing. The fundamental issue (I think*) is that the proxy server sends back HTTP/1.0 responses. I can get it to work fine from SOAP UI ( A Java application) and curl from the command line, but Python refuses to connect. From what I can tell,

Why does asyncio subprocess behave differently with created event loop unless you set_event_loop?

谁说胖子不能爱 提交于 2021-01-27 13:03:38
问题 I have this simple async code that spawns sleep 3 and then waits for it to complete: from asyncio import SelectorEventLoop, create_subprocess_exec, \ wait_for, get_event_loop, set_event_loop def run_timeout(loop, awaitable, timeout): timed_awaitable = wait_for(awaitable, timeout=timeout, loop=loop) return loop.run_until_complete(timed_awaitable) async def foo(loop): process = await create_subprocess_exec('sleep', '3', loop=loop) await process.wait() print(process.returncode) Notice how it

Setting exit code in atexit callback

ぐ巨炮叔叔 提交于 2021-01-27 12:52:52
问题 Is there any way to set exit code in the function registered in atexit module and called on exit? The call to sys.exit(code) produces an error and does not set exit code to the desired value. d:\>python atexit_test.py Error in atexit._run_exitfuncs: Traceback (most recent call last): File "atexit_test.py", line 3, in myexit sys.exit(2) SystemExit: 2 d:\>echo %ERRORLEVEL% 0 The contents of atexit_test.py : def myexit(): import sys sys.exit(2) import atexit atexit.register(myexit) 回答1: I can

Python (3.5) - urllib.request.urlopen - Progress Bar Available?

落花浮王杯 提交于 2021-01-27 12:23:13
问题 I'm trying to search the world wide web for this answer, but I feel there answer may be no. I'm using Python 3.5 and a library called urllib.request with a method called urllib.request.urlopen(url) to open a link and download a file. It would be nice to have some kind of measure of progress for this, as the file(s) are over 200MB. I'm looking at the API here, and don't see any kind of parameter with a hook. Here's my code: downloadURL = results[3] #got this from code earlier up rel_path =

curl for get-pip.py does not work: Syntax Error

纵饮孤独 提交于 2021-01-27 12:01:49
问题 When I try to run: [root@pex appliance_ui]# curl https://bootstrap.pypa.io./get-pip.py | python It returns: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1603k 100 1603k 0 0 7006k 0 --:--:-- --:--:-- --:--:-- 13.2M Traceback (most recent call last): File "<stdin>", line 20649, in <module> File "<stdin>", line 197, in main File "<stdin>", line 82, in bootstrap File "/tmp/tmpH39pcu/pip.zip/pip/_internal/__init__.py", line 42, in <module>

curl for get-pip.py does not work: Syntax Error

元气小坏坏 提交于 2021-01-27 12:00:01
问题 When I try to run: [root@pex appliance_ui]# curl https://bootstrap.pypa.io./get-pip.py | python It returns: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1603k 100 1603k 0 0 7006k 0 --:--:-- --:--:-- --:--:-- 13.2M Traceback (most recent call last): File "<stdin>", line 20649, in <module> File "<stdin>", line 197, in main File "<stdin>", line 82, in bootstrap File "/tmp/tmpH39pcu/pip.zip/pip/_internal/__init__.py", line 42, in <module>

error while launching qweb report from python

梦想与她 提交于 2021-01-27 11:50:38
问题 I'm upgrading a module from odoo v10 to odoo v11. It is founded that the get_action is replaced with report_action. so I used the code as follows self.env.ref('report_action_name').report_action(self, data=data, config=False) but it gives me error AttributeError: 'ir.ui.view' object has no attribute 'report_action' Thanks in advance 回答1: Make sure that report_action_name is the record_id of the report . Eg: Python self.env.ref('module_name.record_id').report_action(self, data=data, config

Excel wont recognize date using openpyxl

冷暖自知 提交于 2021-01-27 06:41:35
问题 I have a piece of code that converts a unix date to standard U.S. date format. It displays properly in excel, however excel doesn't recognize it as a date. if str(startdate).isdigit(): startdate = int(startdate) date = datetime.datetime.fromtimestamp(int(startdate)).strftime('%m/%d/%Y') ws4.cell(row=cell.row,column=2).value = date ws4.cell(row=cell.row,column=2).number_format = 'MM DD YYYY' Any idea how to get excel to see this as a date rather than text? 回答1: My mistake was assuming the line

Excel wont recognize date using openpyxl

北慕城南 提交于 2021-01-27 06:40:18
问题 I have a piece of code that converts a unix date to standard U.S. date format. It displays properly in excel, however excel doesn't recognize it as a date. if str(startdate).isdigit(): startdate = int(startdate) date = datetime.datetime.fromtimestamp(int(startdate)).strftime('%m/%d/%Y') ws4.cell(row=cell.row,column=2).value = date ws4.cell(row=cell.row,column=2).number_format = 'MM DD YYYY' Any idea how to get excel to see this as a date rather than text? 回答1: My mistake was assuming the line

How can I specify rmarkdown to use python3 instead python 2?

限于喜欢 提交于 2021-01-27 02:55:39
问题 I am trying to run python as rmarkdwon code chunks. I was sucessfull but rmarkdown by default uses python2 and I want it to use python 3. I am running it on Ubuntu with python 2.7.6 installed and I installed anaconda with pytthon 3.5, which is the one I want rmarkdown use. Here is the code and output of the python chunk in rmarkdown ```{python} import sys print (sys.version) ``` and the output: 2.7.6 (default, Jun 22 2015, 17:58:13) Any ideas? 回答1: You can add engine.path = '/path/to/python3'