Closed huiosx closed 3 years ago
I tried subprocess.Popen(["open", "-F", "-a", "Terminal", r"bin/run.sh", r"root/conf.yaml"])
in its own file, and ran it from /resources/clientportal.beta.gw
so that it would pick up bin/rus.sh
and root/conf.yaml
. Here's what happened:
The error is: “run.sh” can’t be opened because Sandbox is not allowed to open documents in Terminal.
It's followed by the same error for conf.yaml
.
I came across this error a few times before too while trying out a few ideas. I think this could be key now.
It seems this person had the exact same issue. He doesn't mention interactive-broker-python-api by name, but he quotes the same code I'm talking about verbatim.
Here's how I got around this issue.
In /resources
I created start.command
:
#!/bin/bash
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"/clientportal.beta.gw
bin/run.sh root/conf.yaml
Then in client.py
I modified it so that the method _start_server
, specifically line 522. It is now:
IB_WEB_API_PROC = ["open", "-F", "-a", "Terminal", "start.command"]
You may have to edit your cwd
in line 525 to point it to /resources
, I'm not sure. For now I've just given the literal path to my /resources
folder. Hopefully this helps someone.
Hey bud ... I am having this same issue, not able to get your work around functioning.
would you be able to post the code as you have it if you don't mind ?? Im wondering if I have done the "start.command" correctly by simply pasting that text and naming my file exactly that .
it does show that I have a server runnon on process id (***) but just can't connect. Cheers.
Here's what I have: Hope it helps:
I should note I've now moved to ib-insync as I've found that to work better.
When I run
ib_client.create_session()
, I get the expected message with steps 1-3 telling me how to authenticate. Terminal is opened. However, nothing is run in Terminal so there's nothing running at https://localhost:5000. However, if Icd
to the correct folder and dobin/run.sh root/conf.yaml
then localhost shows the login screen. So it seems the problem is that the command isn't being passed through to Terminal.client.py contains
def _start_server(self)
with this relevant section:My suspicion is that something is up with
subprocess
. Not only because of this, but also because after Terminal does nothing and the command prompt in VS Code is asking meWould you like to make an authenticated request (Yes/No)?
, when I type 'No', I get a few errors includingAfter some Googling, someone pointed out that if you have your own
subprocess.py
then Python will look through that and not find the expectedDETACHED_PROCESS
, but I don't have my ownsubprocess.py
.Have I got a corrupt subprocess module, even though it comes as standard with Python? Is something else wrong? Thanks.