aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-04-06 17:29:23 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2015-04-06 17:29:23 +0300
commitabb844aafca17ed8cdf04f08efaca3a19c477c8a (patch)
tree590b150f8825562f3fa6e201d296bf772f59382d /bin
parent89a4c6bc634fe93254f738b9cb885eb2f88f8502 (diff)
downloadmailman-abb844aafca17ed8cdf04f08efaca3a19c477c8a.tar.gz
mailman-abb844aafca17ed8cdf04f08efaca3a19c477c8a.tar.bz2
Fix in mailsync
* bin/mailsync (get_state): Strip trailing whitespace (save_state): Write newline. (save_timestamp): New function. (mboxtohtml): Write .timestamp file
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mailsync16
1 files changed, 13 insertions, 3 deletions
diff --git a/bin/mailsync b/bin/mailsync
index 5aa796d..555b4da 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -46,7 +46,7 @@ def get_state(listid):
file = conf['htmlrootdir'] + "/" + listid + "/.state"
try:
with open(file, 'r') as f:
- r = int(f.readline())
+ r = int(f.readline().rstrip())
except:
r = 0
return r
@@ -55,7 +55,15 @@ def save_state(listid,n):
file = conf['htmlrootdir'] + "/" + listid + "/.state"
try:
with open(file, 'w') as f:
- f.write(str(n + 1))
+ f.write(str(n + 1) + "\n")
+ except:
+ print("cannot write %s: %s" % (file,sys.exc_info()), file=sys.stderr)
+
+def save_timestamp(listid,ts):
+ file = conf['htmlrootdir'] + "/" + listid + "/.timestamp"
+ try:
+ with open(file, 'w') as f:
+ f.write(strftime('%s', ts) + "\n")
except:
print("cannot write %s: %s" % (file,sys.exc_info()), file=sys.stderr)
@@ -66,12 +74,12 @@ def mboxtohtml(listid):
n = 0
else:
n = get_state(listid)
+ t = 0
for message in inbox.values()[n:]:
n += 1
frm = message.get_from()
s = frm.split(' ', 1)
t = strptime(s[1], '%a %b %d %H:%M:%S %Y')
- timestamp = strftime('%s', t)
period = strftime('%Y-%m', t)
periodh = strftime('%B, %Y', t)
dirname = conf['htmlrootdir'] + "/" + listid + "/" + period
@@ -100,6 +108,8 @@ def mboxtohtml(listid):
print("\"%s\": %s" % (str(cmd), err), file=sys.stderr)
save_state(listid, n)
+ if t > 0:
+ save_timestamp(listid, t)
def savane_lists(file):
with open(file, 'r') as f:

Return to:

Send suggestions and report system problems to the System administrator.