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
rtc-finalizer.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 """
4 HCE project, Python bindings, Distributed Tasks Manager application.
5 RTCFinalizer Class content main functional for finalize realtime crawling.
6 
7 @package: dc
8 @file rtc-finalizer.py
9 @author Oleksii <developers.hce@gmail.com>, bgv, Alexander Vybornyh <alexander.hce.cluster@gmail.com>
10 @link: http://hierarchical-cluster-engine.com/
11 @copyright: Copyright &copy; 2013-2015 IOIX Ukraine
12 @license: http://hierarchical-cluster-engine.com/license/
13 @since: 0.1
14 """
15 
16 import ppath
17 from ppath import sys
18 
19 # For profiling
20 import app.Profiler as Profiler
21 
22 
23 # Start profiling
24 pr = Profiler.Profiler()
25 if pr and pr.status > 0:
26  pr.start()
27 
28 
29 import pickle
30 import os
31 import sys
32 import app.Utils as Utils # pylint: disable=F0401
33 import app.Consts as APP_CONSTS
34 
35 from dc_crawler.RTCFinalizer import RTCFinalizer
36 
37 
38 # That script create main rtc-finalizer application
39 
40 
41 app = None
42 exit_code = APP_CONSTS.EXIT_SUCCESS
43 
44 if __name__ == "__main__":
45  try:
46  # create the app
47  app = RTCFinalizer()
48  # setup the application
49  app.setup()
50  # add support command line arguments
51  app.args.add_argument('-c', '--config', action='store', metavar='config_file', help='config ini-file',
52  required=True)
53  app.args.add_argument('-rb', '--rb', action='store', metavar='bacth_file', help='batch output file',
54  required=False)
55  app.args.add_argument('-rc', '--rc', action='store', metavar='special_exit_code', help='special exit code',
56  required=False)
57  # run the application
58  app.run()
59 
60  # get exit code
61  exit_code = app.exitCode
62 
63  # log message about profiler
64  if pr.errorMsg and app.logger:
65  app.logger.error(pr.errorMsg)
66 
67  except Exception as err:
68  sys.stderr.write(str(err) + '\n')
69  exit_code = APP_CONSTS.EXIT_FAILURE
70  except:
71  exit_code = APP_CONSTS.EXIT_FAILURE
72  finally:
73  # stop profiling
74  if pr:
75  pr.stop()
76  # close the app
77  if app:
78  app.close()
79 
80  sys.stdout.flush()
81  os._exit(exit_code)