core classes

How to make a server request

tba.

Classes:

Client

class pipeLionServer.core.client.Client[source]

The Client-class is an interface, which automatically connects to the server set in the config. The Client class should be used everywhere where ther is the need to connect to the data-base.

It is possible to access the database through the server by using predefined services.

example:
1 | c = Client() 2 | c.sendRequest(‘exampleService’, ‘exampleRequest’, {‘argName1’: True, ‘argName2’: argValue}) 3 | >>> resultFromServer
addRequestToHistory(request, response=None)[source]

Each request a client does to the server the request and its response is stored in a dict. this method will add an entry to this dictionary.

Parameters:
  • request (string) – name of the server-request
  • response (pickled object) – pickled server-response
Returns:

unpickled response

Return type:

variant object

connectToServer()[source]

this method establishes a connection to the server. in case it wasn’t possible to connect to the server, the result will be 0

Returns:success-value 1 if the connection was successful 0 if not
Return type:int
disconnectFromServer()[source]

method will disconnect the client from the server

classmethod getHost()[source]

gets the host from the config or takes the default host, which is the local

Returns:host
Return type:string
classmethod getPort()[source]

gets the port from the config or takes the default port, which is 50007

Returns:port
Return type:int
getRequestHistory()[source]

method will return the full request-history dictionary

queryRequestHistory(id=None, request=None, response=None, all=False)[source]

method will query the request history by one of the given args: id, request, response if id is given, the ids entry in the history is returned, if request is given, all history-entries with the given request are returned and if response is given, all history entries with the given response are returned

Parameters:
  • id (int) – index number of request (last request is -1, first is 0)
  • request (string) – name of the request
  • response (variant object) – object which is searched for in the history
Returns:

method will either return a list of dictionaries or a single dictionary.

Return type:

list or dictionary

sendRequest(service, request='', args={})[source]

method will send a request to the server. argument-dictionary will be pickled and the server will send back a pickled object as well.

Parameters:
  • service (string) – name of the service, in which we can find the request
  • requests (string) – name of the server-requests
  • args (dictionary:) – in case the request needs input arguments to work, these args can be given in here as keyword-args. If there are None, the default value is an empty dictionary
Returns:

the return of this method will be the returnValue of the Service-request-function, which ran on the server.

Return type:

unpickledObject

sendRequests(requests=None)[source]

method is a wrapper around the sendRequest method, and takes a list of service-requests instead of just one. return Value is a list of all server-replies

Parameters:requests (list) – a list of tuples which hold two strings and one dictionary
Returns:list of all server-responses
Return type:list
stopServer()[source]

method will close the server

Server

class pipeLionServer.core.server.Server[source]

The server class provides the functions to start and stop a socket server, that waits for other programs to communicate with the main program. Inbetween calling the start and stop functions a socket will be opened. The port# which is opened is 17473 on your localhost(127.0.0.1) as standard

example:
1| serverA=server() 2| serverA.start() 3| serverA.stop()
dB

alias of SqLiteDataBase

classmethod getHost()[source]

gets the host from the config or takes the default host, which is the local

Returns:host
Return type:string
classmethod getPort()[source]

gets the port from the config or takes the default port, which is 17473

Returns:port
Return type:int
getRequestHistory()[source]

this will return a dictionary holding the complete history of all server-requests :returns: former requests :rtype: dictionary

setupDataBase()[source]

method starts the database and stores the instance in the self.dB class-variable

start()[source]

starts a loop which listens to incoming connections and connects to the client. Incoming commands are BYTEARRAYs which will be decoded as a STRING within this function. It is possible to send multiple commands at once by separating each command with the ‘|’ character. After receiving the ‘closeSocket’ command this function will disconnect from the incoming client and will wait for the next client who connects.

stop()[source]

closes the socket-server

error-handling:

exception pipeLionServer.core.error.PipeLionServerException(message, baseTrace='')[source]

the pipeLionServerException class will create an error-message for the pipeLionServer in case there was an error, due to a wrong request to the server

exception pipeLionServer.core.error.PipeLionServerTimeoutException[source]

the PipeLionServerTimeoutException class will create an error-message for the pipeLionServer in case there was a timeout-error, due to a wrong request to the server

exception pipeLionServer.core.error.PipeLionServerWarning(message, baseTrace='')[source]

the PipeLionServerWarning class will create a warning-message for the pipeLionServer in case there was a warning, due to a wrong request to the server

Table Of Contents

Previous topic

Welcome to the pipeLionServer documentation!

Next topic

dataBase - API

This Page