Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxies arg to TM1Service #911

Merged
merged 1 commit into from
May 2, 2023
Merged

Add proxies arg to TM1Service #911

merged 1 commit into from
May 2, 2023

Conversation

MariusWirtz
Copy link
Collaborator

Accept proxies argument in TM1Service constructor

@Cubewise-gtejeda
please upgrade to this branch and test it.

pip uninstall tm1py
pip install https://github.com/cubewise-code/tm1py/archive/refs/heads/feature/support-proxy.zip
proxies = {
   'http': 'http://proxy.example.com:8080',
   'https': 'http://secureproxy.example.com:8090',
}

with TM1Service(**params, proxies=proxies) as tm1:
    print(tm1.server.get_product_version())
}

@MariusWirtz MariusWirtz force-pushed the feature/support-proxy branch from 7166438 to 7db7c8c Compare April 28, 2023 14:21
@MariusWirtz
Copy link
Collaborator Author

@Cubewise-gtejeda please try again.

Now we pass the proxies to the requests Session object before the first request is made to TM1.

@Cubewise-gtejeda
Copy link

Package containing module 'urllib3' is not listed in the project requirements
PyCharm shows this message on line 13

@Cubewise-gtejeda
Copy link

Proxies are configured in the config.ini file as such:
proxies={{"http":"http://192.168.0.10:3128"},{"https":"http://192.168.0.10:3128"}}

Still getting this error:
ValueError: No response returned from URL: 'https://cubewise.planning-analytics.ibmcloud.com/tm1/api/plansamp/api/v1/Configuration/ProductVersion/$value'. Please double check your address and port number in the URL.

Last entry in the trace:
TM1py\Services\RestService.py:252: in connect
self._start_session(...

@Cubewise-gtejeda
Copy link

Cubewise-gtejeda commented Apr 28, 2023

Line 191:
self._proxies = kwargs.get('proxies', None)
This is setting the value correctly.

Line 228:

        self._s = Session()
        if self._proxies:
            self._s.proxies = self._proxies

This also gets populated correctly.

@Cubewise-gtejeda
Copy link

In sessions.py from the requests package line 575:
proxies = proxies or {}

proxies is empty.

@Cubewise-gtejeda
Copy link

When setting environment variables it works:

import os
os.environ["HTTP_PROXY"] = "http://192.168.0.10:3128"
os.environ["HTTPS_PROXY"] = "http://192.168.0.10:3128"

Even through the proxies in sessions.py in the requests package remains empty.
See: https://requests.readthedocs.io/en/latest/user/advanced/#proxies

@MariusWirtz MariusWirtz force-pushed the feature/support-proxy branch from 7db7c8c to 6a1dc83 Compare May 2, 2023 12:09
@MariusWirtz MariusWirtz force-pushed the feature/support-proxy branch from 6a1dc83 to ea9e616 Compare May 2, 2023 15:11
@MariusWirtz MariusWirtz merged commit 91795cd into master May 2, 2023
@Cubewise-gtejeda
Copy link

Correction from #911 (comment):
The proxies in the configuration file should be specified as below:
proxies={"http":"http://192.168.0.10:3128","https":"http://192.168.0.10:3128"}

@MariusWirtz MariusWirtz deleted the feature/support-proxy branch October 15, 2024 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants