HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
Command.py
Go to the documentation of this file.
1 '''
2 Created on Feb 17, 2014
3 
4 @author: scorp
5 @link: http://hierarchical-cluster-engine.com/
6 @copyright: Copyright © 2013-2014 IOIX Ukraine
7 @license: http://hierarchical-cluster-engine.com/license/
8 @since: 0.1
9 '''
10 
11 from Constants import ADMIN_HANDLER_TYPES as ADMIN_HANDLERS
12 import Constants as CONSTANTS
13 
14 
15 
16 class Command(object):
17  def __init__(self, commandName=None, params=None, adminHandler=ADMIN_HANDLERS.ADMIN, requestTimeout=None):
18  self.commandName = commandName
19  if params == None:
20  params = []
21  self.params = params
22  self.adminHandler = adminHandler
23  self.requestTimeout = requestTimeout
24 
25 
26  def setCommandName(self, commandName):
27  self.commandName = commandName
28 
29 
30  def setParams(self, params):
31  self.params = params
32 
33 
34  def setAdminHandler(self, adminHandler):
35  self.adminHandler = adminHandler
36 
37 
38  def setRequestTimeout(self, requestTimeout):
39  self.requestTimeout = requestTimeout
40 
41 
42  def getCommandName(self):
43  return self.commandName
44 
45 
46  def getParams(self):
47  return self.params
48 
49 
50  def getAdminHandler(self):
51  return self.adminHandler
52 
53 
54  def getRequestTimeout(self):
55  return self.requestTimeout
56 
57 
58 
59  def generateBody(self):
60  resultStr = ""
61  if self.commandName != None:
62  resultStr += self.adminHandler
63  resultStr += CONSTANTS.COMMAND_DELIM
64  resultStr += self.commandName
65  resultStr += CONSTANTS.COMMAND_DELIM
66  for param in self.params:
67  if type(param) == type(0):
68  param = str(param)
69  resultStr += param
70  resultStr += CONSTANTS.PARAM_DELIM
71  if resultStr[-1] == CONSTANTS.PARAM_DELIM:
72  resultStr = resultStr[:-1]
73  resultStr += CONSTANTS.COMMAND_DELIM
74  return resultStr
75 
def setParams(self, params)
Definition: Command.py:30
def getCommandName(self)
Definition: Command.py:42
def getAdminHandler(self)
Definition: Command.py:50
Command class contents "commad" data and processing methods.
Definition: Command.py:16
def getParams(self)
Definition: Command.py:46
def setAdminHandler(self, adminHandler)
Definition: Command.py:34
def getRequestTimeout(self)
Definition: Command.py:54
def generateBody(self)
Main processing method, generate request body string, based on internal field - "param".
Definition: Command.py:59
def setRequestTimeout(self, requestTimeout)
Definition: Command.py:38
def __init__(self, commandName=None, params=None, adminHandler=ADMIN_HANDLERS.ADMIN, requestTimeout=None)
Definition: Command.py:17
def setCommandName(self, commandName)
Definition: Command.py:26