<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
config.py contains most CONSTANTS in the project
"""
# @author chengdujin
# @contact <EMAIL>
# @created Jan 17, 2013


import sys
reload(sys)
sys.setdefaultencoding('UTF-8')

# SERVICES
import logging

# mongodb client
from pymongo.connection import Connection
from pymongo.database import Database
from pymongo.collection import Collection
from pymongo.errors import CollectionInvalid
con = Connection('127.0.0.1:27017')
db = Database(con, 'news')

# redis rclient
import redis
from redis import ConnectionError
#rclient = redis.StrictRedis(host='10.240.35.40', port=6379)
rclient = redis.StrictRedis(host='127.0.0.1')

# htmlparser to do unescaping
from HTMLParser import HTMLParser
hparser = HTMLParser()


# CONSTANTS
#PUBLIC = 'http://mobile-global.baidu.com/news/%s'  # hk01-hao123-mob01/mob02
#PUBLIC = 'http://192.168.3.11/%s'                   # hk01-hao123-mob00
PUBLIC = 'http://54.251.107.116/%s'                # AWS singapore
#PUBLIC = 'http://54.232.81.44/%s'                  # AWS sao paolo
#PUBLIC = 'http://172.16.17.32/%s'                 # AWS tokyo
#LOCAL = '/home/work/%s'                            # official server prefix
#LOCAL = '/home/ubuntu/%s'                          # AWS server prefix
LOCAL = '/home/jinyuan/Downloads/%s'               # local server prefix

# code base folder for updating
CODE_BASE = LOCAL % 'newsman'

# logging settings
LOG_FORMAT = "%(levelname)-8s %(asctime)-25s %(lineno)-3d:%(filename)-16s %(message)s"
# critical, error, warning, info, debug, notset
logging.basicConfig(format=LOG_FORMAT)
logger = logging.getLogger('news-logger')
logger.setLevel(logging.WARNING)

# paths for generating transcoded files, mp3 and images
TRANSCODED_LOCAL_DIR = LOCAL % 'STATIC/news/ts/'
TRANSCODED_PUBLIC_DIR = PUBLIC % 'ts/'

IMAGES_LOCAL_DIR = LOCAL % 'STATIC/news/img/'
IMAGES_PUBLIC_DIR = PUBLIC % 'img/'

MEDIA_LOCAL_DIR = LOCAL % 'STATIC/news/mid/'
MEDIA_PUBLIC_DIR = PUBLIC % 'mid/'

# path for generating temporary files (used in mp3 download)
MEDIA_TEMP_LOCAL_DIR = LOCAL % 'STATIC/news/tmp/'

# templates for new page
NEWS_TEMPLATE_1 = LOCAL % 'STATIC/news/templates/news1.html'
NEWS_TEMPLATE_2 = LOCAL % 'STATIC/news/templates/news2.html'
NEWS_TEMPLATE_3 = LOCAL % 'STATIC/news/templates/news3.html'
NEWS_TEMPLATE_ARABIC = LOCAL % 'STATIC/news/templates/index_arabic.html'

# uck transcoding web service url
UCK_TRANSCODING = 'http://gate.baidu.com/tc?m=8&from=bdpc_browser&src='
UCK_TRANSCODING_NEW = 'http://m.baidu.com/openapp?/webapp?debug=1&from=bd_international&onlyspdebug=1&structpage&siteType=7&nextpage=1&siteappid=1071361&src='

# meta info for a new page
TRANSCODED_ENCODING = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n'

# words on 'opening origial page' button
TRANSCODING_BTN_EN = 'Original page'
TRANSCODING_BTN_PT = 'Página original'
TRANSCODING_BTN_JA = '元のページ'
TRANSCODING_BTN_IND = 'Laman Asli'
TRANSCODING_BTN_TH = 'หน้าเดิม'
TRANSCODING_BTN_AR = 'ﺎﻠﻤﺻﺩﺭ'
TRANSCODING_BTN_ZH_CN = '查看原始网页'
TRANSCODING_BTN_ZH_HK = '查看原始鏈接'

# hot news title
HOTNEWS_TITLE_EN = 'Hot News'
HOTNEWS_TITLE_PT = 'Notícias Quentes'
HOTNEWS_TITLE_JA = '人気ニュース'
HOTNEWS_TITLE_IND = 'Berita Terbaru'
HOTNEWS_TITLE_TH = 'ข่าวฮิต'
HOTNEWS_TITLE_AR = 'أخبار عاجلة'
HOTNEWS_TITLE_ZH_CN = '查看原始网页'
HOTNEWS_TITLE_ZH_HK = '查看原始鏈接'

# expirations 
DATABASE_REMOVAL_DAYS = 365
FEED_UPDATE_DAYS = 2
MEMORY_RESTORATION_DAYS = 20
MEMORY_EXPIRATION_DAYS = 20

# database names for feeds
FEED_REGISTRAR = 'feeds'

# settings used in summarizing
PARAGRAPH_CRITERIA = 40
SUMMARY_LENGTH_LIMIT = 500

# request connection timeouts
UCK_TIMEOUT = 40  # 14 seconds timeout
GOOGLE_TTS_TIMEOUT = 120  # 2 minutes timeout

# supported languages
LANGUAGES = ['en', 'th', 'ind', 'ja', 'pt', 'en-rIN', 'ar', 'zh-CN', 'zh-HK']

# sizes for generating images
MIN_IMAGE_SIZE = 150, 150
THUMBNAIL_STYLE = 1.4
THUMBNAIL_LANDSCAPE_SIZE_HIGH = 600, 226
THUMBNAIL_LANDSCAPE_SIZE_NORMAL = 450, 169
THUMBNAIL_LANDSCAPE_SIZE_LOW = 230, 85
THUMBNAIL_PORTRAIT_SIZE_HIGH = 310, 400
THUMBNAIL_PORTRAIT_SIZE_NORMAL = 175, 210
THUMBNAIL_PORTRAIT_SIZE_LOW = 90, 110
CATEGORY_IMAGE_SIZE = 310, 250
HOT_IMAGE_SIZE = 600, 250<commit_msg>Update image size in config.py<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
config.py contains most CONSTANTS in the project
"""
# @author chengdujin
# @contact <EMAIL>
# @created Jan 17, 2013


