@@ -14,11 +14,6 @@ import sys | |||||
os.chdir("..") | os.chdir("..") | ||||
sys.path.insert(0, ".") | sys.path.insert(0, ".") | ||||
try: | |||||
from toolserver import preconfig | |||||
except ImportError: | |||||
pass | |||||
from mako.template import Template | from mako.template import Template | ||||
from mako.lookup import TemplateLookup | from mako.lookup import TemplateLookup | ||||
@@ -15,8 +15,8 @@ _descurl = None | |||||
def set_background(context, cookies, selected): | def set_background(context, cookies, selected): | ||||
global _descurl | global _descurl | ||||
conn = open_sql_connection(get_bot(), "globals") | conn = open_sql_connection(get_bot(), "globals") | ||||
if "EarwigScreenCache" in cookies: | |||||
cache = cookies["EarwigScreenCache"].value | |||||
if "CopyviosScreenCache" in cookies: | |||||
cache = cookies["CopyviosScreenCache"].value | |||||
try: | try: | ||||
screen = loads(cache) | screen = loads(cache) | ||||
int(screen["width"]) | int(screen["width"]) | ||||
@@ -6,7 +6,7 @@ from datetime import datetime, timedelta | |||||
from os import path | from os import path | ||||
class _CookieManager(SimpleCookie): | class _CookieManager(SimpleCookie): | ||||
MAGIC = "--ets1" | |||||
MAGIC = "--cpv2" | |||||
def __init__(self, environ): | def __init__(self, environ): | ||||
self._path = path.split(environ["PATH_INFO"])[0] | self._path = path.split(environ["PATH_INFO"])[0] | ||||
@@ -47,9 +47,11 @@ def get_bot(): | |||||
def open_sql_connection(bot, dbname): | def open_sql_connection(bot, dbname): | ||||
if dbname in _connections: | if dbname in _connections: | ||||
return _connections[dbname] | return _connections[dbname] | ||||
conn_args = bot.config.wiki["_toolserverSQL"][dbname] | |||||
conn_args = bot.config.wiki["_copyviosSQL"][dbname] | |||||
if "read_default_file" not in conn_args and "user" not in conn_args and "passwd" not in conn_args: | if "read_default_file" not in conn_args and "user" not in conn_args and "passwd" not in conn_args: | ||||
conn_args["read_default_file"] = expanduser("~/.my.cnf") | conn_args["read_default_file"] = expanduser("~/.my.cnf") | ||||
elif "read_default_file" in args: | |||||
args["read_default_file"] = expanduser(args["read_default_file"]) | |||||
if "autoping" not in conn_args: | if "autoping" not in conn_args: | ||||
conn_args["autoping"] = True | conn_args["autoping"] = True | ||||
if "autoreconnect" not in conn_args: | if "autoreconnect" not in conn_args: | ||||
@@ -1,32 +0,0 @@ | |||||
# -*- coding: utf-8 -*- | |||||
""" | |||||
This module contains installation-specific import configuration for the | |||||
Toolserver. To add your own, create and put code in the file 'preconfig.py' in | |||||
this directory, or rename this file to 'preconfig.py' if you want to use this | |||||
specific configuration. | |||||
""" | |||||
import os | |||||
import site | |||||
import sys | |||||
# Add a local platform-specific site package directory: | |||||
plat = sys.platform | |||||
if plat.startswith("sunos"): | |||||
plat = "solaris" | |||||
elif plat.startswith("linux"): | |||||
plat = "linux" | |||||
site.addsitedir(os.path.expanduser("~/.local/" + plat + "/lib/python2.7/site-packages")) | |||||
sys.path.insert(0, os.path.expanduser("~/.local/" + plat + "/lib/python2.7/site-packages")) | |||||
# EarwigBot, in-between releases, tries to import the 'git' module and add the | |||||
# current git commit ID to its __version__ string. This behavior is useful, but | |||||
# the Toolserver can be slow at importing things. Insert a fake 'git' module | |||||
# into sys.modules so it skips the __version__ addition: | |||||
from types import ModuleType | |||||
git = ModuleType("git") | |||||
sys.modules["git"] = git |
@@ -22,17 +22,17 @@ def main(context, environ, headers, cookies): | |||||
def _do_set(query, headers, cookies): | def _do_set(query, headers, cookies): | ||||
changes = set() | changes = set() | ||||
if query.lang: | if query.lang: | ||||
key = "EarwigDefaultLang" | |||||
key = "CopyviosDefaultLang" | |||||
if key not in cookies or cookies[key].value != query.lang: | if key not in cookies or cookies[key].value != query.lang: | ||||
set_cookie(headers, cookies, key, query.lang, 1095) | set_cookie(headers, cookies, key, query.lang, 1095) | ||||
changes.add("site") | changes.add("site") | ||||
if query.project: | if query.project: | ||||
key = "EarwigDefaultProject" | |||||
key = "CopyviosDefaultProject" | |||||
if key not in cookies or cookies[key].value != query.project: | if key not in cookies or cookies[key].value != query.project: | ||||
set_cookie(headers, cookies, key, query.project, 1095) | set_cookie(headers, cookies, key, query.project, 1095) | ||||
changes.add("site") | changes.add("site") | ||||
if query.background: | if query.background: | ||||
key = "EarwigBackground" | |||||
key = "CopyviosBackground" | |||||
if key not in cookies or cookies[key].value != query.background: | if key not in cookies or cookies[key].value != query.background: | ||||
set_cookie(headers, cookies, key, query.background, 1095) | set_cookie(headers, cookies, key, query.background, 1095) | ||||
delete_cookie(headers, cookies, "EarwigBackgroundCache") | delete_cookie(headers, cookies, "EarwigBackgroundCache") | ||||