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
postprocessor_task.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 """
4 HCE project, Python bindings, Distributed Tasks Manager application.
5 Social data rate main functional.
6 
7 @package: dc_processor
8 @file postprocessor_task.py
9 @author Alexander Vybornyh <alexander.hce.cluster@gmail.com>
10 @link: http://hierarchical-cluster-engine.com/
11 @copyright: Copyright &copy; 2013-2017 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 import os
29 import sys
30 import app.Utils as Utils
31 import app.Consts as APP_CONSTS
32 
33 from dc_postprocessor.PostprocessorTask import PostprocessorTask
34 
35 
36 # That script create main urls-to-batch-task application
37 
38 
39 app = None
40 exit_code = APP_CONSTS.EXIT_FAILURE
41 
42 if __name__ == "__main__":
43  try:
44  # create the app
45  app = PostprocessorTask()
46  # setup the application
47  app.setup()
48  # add support command line arguments
49  app.args.add_argument('-c', '--config', action='store', metavar='config_file', help='config ini-file',
50  required=True)
51  app.args.add_argument('-i', '--inputFile', action='store', metavar='input_pickle_file', help='input pickle file',
52  required=False)
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, err:
65  sys.stderr.write(str(err) + '\n')
66  exit_code = APP_CONSTS.EXIT_FAILURE
67  except:
68  exit_code = APP_CONSTS.EXIT_FAILURE
69  finally:
70  # stop profiling
71  if pr:
72  pr.stop()
73  # close the app
74  if app:
75  app.close()
76 
77  sys.stdout.flush()
78  os._exit(exit_code)