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
dc_db.DBTask.DBTask Class Reference
Inheritance diagram for dc_db.DBTask.DBTask:
Collaboration diagram for dc_db.DBTask.DBTask:

Classes

class  Meta
 

Public Member Functions

def __init__ (self)
 
def setup (self)
 
def run (self)
 
def close (self, code=None)
 

Public Attributes

 errorCode
 drceSyncTasksCoverPickled = sys.stdin.read() More...
 
 errorStr
 

Detailed Description

Definition at line 47 of file DBTask.py.

Constructor & Destructor Documentation

◆ __init__()

def dc_db.DBTask.DBTask.__init__ (   self)

Definition at line 58 of file DBTask.py.

58  def __init__(self):
59  # call base class __init__ method
60  foundation.CementApp.__init__(self)
61  self.errorCode = Constants.EXIT_CODE_OK
62  self.errorStr = ""
63 
64 
def __init__(self)
constructor
Definition: UIDGenerator.py:19

Member Function Documentation

◆ close()

def dc_db.DBTask.DBTask.close (   self,
  code = None 
)

Definition at line 157 of file DBTask.py.

157  def close(self, code=None): # pylint: disable=W0221,W0613
158  sys.stdout.flush()
159  self.errorCode = Constants.EXIT_CODE_OK
160  foundation.CementApp.close(self)
161 

◆ run()

def dc_db.DBTask.DBTask.run (   self)

Definition at line 74 of file DBTask.py.

74  def run(self):
75  # call base class run method
76  foundation.CementApp.run(self)
77 
78  if self.pargs.config is not None:
79  try:
80  drceSyncTasksCoverPickled = sys.stdin.read()
81 
82  if not os.path.isfile(self.pargs.config):
83  raise Exception('Config file %s not found' % self.pargs.config)
84  cfgParser = ConfigParser.ConfigParser()
85  cfgParser.read(self.pargs.config)
86 
87  # init loggers
88  logging.config.fileConfig(cfgParser.get("TasksManager", "log_cfg"))
89 
90  # Logger initialization
91  logger = Utils.MPLogger().getLogger()
92  #logger.debug("Receved object:\n" + str(drceSyncTasksCoverPickled) + "\n")
93 
94  dbTask = TasksManager(cfgParser)
95 
96 
97  if len(drceSyncTasksCoverPickled) == 0 or drceSyncTasksCoverPickled[-1] != '\x2E':
98  drceSyncTasksCoverPickled += '\x2E'
99 
100  drceSyncTasksCover = pickle.loads(drceSyncTasksCoverPickled)
101  responseDRCESyncTasksCover = dbTask.process(drceSyncTasksCover)
102  sys.stdout.write(pickle.dumps(responseDRCESyncTasksCover))
103  sys.stdout.flush()
104 
105  if dbTask.SQLErrorCode != Constants.EXIT_CODE_OK:
106  logger.error("Exited with dbTask.SQLErrorCode=" + str(dbTask.SQLErrorCode))
107  #sys.stderr.write("Exited with dbTask.SQLErrorCode=" + str(dbTask.SQLErrorCode) + "\n" +
108  # "dbTask.SQLErrorMessage=\"" + dbTask.SQLErrorString + "\"\n")
109 
110 
111  # log message about profiler
112  logger.info(APP_CONSTS.LOGGER_DELIMITER_LINE)
113  # stop profiling
114  self.errorCode = dbTask.SQLErrorCode
115  raise DatabaseException(dbTask.SQLErrorString)
116 
117  else:
118  # log message about profiler
119  logger.info(APP_CONSTS.LOGGER_DELIMITER_LINE)
120  except MySQLdb.OperationalError as err: # pylint: disable=E1101
121  ExceptionLog.handler(logger, err, "Aborted cause exception! MySQLdb.OperationalError:")
122  exceptionLogging("Aborted cause exception! MySQLdb.OperationalError {%s}\n" % str(err))
123  self.errorCode = Constants.EXIT_CODE_GLOBAL_ERROR
124  except MySQLdb.Error as err: # pylint: disable=E1101
125  ExceptionLog.handler(logger, err, "Aborted cause exception! Error %d: %s" % (err.args[0], err.args[1]))
126  exceptionLogging("Aborted cause exception! Error %d: %s" % (err.args[0], err.args[1]))
127  self.errorCode = Constants.EXIT_CODE_GLOBAL_ERROR
128  except DatabaseException, err:
129  ExceptionLog.handler(logger, err, "Aborted cause exception! ")
130  exceptionLogging("Aborted cause exception! {%s}\n" % str(err))
131  self.errorCode = Constants.EXIT_CODE_MYSQL_ERROR
132  except Exception as err:
133  ExceptionLog.handler(logger, err, "Aborted cause exception! ")
134  exceptionLogging("Aborted cause exception! {%s}\n" % str(err))
135  self.errorCode = Constants.EXIT_CODE_GLOBAL_ERROR
136  except: # pylint: disable=W0702
137  ExceptionLog.handler(logger, None, "Unknown exception")
138  # log message about profiler
139  logger.info(APP_CONSTS.LOGGER_DELIMITER_LINE)
140  # stop profiling
141  sys.stdout.flush()
142  self.errorCode = APP_CONSTS.EXIT_FAILURE
143  return
144  else:
145  logger.error("Invalid command line arguments. To help - python ./db_task.py -h")
146  sys.stderr.write("Invalid command line arguments. To help - python ./db_task.py -h")
147 
148  # log message about profiler
149  logger.info(APP_CONSTS.LOGGER_DELIMITER_LINE)
150  # stop profiling
151  sys.stdout.flush()
152  self.errorCode = Constants.EXIT_CODE_CONFIG_ERROR
153 
154 
def exceptionLogging(abortStr)
Definition: DBTask.py:43
Here is the call graph for this function:

◆ setup()

def dc_db.DBTask.DBTask.setup (   self)

Definition at line 67 of file DBTask.py.

67  def setup(self):
68  # call base class setup method
69  foundation.CementApp.setup(self)
70 
71 

Member Data Documentation

◆ errorCode

dc_db.DBTask.DBTask.errorCode

drceSyncTasksCoverPickled = sys.stdin.read()

return

Definition at line 61 of file DBTask.py.

◆ errorStr

dc_db.DBTask.DBTask.errorStr

Definition at line 62 of file DBTask.py.


The documentation for this class was generated from the following file: