SpssServerConf Class (Python)
The SpssServerConf class represents the configuration information for a server machine (may be an instance of IBM® SPSS® Statistics Server or the local computer). From the SpssClient object you can get an SpssServerConf object for the current server, the default server, the local computer, or you can get a list of SpssServerConf objects for all configured servers (includes the local computer).
Example: Connecting to a Server
import SpssClient
SpssClient.StartClient()
SpssServerConf = SpssClient.CreateNewServer("myservername",3016,"")
SpssServerConf.Connect("","myuserID","mypassword")
SpssClient.StopClient()
- The CreateNewServer method from the SpssClient class creates a new server configuration object for a server with a specified name (or IP address) on a specified port. It returns an SpssServerConf object.
- The Connect method of an SpssServerConf object establishes a connection to the server using the specified domain, user ID, and password.
Example: Configuring a New Server and Saving the Configuration
import SpssClient
SpssClient.StartClient()
ServerConfList = SpssClient.GetConfiguredServers()
SpssServerConf = SpssClient.CreateNewServer("myservername",3016,"")
ServerConfList.Add(SpssServerConf)
SpssServerConf = ServerConfList.GetItemAt(ServerConfList.Size()-1)
SpssServerConf.SetUserId("myuserID")
SpssServerConf.SetPassword("mypassword")
SpssServerConf.SetUserDomain("mydomain")
SpssServerConf.SetPasswordSaved(True)
SpssClient.SaveServers()
SpssClient.StopClient()
- SpssClient.GetConfiguredServers() gets an SpssServerConfList object that allows you to manage the list of configured servers.
- The CreateNewServer method from the SpssClient class creates a new server configuration object. The variable SpssServerConf is an SpssServerConf object.
- To add a new server configuration to the list, you use the Add method of the SpssServerConfList object.
- The user ID, password, and domain are set using the SetUserId, SetPassword, and SetUserDomain methods of the SpssServerConf object. The SetPasswordSaved method specifies that the password is to be saved for future use.
- The SaveServers method from the SpssClient class saves all server configurations so that they are available in future sessions.
Example: Connecting to a Server Using a Saved Configuration
import SpssClient
SpssClient.StartClient()
ServerConfList = SpssClient.GetConfiguredServers()
for i in range(ServerConfList.Size()):
server = ServerConfList.GetItemAt(i)
if server.GetServerName()=="myservername":
server.ConnectWithSavedPassword()
SpssClient.StopClient()
- SpssClient.GetConfiguredServers() gets an SpssServerConfList object that provides access to the list of configured servers.
- The GetItemAt method of an SpssServerConfList object returns the SpssServerConf object at the specified index. Index values start from 0 and represent the order in which the servers were added to the list.
- The ConnectWithSavedPassword method uses the connection information (domain, user ID, and password) to connect to the server.