# # config.py - Configuration. # Copyright (c) 2005 shinGETsu Project. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $Id: config.py,v 1.50 2005/06/22 08:01:08 fuktommy Exp $ # import os.path import sys import ConfigParser __version__ = "$Revision: 1.50 $" def get_value(parser, key, default, vtype=""): """Get config value or default value.""" try: if vtype == "int": return parser.getint("SAKU", key) elif vtype == "path": return os.path.expanduser(parser.get("SAKU", key)) else: return parser.get("SAKU", key) except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): return default # External config files. config_files = ["file/saku.ini", "/usr/local/etc/saku.ini", "/etc/saku.ini", os.path.expanduser("~/.saku/saku.ini")] extconf = ConfigParser.SafeConfigParser() extconf.read(config_files) port = get_value(extconf, "port", 8000, "int") tklog = get_value(extconf, "tklog", 100, "int") admin = get_value(extconf, "admin", r"^127") docroot = get_value(extconf, "docroot", "./www", "path") log_dir = get_value(extconf, "log_dir", "./log", "path") run_dir = get_value(extconf, "run_dir", "../run", "path") file_dir = get_value(extconf, "file_dir", "../file", "path") cache_dir = get_value(extconf, "cache_dir", "../cache", "path") client_cycle = 5*60 # Seconds; Access client.cgi ping_cycle = 5*60 # Seconds; Check nodes sync_cycle = 60*60 # Seconds; Check cache init_cycle = 20*60 # Seconds; Check initial node update_range = 3*24*60*60 # Seconds rss_range = 3*24*60*60 # Seconds wait_update = 10 # Seconds time_error = 60 # Seconds search_timeout = 10*60 # Seconds timeout = 20 # Seconds; Timeout for TCP get_timeout = 2*60 # Seconds; Timeout for /get client_timeout = 30*60 # Seconds; client_timeout < sync_cycle retry = 5 # Times; Common setting nodes = 5 # Nodes keeping in node list search_depth = 30 # Search node size file_limit = 10 # MegaBytes; File size limit broadcast = "../tool/broadcast.py" # Broadcast script path rss = "1" # 1/2; RSS version google = "http://www.google.co.jp/search" language = "en" # Language code (see RFC3066) robot = r"Google|bot|Yahoo|archiver|Wget" # regexp dnsname = "" # Server name menu = "menu" # File name for /list.cgi query_separator = "/" # Charactor for foo.cgi[/?]bar root_path = "/" # path of URI for root motd = file_dir + "/motd.txt" node = run_dir + "/node.txt" search = run_dir + "/search.txt" update = run_dir + "/update.txt" client_log = run_dir + "/client.txt" lock = run_dir + "/lock.txt" search_lock = run_dir + "/touch.txt" server = root_path + "server.cgi" client = root_path + "client.cgi" gateway = root_path + "gateway.cgi" list_cgi = root_path + "list.cgi" thread_cgi = root_path + "thread.cgi" note_cgi = root_path + "note.cgi" admin_cgi = root_path + "admin.cgi" css = root_path + "default.css" types = ("list", "thread", "note") # Application types application = {"list": list_cgi, "thread": thread_cgi, "note": note_cgi} limit_rec = {"list": 100} save_record = {"list": 100*366*24*60*60, # Seconds; 0 for infinity "thread": 100*366*24*60*60, # Seconds; 0 for infinity "note": 100*31*24*60*60} # Seconds; 0 for infinity get_range = {"thread": 366*24*60*60} # Seconds; 0 for infinity sync_range = {"list": 31*24*60*60, # Seconds; 0 for infinity "thread": 3*10*24*60*60, # Seconds; 0 for infinity "note": 10*24*60*60} # Seconds; 0 for infinity save_removed = {"list": 1000*50*24*60*60, # Seconds; 0 for infinity "thread": 1000*50*24*60*60, # Seconds; 0 for infinity "note": 1000*50*24*60*60} # Seconds; 0 for infinity version = "shinGETsu/0.5 (Saku/0.5.1)" init_node = ["shingetsu.xrea.jp:80/node.cgi", "fuktommy.ddo.jp:8000/server.cgi", "feeling.zive.net:8000/server.cgi", "pushare.zenno.info:8000/server.cgi"] ignore_search_node = ["shingetsu.xrea.jp:80/node.cgi"] flags = [] # It is set by script