config.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env python
  2. #coding=utf-8
  3. from __future__ import with_statement
  4. import sys
  5. import os
  6. import datetime
  7. import time
  8. import ConfigParser
  9. # 读取配置文件
  10. try:
  11. config = ConfigParser.ConfigParser()
  12. with open(os.path.expanduser('~') + '/huoju_fty_home/config.cfg', 'rw') as f:
  13. config.readfp(f)
  14. except IOError, e:
  15. print e
  16. sys.exit(1)
  17. class APP_CFG(object):
  18. OFFLINE_CONFIG_HOST = config.get('offline_config', 'host')
  19. OFFLINE_CONFIG_USER = config.get('offline_config', 'user')
  20. OFFLINE_CONFIG_PASSWORD = config.get('offline_config', 'password')
  21. OFFLINE_CONFIG_PORT = config.get('offline_config', 'port')
  22. ONLINE_CONFIG_HOST = config.get('online_config', 'host')
  23. ONLINE_CONFIG_USER = config.get('online_config', 'user')
  24. ONLINE_CONFIG_PASSWORD = config.get('online_config', 'password')
  25. ONLINE_CONFIG_PORT = config.get('online_config', 'port')
  26. SCRAPY_CONFIG_HOST = config.get('scrapy_config', 'host')
  27. SCRAPY_CONFIG_USER = config.get('scrapy_config', 'user')
  28. SCRAPY_CONFIG_PASSWORD = config.get('scrapy_config', 'password')
  29. SCRAPY_CONFIG_PORT = config.get('scrapy_config', 'port')
  30. # # 离线数据库配置
  31. # OFFLINE_CONFIG = config.get('info', 'offline_config')
  32. # # 在线数据库配置
  33. # ONLINE_CONFIG = config.get('info', 'online_config')
  34. # # 电视台收视率统计路径
  35. # AD_TELEVISION_STAT_PATH = config.get('info', 'tmp_path') + 'ad_television_stat.txt'
  36. # # 备案发行数据路径
  37. # AD_TV_RECORD_DISTRIBUTION_PATH = config.get('info', 'tmp_path') + 'ad_tv_record_distribution.txt'
  38. # # 趋势路径
  39. # TRENDING_PATH = config.get('info', 'tmp_path') + 'trending.txt'
  40. # # 收视预测路径
  41. # TV_STATION_RATINGS_STAT_PATH = config.get('info', 'tmp_path') + 'tv_station_ratings_stat.txt'
  42. # # 推荐结果路径
  43. # TV_STATION_RECOMMEND_PATH = config.get('info', 'tmp_path') + 'tv_station_recommend.txt'
  44. # # 类型预测路径
  45. # TV_STATION_TYPE_STAT_PATH = config.get('info', 'tmp_path') + 'tv_station_type_stat.txt'