import sys
reload(sys)
sys.setdefaultencoding('UTF-8')

# SERVICES
import logging

# mongodb client
from pymongo.connection import Connection
from pymongo.database import Database
from pymongo.collection import Collection
from pymongo.errors import CollectionInvalid
con = Connection('127.0.0.1:27017')
db = Database(con, 'news')

# redis rclient
import redis
from redis import ConnectionError
#rclient = redis.StrictRedis(host='10.240.35.40', port=6379)
rclient = redis.StrictRedis(host='127.0.0.1')

# htmlparser to do unescaping
from HTMLParser import HTMLParser
hparser = HTMLParser()


# CONSTANTS
#PUBLIC = 'http://mobile-global.baidu.com/news/%s'  # hk01-hao123-mob01/mob02
#PUBLIC = 'http://192.168.3.11/%s'                   # hk01-hao123-mob00
PUBLIC = 'http://172.16.31.10/%s'                # AWS singapore
#PUBLIC = 'http://192.168.3.11/%s'                  # AWS sao paolo
#PUBLIC = 'http://5172.16.58.3/%s'                 # AWS tokyo
#LOCAL = '/home/work/%s'                            # official server prefix
#LOCAL = '/home/ubuntu/%s'                          # AWS server prefix
LOCAL = '/home/jinyuan/Downloads/%s'               # local server prefix

# code base folder for updating
CODE_BASE = LOCAL % 'newsman'

# logging settings
LOG_FORMAT = "%(levelname)-8s %(asctime)-25s %(lineno)-3d:%(filename)-16s %(message)s"
# critical, error, warning, info, debug, notset
logging.basicConfig(format=LOG_FORMAT)
logger = logging.getLogger('news-logger')
logger.setLevel(logging.WARNING)

# paths for generating transcoded files, mp3 and images
TRANSCODED_LOCAL_DIR = LOCAL % 'STATIC/news/ts/'
TRANSCODED_PUBLIC_DIR = PUBLIC % 'ts/'

IMAGES_LOCAL_DIR = LOCAL % 'STATIC/news/img/'
IMAGES_PUBLIC_DIR = PUBLIC % 'img/'

