def getServerStates(pbclient=None, dc_id=None, serverid=None, servername=None):
if pbclient is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if dc_id is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>server = None<EOL>if serverid is None:<EOL><INDENT>if servername is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>server_info = select_where(getServerInfo(pbclient, dc_id),<EOL>['<STR_LIT:id>', '<STR_LIT:name>', '<STR_LIT:state>', '<STR_LIT>'],<EOL>name=servername)<EOL>if len(server_info) > <NUM_LIT:1>:<EOL><INDENT>raise NameError("<STR_LIT>".format(servername))<EOL><DEDENT>if len(server_info) == <NUM_LIT:1>:<EOL><INDENT>server = server_info[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>server_info = pbclient.get_server(dc_id, serverid, <NUM_LIT:1>)<EOL>server = dict(id=server_info['<STR_LIT:id>'],<EOL>name=server_info['<STR_LIT>']['<STR_LIT:name>'],<EOL>state=server_info['<STR_LIT>']['<STR_LIT:state>'],<EOL>vmstate=server_info['<STR_LIT>']['<STR_LIT>'])<EOL><DEDENT>except Exception:<EOL><INDENT>ex = sys.exc_info()[<NUM_LIT:1>]<EOL>if ex.args[<NUM_LIT:0>] is not None and ex.args[<NUM_LIT:0>] == <NUM_LIT>:<EOL><INDENT>print("<STR_LIT>".format(serverid))<EOL>server = None<EOL><DEDENT>else:<EOL><INDENT>raise ex<EOL><DEDENT><DEDENT><DEDENT>return server<EOL>
gets states of a server