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
content_updater.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 Content updater main functional.
7 
8 @package: app
9 @file content_updater.py
10 @author Alexander Vybornyh <alexander.hce.cluster@gmail.com>
11 @link: http://hierarchical-cluster-engine.com/
12 @copyright: Copyright &copy; 2013-2016 IOIX Ukraine
13 @license: http://hierarchical-cluster-engine.com/license/
14 @since: 0.1
15 """
16 
17 import ppath
18 from ppath import sys
19 
20 import os
21 import sys
22 import app.Utils as Utils
23 import app.Consts as APP_CONSTS
24 
25 from app.ContentUpdater import ContentUpdater
26 
27 
28 app = None
29 exit_code = APP_CONSTS.EXIT_FAILURE
30 
31 if __name__ == "__main__":
32  try:
33  # create the app
34  app = ContentUpdater()
35  # setup the application
36  app.setup()
37  # add support command line arguments
38  app.args.add_argument('-c', '--config', action='store', metavar='config_file', help='config ini-file',
39  required=True)
40  app.args.add_argument('-e', '--error', action='store', metavar='error_message', help='input error message',
41  required=False)
42 
43  # run the application
44  app.run()
45 
46  # get exit code
47  exit_code = app.exitCode
48 
49  except Exception, err:
50  sys.stderr.write(str(err) + '\n')
51  exit_code = APP_CONSTS.EXIT_FAILURE
52  except:
53  exit_code = APP_CONSTS.EXIT_FAILURE
54  finally:
55  # close the app
56  if app:
57  app.close()
58 
59  sys.stdout.flush()
60  os._exit(exit_code)