MEDIA_LOCAL_DIR = LOCAL % 'STATIC/news/mid/'
MEDIA_PUBLIC_DIR = PUBLIC % 'mid/'

# path for generating temporary files (used in mp3 download)
MEDIA_TEMP_LOCAL_DIR = LOCAL % 'STATIC/news/tmp/'

# templates for new page
NEWS_TEMPLATE_1 = LOCAL % 'STATIC/news/templates/news1.html'
NEWS_TEMPLATE_2 = LOCAL % 'STATIC/news/templates/news2.html'
NEWS_TEMPLATE_3 = LOCAL % 'STATIC/news/templates/news3.html'
NEWS_TEMPLATE_ARABIC = LOCAL % 'STATIC/news/templates/index_arabic.html'

# uck transcoding web service url
UCK_TRANSCODING = 'http://gate.baidu.com/tc?m=8&from=bdpc_browser&src='
UCK_TRANSCODING_NEW = 'http://m.baidu.com/openapp?/webapp?debug=1&from=bd_international&onlyspdebug=1&structpage&siteType=7&nextpage=1&siteappid=1071361&src='

# meta info for a new page
TRANSCODED_ENCODING = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n'

# words on 'opening origial page' button
TRANSCODING_BTN_EN = 'Original page'
TRANSCODING_BTN_PT = 'Página original'
TRANSCODING_BTN_JA = '元のページ'
TRANSCODING_BTN_IND = 'Laman Asli'
TRANSCODING_BTN_TH = 'หน้าเดิม'
TRANSCODING_BTN_AR = 'ﺎﻠﻤﺻﺩﺭ'
TRANSCODING_BTN_ZH_CN = '查看原始网页'
TRANSCODING_BTN_ZH_HK = '查看原始鏈接'

# hot news title
HOTNEWS_TITLE_EN = 'Hot News'
HOTNEWS_TITLE_PT = 'Notícias Quentes'
HOTNEWS_TITLE_JA = '人気ニュース'
HOTNEWS_TITLE_IND = 'Berita Terbaru'
HOTNEWS_TITLE_TH = 'ข่าวฮิต'
HOTNEWS_TITLE_AR = 'أخبار عاجلة'
HOTNEWS_TITLE_ZH_CN = '查看原始网页'
HOTNEWS_TITLE_ZH_HK = '查看原始鏈接'

# expirations 
DATABASE_REMOVAL_DAYS = 365
FEED_UPDATE_DAYS = 2
MEMORY_RESTORATION_DAYS = 20
MEMORY_EXPIRATION_DAYS = 20

# database names for feeds
FEED_REGISTRAR = 'feeds'

# settings used in summarizing
PARAGRAPH_CRITERIA = 40
SUMMARY_LENGTH_LIMIT = 500

# request connection timeouts
UCK_TIMEOUT = 40  # 14 seconds timeout
GOOGLE_TTS_TIMEOUT = 120  # 2 minutes timeout

# supported languages
LANGUAGES = ['en', 'th', 'ind', 'ja', 'pt', 'en-rIN', 'ar', 'zh-CN', 'zh-HK']

# sizes for generating images
MIN_IMAGE_SIZE = 150, 150
THUMBNAIL_STYLE = 1.4
THUMBNAIL_LANDSCAPE_SIZE_HIGH = 600, 226
THUMBNAIL_LANDSCAPE_SIZE_NORMAL = 450, 169
THUMBNAIL_LANDSCAPE_SIZE_LOW = 230, 85
THUMBNAIL_PORTRAIT_SIZE_HIGH = 310, 400
THUMBNAIL_PORTRAIT_SIZE_NORMAL = 175, 210
THUMBNAIL_PORTRAIT_SIZE_LOW = 90, 110
CATEGORY_IMAGE_SIZE = 300, 200
HOT_IMAGE_SIZE = 600, 226
{'fraction_non_alphanumeric': 0.12002832526849994, 'fraction_numerical': 0.04555647350407176, 'mean_word_length': 4.6644385026737964, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 14, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2924025', 'n_tokens_mistral': 3745, 'n_tokens_neox': 3331, 'n_words': 671}