summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2012-07-08 14:56:58 +0000
committerMagnus Hagander2012-07-08 14:56:58 +0000
commite153cd808e9b1239587bc3219772da7c59e11435 (patch)
treefeb74b797bdbf0c3ddc5a80f8d42e54de6f32315
parent028ab9874d49b68abaf15b226208c71446547813 (diff)
Optionally subscribe users to the mailing lists as well, don't just detect they're missing
-rwxr-xr-xloader/mj2_subscriber_sync.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/loader/mj2_subscriber_sync.py b/loader/mj2_subscriber_sync.py
index cd3ba8d..68fd5e3 100755
--- a/loader/mj2_subscriber_sync.py
+++ b/loader/mj2_subscriber_sync.py
@@ -24,7 +24,34 @@ def ensure_subscribed(listname):
f.close()
if s.find("No matching addresses were found") > 0:
print "User %s@%s is not subscribed to list %s" % (listname, cfg.get('mail', 'server'), listname)
- return False
+ if os.isatty(sys.stdout.fileno()):
+ while True:
+ x = raw_input("Attempt to subscribe? ")
+ if x.upper() == 'N': return False
+ if x.upper() != 'Y': continue
+ u = 'http://%s/mj/mj_wwwadm?%s' % (cfg.get('majordomo','server'), urlencode((
+ ('passw', cfg.get('majordomo', 'password')),
+ ('list', listname),
+ ('func', 'subscribe-set-nowelcome'),
+ ('setting', 'hideaddress'),
+ ('setting', 'hideall'),
+ ('setting', 'postblock'),
+ ('setting', 'selfcopy'),
+ ('setting', 'each'),
+ ('victims', '%s@%s' % (listname, cfg.get('mail', 'server'))),
+ )))
+ f = urlopen(u)
+ s = f.read()
+ f.close()
+ if s.find("%s@%s was added to the %s mailing list." % (
+ listname,
+ cfg.get('mail', 'server'),
+ listname)) > 0:
+ print "SUCCESS!"
+ return True
+ else:
+ print "FAILED to add the subscriber!"
+ return False
# Wow this is ugly - but regexps are useful
m = re.search('Addresses found: (\d+)\s', s)