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