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
crawling-optimiser.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 
4 """
5  HCE project, Python bindings, Processor Manager application.
6  Event objects definitions.
7 
8  @package: dc
9  @file crawling-optimiser.py
10  @author Oleksii <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 # crontab -e
19 # */5 * * * * cd ~/hce-node-bundle/api/python/ftests && ./crawling-optimiser.py -s=rss
20 
21 
22 import ppath
23 from ppath import sys
24 
25 # For profiling
26 import app.Profiler as Profiler
27 
28 
29 # Start profiling
30 pr = Profiler.Profiler()
31 if pr and pr.status > 0:
32  pr.start()
33 
34 
35 import os
36 from dc_co.CrawlingOptimiser import CrawlingOptimiser
37 import app.Consts as APP_CONSTS
38 
39 
40 # That script create main application
41 
42 
43 app = None
44 exit_code = APP_CONSTS.EXIT_SUCCESS
45 
46 try:
47  # create the app
48  app = CrawlingOptimiser()
49  # setup the application
50  app.setup()
51  # run the application
52  app.run()
53 
54  exit_code = app.exit_code
55 
56  # log message about profiler
57  if pr.errorMsg:
58  app.logger.error(pr.errorMsg)
59 
60 except Exception as err:
61  sys.stderr.write(str(err))
62  exit_code = APP_CONSTS.EXIT_FAILURE
63 finally:
64  # stop profiling
65  if pr:
66  pr.stop()
67  # close the app
68  if app:
69  app.close()
70 
71  sys.stdout.flush()
72  os._exit(exit_code)