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
ftest_exit_code.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 
54  # run the application
55  app.run()
56 
57  # get exit code
58  exit_code = app.exitCode
59 
60  # log message about profiler
61  if pr.errorMsg and app.logger:
62  app.logger.error(pr.errorMsg)
63 
64  except Exception as err:
65  sys.stderr.write(str(err) + '\n')
66  exit_code = 111#APP_CONSTS.EXIT_FAILURE
67  except:
68  exit_code = 111#APP_CONSTS.EXIT_FAILURE
69  finally:
70  # close the app
71  if app:
72  app.close()
73  # stop profiling
74  if pr:
75  pr.stop()
76 
77  sys.stdout.flush()
78  os._exit(exit_code)