forked from github/server
Merge branch 'master' into develop
This commit is contained in:
commit
7a59a11c20
6 changed files with 97 additions and 46 deletions
|
@ -1,21 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from email.Utils import parseaddr
|
||||
from email.Parser import Parser
|
||||
import os
|
||||
import os.path
|
||||
import ConfigParser
|
||||
from re import compile, IGNORECASE
|
||||
from stat import ST_MTIME
|
||||
from string import upper, split, replace
|
||||
import string
|
||||
import logging
|
||||
import sys
|
||||
import subprocess
|
||||
from sys import stdin
|
||||
from time import ctime, sleep, time
|
||||
from socket import gethostname
|
||||
from rfc822 import parsedate_tz, mktime_tz
|
||||
import time
|
||||
import socket
|
||||
import rfc822
|
||||
from stat import ST_MTIME
|
||||
from email.Utils import parseaddr
|
||||
from email.Parser import Parser
|
||||
|
||||
if 'ERESSEA' in os.environ:
|
||||
dir = os.environ['ERESSEA']
|
||||
|
@ -50,7 +48,7 @@ else:
|
|||
sender = "%s Server <%s>" % (gamename, frommail)
|
||||
config = None
|
||||
prefix = 'turn-'
|
||||
hostname = gethostname()
|
||||
hostname = socket.gethostname()
|
||||
orderbase = "orders.dir"
|
||||
sendmail = True
|
||||
# maximum number of reports per sender:
|
||||
|
@ -177,7 +175,7 @@ def available_file(dirname, basename):
|
|||
return maxdate, filename
|
||||
|
||||
def formatpar(string, l=76, indent=2):
|
||||
words = split(string)
|
||||
words = string.split(string)
|
||||
res = ""
|
||||
ll = 0
|
||||
first = 1
|
||||
|
@ -223,14 +221,13 @@ def write_part(outfile, part):
|
|||
outfile.write("\n");
|
||||
return True
|
||||
|
||||
def copy_orders(message, filename, sender):
|
||||
def copy_orders(message, filename, sender, mtime):
|
||||
# print the header first
|
||||
dirname, basename = os.path.split(filename)
|
||||
if writeheaders:
|
||||
from os.path import split
|
||||
dirname, basename = split(filename)
|
||||
dirname = dirname + '/headers'
|
||||
if not os.path.exists(dirname): os.mkdir(dirname)
|
||||
outfile = open(dirname + '/' + basename, "w")
|
||||
header_dir = dirname + '/headers'
|
||||
if not os.path.exists(header_dir): os.mkdir(header_dir)
|
||||
outfile = open(header_dir + '/' + basename, "w")
|
||||
for name, value in message.items():
|
||||
outfile.write(name + ": " + value + "\n")
|
||||
outfile.close()
|
||||
|
@ -255,6 +252,7 @@ def copy_orders(message, filename, sender):
|
|||
charset = message.get_content_charset()
|
||||
logger.error("could not write text/plain message (charset=%s) for %s" % (charset, sender))
|
||||
outfile.close()
|
||||
|
||||
return found
|
||||
|
||||
# create a file, containing:
|
||||
|
@ -283,23 +281,31 @@ def accept(game, locale, stream, extend=None):
|
|||
logger.warning("more than " + str(maxfiles) + " orders from " + email)
|
||||
return -1
|
||||
# copy the orders to the file
|
||||
text_ok = copy_orders(message, filename, email)
|
||||
|
||||
warning, msg, fail = None, "", False
|
||||
turndate = None
|
||||
maildate = message.get("Date")
|
||||
if maildate != None:
|
||||
turndate = mktime_tz(parsedate_tz(maildate))
|
||||
if maildate is None:
|
||||
turndate = time.time()
|
||||
else:
|
||||
turndate = rfc822.mktime_tz(rfc822.parsedate_tz(maildate))
|
||||
|
||||
text_ok = copy_orders(message, filename, email, turndate)
|
||||
warning, msg, fail = None, "", False
|
||||
if not maildate is None:
|
||||
os.utime(filename, (turndate, turndate))
|
||||
logger.debug("mail date is '%s' (%d)" % (maildate, turndate))
|
||||
if False and turndate < maxdate:
|
||||
logger.warning("inconsistent message date " + email)
|
||||
warning = " (" + messages["warning-" + locale] + ")"
|
||||
msg = msg + formatpar(messages["maildate-" + locale] % (ctime(maxdate),ctime(turndate)), 76, 2) + "\n"
|
||||
msg = msg + formatpar(messages["maildate-" + locale] % (time.ctime(maxdate), time.ctime(turndate)), 76, 2) + "\n"
|
||||
else:
|
||||
logger.warning("missing message date " + email)
|
||||
warning = " (" + messages["warning-" + locale] + ")"
|
||||
msg = msg + formatpar(messages["nodate-" + locale], 76, 2) + "\n"
|
||||
|
||||
print('ACCEPT_MAIL=' + email)
|
||||
print('ACCEPT_FILE="' + filename + '"')
|
||||
|
||||
if not text_ok:
|
||||
warning = " (" + messages["error-" + locale] + ")"
|
||||
msg = msg + formatpar(messages["multipart-" + locale], 76, 2) + "\n"
|
||||
|
@ -340,10 +346,10 @@ logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME)
|
|||
logger = logging
|
||||
delay = None # TODO: parse the turn delay
|
||||
locale = sys.argv[2]
|
||||
infile = stdin
|
||||
infile = sys.stdin
|
||||
if len(sys.argv)>3:
|
||||
infile = open(sys.argv[3], "r")
|
||||
retval = accept(game, locale, infile, delay)
|
||||
if infile!=stdin:
|
||||
if infile!=sys.stdin:
|
||||
infile.close()
|
||||
sys.exit(retval)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#!/bin/bash
|
||||
(
|
||||
[ "$PREVIEW" != "yes" ] && exit
|
||||
[ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea
|
||||
[ -z "${ERESSEA}" ] && ERESSEA="$HOME/eressea"
|
||||
|
||||
branch="develop"
|
||||
if [ -e ${ERESSEA}/build/.preview ]; then
|
||||
branch=`cat ${ERESSEA}/build/.preview`
|
||||
if [ -e "${ERESSEA}/build/.preview" ]; then
|
||||
branch=$(cat "${ERESSEA}/build/.preview")
|
||||
fi
|
||||
SRC=${ERESSEA}/git
|
||||
${SRC}/s/preview build ${branch} || exit $?
|
||||
for game in 2 3 4 ; do
|
||||
${SRC}/s/preview -g ${game} run && \
|
||||
${SRC}/s/preview -g ${game} send
|
||||
SRC="${ERESSEA}/git"
|
||||
"${SRC}/s/preview" build "$branch" || exit $?
|
||||
for game in "$@" ; do
|
||||
"${SRC}/s/preview" -g "$game" run && \
|
||||
"${SRC}/s/preview" -g "$game" send
|
||||
done
|
||||
) | tee -a $HOME/log/preview.cron.log
|
||||
) | tee -a "$HOME/log/preview.cron.log"
|
||||
|
||||
|
|
|
@ -1,8 +1,25 @@
|
|||
#!/bin/sh
|
||||
SCRIPT=$(readlink -f $0)
|
||||
cd $(dirname $SCRIPT)
|
||||
# example: orders-accept 2 de < mail.txt
|
||||
|
||||
lockfile -r3 -l120 orders.queue.lock
|
||||
python accept-orders.py "$@"
|
||||
rm -f orders.queue.lock
|
||||
game="$1"
|
||||
|
||||
[ -z "$ERESSEA" ] && ERESSEA="$HOME/eressea"
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
BIN=$(dirname "$SCRIPT")
|
||||
|
||||
LOCKFILE="$ERESSEA/game-$game/orders.queue.lock"
|
||||
set -e
|
||||
trap 'rm -f "$LOCKFILE"' EXIT
|
||||
|
||||
cd "$ERESSEA/game-$game"
|
||||
mkdir -p orders.dir
|
||||
cd orders.dir
|
||||
lockfile -r3 -l120 "$LOCKFILE"
|
||||
eval "$(python "$BIN/accept-orders.py" "$@")"
|
||||
rm -f "$LOCKFILE"
|
||||
filename=$(basename "$ACCEPT_FILE")
|
||||
email="$ACCEPT_MAIL"
|
||||
if [ -d "$ERESSEA/orders-php" ]
|
||||
then
|
||||
php "$ERESSEA/orders-php/cli.php" insert "$filename" "$email"
|
||||
fi
|
||||
|
|
|
@ -6,7 +6,7 @@ cd Debug
|
|||
make clean
|
||||
../../coverity/bin/cov-build --dir cov-int make eressea
|
||||
tar czf eressea.tgz cov-int
|
||||
curl --form token=IISXKH3A1ngZGfFmBz_aSA \
|
||||
curl -k --form token=IISXKH3A1ngZGfFmBz_aSA \
|
||||
--form email=enno.rehling@gmail.com \
|
||||
--form file=@eressea.tgz \
|
||||
--form version="$VERSION" \
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
#define FAMILIAR_FIXMAGE_VERSION 364 /* familiar links are fixed */
|
||||
#define FAMILIAR_FIXSPELLBOOK_VERSION 365 /* familiar spells are fixed */
|
||||
#define FIX_STARTLEVEL_VERSION 366 /* fixing resource startlevels */
|
||||
#define FIX_CLONES_VERSION 367 /* dissolve clones */
|
||||
#define FIX_RES_BASE_VERSION 367 /* fixing resource base */
|
||||
#define FIX_CLONES_VERSION 368 /* dissolve clones */
|
||||
|
||||
#define RELEASE_VERSION FIX_CLONES_VERSION /* current datafile */
|
||||
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
|
||||
|
|
|
@ -613,7 +613,7 @@ static void read_regioninfo(gamedata *data, const region *r, char *info, size_t
|
|||
}
|
||||
}
|
||||
|
||||
static void fix_baselevel(region *r) {
|
||||
static void fix_resource_levels(region *r) {
|
||||
struct terrain_production *p;
|
||||
for (p = r->terrain->production; p->type; ++p) {
|
||||
char *end;
|
||||
|
@ -634,6 +634,27 @@ static void fix_baselevel(region *r) {
|
|||
}
|
||||
}
|
||||
|
||||
static void fix_resource_bases(region *r) {
|
||||
struct terrain_production *p;
|
||||
for (p = r->terrain->production; p->type; ++p) {
|
||||
char *end;
|
||||
long base = (int)strtol(p->base, &end, 10);
|
||||
if (*end == '\0') {
|
||||
rawmaterial *res;
|
||||
for (res = r->resources; res; res = res->next) {
|
||||
if (p->type == res->rtype) {
|
||||
if (base != res->base) {
|
||||
log_debug("setting resource base for %s in %s to %d",
|
||||
res->rtype->_name, regionname(r, NULL), base);
|
||||
res->base = base;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static region *readregion(gamedata *data, int x, int y)
|
||||
{
|
||||
region *r;
|
||||
|
@ -803,9 +824,15 @@ static region *readregion(gamedata *data, int x, int y)
|
|||
}
|
||||
read_attribs(data, &r->attribs, r);
|
||||
|
||||
if (r->resources && data->version < FIX_STARTLEVEL_VERSION) {
|
||||
if (r->resources) {
|
||||
if (data->version < FIX_STARTLEVEL_VERSION) {
|
||||
/* we had some badly made rawmaterials before this */
|
||||
fix_baselevel(r);
|
||||
fix_resource_levels(r);
|
||||
}
|
||||
if (data->version < FIX_RES_BASE_VERSION) {
|
||||
/* we had some badly made rawmaterials before this */
|
||||
fix_resource_bases(r);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue