Product:
Planning Analytics 2.0.9.x TM1_version=TM1-AW64-ML-RTM-11.0.913.10-0
Microsoft Windows 2019 server
Python 3.11

Issue:

Get error when run code below:

C:\Program Files\Python311>python.exe c:\temp\test.py

ERROR:
(‘Connection aborted.’, BadStatusLine(‘\x15\x03\x03\x00\x02\x02\n’))

 

Code that does not work:

from TM1py.Services import TM1Service

# Parameters for connection
user = "admin"
password = "apple"
namespace = ""
address = "192.168.50.190"
gateway = ""
port = 12354
# HTTPPortNumber=12354 for planning sample
ssl = "T"

if len(namespace.strip()) == 0:
namespace = None

if len(gateway.strip()) == 0:
gateway = None

try:
with TM1Service(
address=address,
port=port,
user=user,
password=password,
namespace=namespace,
gateway=gateway,
ssl=ssl) as tm1:
server_name = tm1.server.get_server_name()
print("Connection to TM1 established!! your Servername is: {}".format(server_name))
except Exception as e:
print("\nERROR:")
print("\t" + str(e))

https://code.cubewise.com/blog/check-connectivity-with-tm1/
Solution:

Change ssl = “T” to ssl = True to make the code work.

 

A small number of constants live in the built-in namespace. They are:

False
The false value of the bool type. Assignments to False are illegal and raise a SyntaxError.
True
The true value of the bool type. Assignments to True are illegal and raise a SyntaxError.
None
An object frequently used to represent the absence of a value, as when default arguments are not passed to a function. Assignments to None are illegal and raise a SyntaxError. None is the sole instance of the NoneType type.

 

More Information:

https://www.w3schools.com/python/python_variables.asp

https://github.com/cubewise-code/TM1py-samples

#import TM1py services
from TM1py.Services import TM1Service
from TM1py.Utils import Utils
#TM1 credentials
ADDRESS = "192.168.50.190"
PORT = 12354
USER = "admin"
PWD = "apple"
SSL = True

#Connect to the TM1 instance
tm1 = TM1Service(address=ADDRESS, port=PORT, user=USER, password=PWD, ssl=SSL)
# Cube view used 
cube_name = 'CubeOfFlags'
view_name = 'Default'
# get the data to a variable in python
values = tm1.cubes.cells.execute_view_values(cube_name=cube_name, view_name=view_name, private=False)
# extract first ten values
first_ten = list(values)[0:10]
# print first ten values
print(first_ten)

 

 

https://docs.python.org/3/library/constants.html

https://realpython.com/python-constants/

https://www.tutorialspoint.com/how-do-i-create-a-constant-in-python

https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-ipv6-in-windows