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
processor_feed_parser.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: dc
9 @file processor_feed_parser.py
10 @author Oleksii, bgv <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 
18 import ppath
19 from ppath import sys
20 
21 # For profiling
22 import app.Profiler as Profiler
23 
24 
25 # Start profiling
26 pr = Profiler.Profiler()
27 if pr and pr.status > 0:
28  pr.start()
29 
30 
31 import os
32 from dc_processor.ProcessorFeedParser import ProcessorFeedParser
33 import dc_processor.Constants as CONSTS
34 import app.Consts as APP_CONSTS
35 
36 
37 # That script create main application
38 
39 
40 app = None
41 exit_code = CONSTS.EXIT_SUCCESS
42 
43 try:
44  # create the app
45  app = ProcessorFeedParser()
46  # setup the application
47  app.setup()
48  app.args.add_argument('-c', '--config', action='store', metavar='config_file', help='.ini file required',
49  required=True)
50  # run the application
51  app.run()
52 
53  exit_code = app.getExitCode()
54 
55  # log message about profiler
56  if pr.errorMsg:
57  app.logger.error(pr.errorMsg)
58 
59 except Exception as err:
60  sys.stderr.write(str(err))
61  exit_code = CONSTS.EXIT_FAILURE
62 except:
63  exit_code = APP_CONSTS.EXIT_FAILURE
64 finally:
65  # stop profiling
66  if pr:
67  pr.stop()
68  # close the app
69  if app:
70  app.close()
71 
72  sys.stdout.flush()
73  os._exit(exit_code)