projects
/
git-mirror.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b13f671
)
configure sender of mails
author
Ralf Jung
<post@ralfj.de>
Sun, 22 Feb 2015 19:49:51 +0000
(20:49 +0100)
committer
Ralf Jung
<post@ralfj.de>
Sun, 22 Feb 2015 19:49:51 +0000
(20:49 +0100)
git_mirror.py
patch
|
blob
|
history
diff --git
a/git_mirror.py
b/git_mirror.py
index ab8699e2e4f89700f94ad49343fe111acef31635..636672f466ab1743fa0155e411cf4d18b73c86cd 100644
(file)
--- a/
git_mirror.py
+++ b/
git_mirror.py
@@
-25,6
+25,8
@@
import sys, os, subprocess
import configparser, itertools, json, re
import email.mime.text, email.utils, smtplib
import configparser, itertools, json, re
import email.mime.text, email.utils, smtplib
+mail_sender = "null@localhost"
+
class GitCommand:
def __getattr__(self, name):
def call(*args, capture_stderr = False, check = True):
class GitCommand:
def __getattr__(self, name):
def call(*args, capture_stderr = False, check = True):
@@
-58,20
+60,20
@@
def read_config(fname, defSection = 'DEFAULT'):
config.read_file(stream)
return config
config.read_file(stream)
return config
-def send_mail(subject, text, rec
eivers, sender='post+webhook@ralfj.de', replyTo=
None):
- assert isinstance(rec
eiver
s, list)
- if not len(rec
eiver
s): return # nothing to do
+def send_mail(subject, text, rec
ipients, sender, replyTo =
None):
+ assert isinstance(rec
ipient
s, list)
+ if not len(rec
ipient
s): return # nothing to do
# construct content
msg = email.mime.text.MIMEText(text.encode('UTF-8'), 'plain', 'UTF-8')
msg['Subject'] = subject
msg['Date'] = email.utils.formatdate(localtime=True)
msg['From'] = sender
# construct content
msg = email.mime.text.MIMEText(text.encode('UTF-8'), 'plain', 'UTF-8')
msg['Subject'] = subject
msg['Date'] = email.utils.formatdate(localtime=True)
msg['From'] = sender
- msg['To'] = ', '.join(rec
eiver
s)
+ msg['To'] = ', '.join(rec
ipient
s)
if replyTo is not None:
msg['Reply-To'] = replyTo
# put into envelope and send
s = smtplib.SMTP('localhost')
if replyTo is not None:
msg['Reply-To'] = replyTo
# put into envelope and send
s = smtplib.SMTP('localhost')
- s.sendmail(sender, rec
eiver
s, msg.as_string())
+ s.sendmail(sender, rec
ipient
s, msg.as_string())
s.quit()
def get_github_payload():
s.quit()
def get_github_payload():
@@
-96,7
+98,8
@@
class Repo:
self.mirrors[mirror] = conf[name]
def mail_owner(self, msg):
self.mirrors[mirror] = conf[name]
def mail_owner(self, msg):
- send_mail("git-mirror {0}".format(self.name), msg, [self.owner])
+ global mail_sender
+ send_mail("git-mirror {0}".format(self.name), msg, recipients = [self.owner], sender = mail_sender)
def find_mirror_by_url(self, match_urls):
for mirror, url in self.mirrors.items():
def find_mirror_by_url(self, match_urls):
for mirror, url in self.mirrors.items():
@@
-169,8
+172,11
@@
def find_repo_by_directory(repos, dir):
return None
def load_repos():
return None
def load_repos():
+ global mail_sender
conffile = os.path.join(os.path.dirname(__file__), 'git-mirror.conf')
conf = read_config(conffile)
conffile = os.path.join(os.path.dirname(__file__), 'git-mirror.conf')
conf = read_config(conffile)
+ mail_sender = conf['mail-sender']
+
repos = {}
for name, section in conf.items():
if name != 'DEFAULT':
repos = {}
for name, section in conf.items():
if name != 'DEFAULT':