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
dtm-admin.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 
4 """
5 HCE project, Python bindings, Distributed Tasks Manager application.
6 Event objects definitions.
7 
8 @package: dtm
9 @file dtm-client.py
10 @author Oleksii <developers.hce@gmail.com>
11 @link: http://hierarchical-cluster-engine.com/
12 @copyright: Copyright &copy; 2013-2014 IOIX Ukraine
13 @license: http://hierarchical-cluster-engine.com/license/
14 @since: 0.1
15 """
16 
17 import ppath
18 from ppath import sys
19 
20 # For profiling
21 import app.Profiler as Profiler
22 
23 
24 # Start profiling
25 pr = Profiler.Profiler()
26 if pr and pr.status > 0:
27  pr.start()
28 
29 
30 from dtma.DTMA import DTMA
31 import dtma.DTMA
32 import os
33 import sys
34 import logging.config
35 
36 from app.Consts import EXIT_SUCCESS
37 from app.Consts import EXIT_FAILURE
38 import app.Consts as APP_CONSTS
39 
40 
41 # That script create main crawler application
42 
43 
44 app = None
45 exit_code = EXIT_SUCCESS
46 
47 try:
48  # create the app
49  app = DTMA()
50 
51  # setup the application
52  app.setup()
53  # add support command line arguments
54  app.args.add_argument("-c", "--config", action="store", required=True)
55  app.args.add_argument("-cmd", "--cmd", action="store", required=True)
56  app.args.add_argument("-fields", "--fields", action="store")
57  app.args.add_argument("-classes", "--classes", action="store")
58 
59  # run the application
60  app.run()
61 
62  exit_code = app.errorCode
63 
64  # log message about profiler
65  if pr.errorMsg and dtma.DTMA.logger:
66  dtma.DTMA.logger.error(pr.errorMsg)
67 
68 except Exception as err:
69  if dtma.DTMA.logger:
70  dtma.DTMA.logger.error(str(err))
71  exit_code = EXIT_FAILURE
72 except:
73  exit_code = EXIT_FAILURE
74 finally:
75  # stop profiling
76  if pr:
77  pr.stop()
78  # close the app
79  if app:
80  app.close()
81 
82  sys.stdout.flush()
83  os._exit(exit_code)
84 
DTMA Class contents main functional of DTMA application, class inherits from foundation.CementApp.
Definition: DTMA.py:36
Definition: DTMA.py:1