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
response_extractor.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 """
4 HCE project, Python bindings, DC service utility
5 Response extractor utility to extract fields from URL_CONTENT responses.
6 
7 @package: dc
8 @file digest.py
9 @author bgv <developers.hce@gmail.com>
10 @link: http://hierarchical-cluster-engine.com/
11 @copyright: Copyright &copy; 2015 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 app.ResponseExtractor import ResponseExtractor
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 = ResponseExtractor()
46  # setup the application
47  app.setup()
48  # run the application
49  app.run()
50  # get exit code
51  exit_code = app.exitCode
52  # log message about profiler
53  if pr.errorMsg and app.logger is not None:
54  app.logger.error(pr.errorMsg)
55  except Exception as err:
56  sys.stderr.write(str(err) + '\n')
57  exit_code = APP_CONSTS.EXIT_FAILURE
58  except:
59  exit_code = APP_CONSTS.EXIT_FAILURE
60  finally:
61  # stop profiling
62  if pr:
63  pr.stop()
64  # close the app
65  if app:
66  app.close()
67 
68  sys.stdout.flush()
69  os._exit(exit_code)
ResponseExtractor Class main functional, class inherits from foundation.CementApp.