def echoServerStatus(): """ Prints the status of the server, either inactive or active as well as returning the server activity integer. Note that servers are started up asynchronously, so there is a short period of time after the startServer() call where the server is loading but not yet ready for communication. These states are captured by both the printed output and the return value @@@returns int An integer representing the state of the server. Values will be: [#list] [#item]0: Server is inactive.[/#item] [#item]1: Server is loading.[/#item] [#item]2: Server is active and ready for communication.[/#item] [/#list] """ if NimbleServerThread.isActivating(): print 'Nimble server is loading' return 1 if NimbleServerThread.isRunning(): print 'Nimble server is running.' return 2 print 'Nimble server is inactive.' return 0
def startServer(logLevel=0, router=None, inMaya=None): """ Starts the NimbleServer properly given the current environmental conditions. The server runs in a separate thread and remains active until the stopServer() method. @@@param logLevel:int The integer logLevel to use when starting the server. The allowed values are: [#list] [#item]0 (default): Only log critical actions.[/#item] [#item]1: Additionally log warnings as well as succinct activity.[/#item] [#item]2: Full verbose logging of all activity.[/#item] [/#list] @@@param router:NimbleRouter The router to use for the server. The default value of None will use the default router for the given environment. The router is responsible for handling the communication traffic received by the server and correctly responding as a result. @@@param inMaya:boolean Whether or not the server is being run in Maya. By default this is determined automatically by the Nimble environment settings. However, in some cases the determination can be incorrect if your external or Maya Python interpreters have been modified to fool the environment test. In such cases this may need to be explicitly set. """ NimbleEnvironment.inMaya(override=inMaya) NimbleEnvironment.setServerLogLevel(logLevel) NimbleServerThread(router=router).start()
def echoServerStatus(): """ Prints the status of the server, either inactive or active as well as returning the server activity integer. Note that servers are started up asynchronously, so there is a short period of time after the startServer() call where the server is loading but not yet ready for communication. These states are captured by both the printed output and the return value @@@returns int An integer representing the state of the server. Values will be: [#list] [#item]0: Server is inactive.[/#item] [#item]1: Server is loading.[/#item] [#item]2: Server is active and ready for communication.[/#item] [/#list] """ if NimbleServerThread.isActivating(): print('Nimble server is loading') return 1 if NimbleServerThread.isRunning(): print('Nimble server is running.') return 2 print('Nimble server is inactive.') return 0
def stopServer(): """ Stops the currently running server if one is active. If no server is active this method will fail silently, no exception will be thrown, making it safe to call at any time. """ return NimbleServerThread.closeServer()