aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/acme/datasource.json_sample23
-rwxr-xr-xbin/common/srtool_email.py46
-rwxr-xr-xbin/dev_tools/srt_env.sh6
3 files changed, 56 insertions, 19 deletions
diff --git a/bin/acme/datasource.json_sample b/bin/acme/datasource.json_sample
index 48e3838e..dc1d0188 100755
--- a/bin/acme/datasource.json_sample
+++ b/bin/acme/datasource.json_sample
@@ -38,11 +38,32 @@
"helptext" : "The registered script to manage defects",
"value" : "bin/acme/srtool_defect.py"
},
-
{
"name" : "SRTOOL_DEFECT_URLBASE",
"helptext" : "The url base lookup for the external defect tool",
"value" : "https://bugzilla.acme.org/show_bug.cgi?id="
+ },
+
+ {
+ "name" : "SRT_EMAIL_SMTP",
+ "helptext" : "The ACME SMTP server",
+ "value" : "smtp.acme.com"
+ },
+ {
+ "name" : "SRT_EMAIL_USER",
+ "helptext" : "The ACME email user account",
+ "value" : "srt_manager"
+ },
+ {
+ "_comment_" : "Fetch from environment",
+ "name" : "SRT_EMAIL_PASSWD",
+ "helptext" : "The ACME email user password",
+ "value" : ""
+ },
+ {
+ "name" : "SRT_EMAIL_FROM",
+ "helptext" : "The ACME email 'from' address",
+ "value" : "srt.manager@acme.com"
}
],
"datasource" : [
diff --git a/bin/common/srtool_email.py b/bin/common/srtool_email.py
index 103c8be0..c57fa9ab 100755
--- a/bin/common/srtool_email.py
+++ b/bin/common/srtool_email.py
@@ -44,6 +44,8 @@ msg = ''
verbose = False
test = False
+srtErrorLog = 'srt_errors.txt'
+
#################################
# Send the email
#
@@ -67,6 +69,11 @@ def enter_message():
print("Message length is", len(msg))
+def srt_error_log(msg):
+ f1=open(srtErrorLog, 'a')
+ f1.write("|" + msg + "|\n" )
+ f1.close()
+
#################################
# Send the email
#
@@ -135,28 +142,17 @@ def main(argv):
args = parser.parse_args()
# Resolve the arguments
- if args.smtpfrom:
- fromaddr = args.smtpfrom
- else:
- print("ERROR: missing 'from' address")
- exit(1)
if args.smtpto:
toaddrs = args.smtpto
toaddrs = toaddrs.split(',')
else:
- print("ERROR: missing 'to' address")
+ print("ERROR: missing 'to' address", file=sys.stderr)
exit(1)
if args.subject:
subject = args.subject
else:
- print("ERROR: missing 'subject'")
+ print("ERROR: missing 'subject'", file=sys.stderr)
exit(1)
- if args.smtpserver:
- smtpserver = args.smtpserver
- else:
- smtpserver = os.environ.get('SRT_SMTP')
- if not smtpserver:
- smtpserver = 'localhost'
verbose = args.verbose
test = args.test
@@ -164,11 +160,25 @@ def main(argv):
if args.user:
srt_user = args.user
else:
- srt_user = os.environ.get('SRT_USER')
+ srt_user = os.getenv('SRT_EMAIL_USER','')
if args.passwd:
srt_passwd = args.passwd
else:
- srt_passwd = os.environ.get('SRT_PASSWD')
+ srt_passwd = os.getenv('SRT_EMAIL_PASSWD','')
+ # Server settings
+ if args.smtpserver:
+ smtpserver = args.smtpserver
+ else:
+ smtpserver = os.getenv('SRT_EMAIL_SMTP','')
+ if args.smtpfrom:
+ fromaddr = args.smtpfrom
+ else:
+ fromaddr = os.getenv('SRT_EMAIL_FROM','')
+ if not smtpserver or not srt_user or not srt_passwd or not fromaddr:
+ msg = "FATAL ERROR: Missing SMTP('%s'), User('%s'), Password('%s'), and/or From('%s') for email access" % (smtpserver,srt_user,'*******' if srt_passwd else '',fromaddr)
+ print(msg, file=sys.stderr)
+ srt_error_log(msg)
+ exit(1)
# Encryption
if args.tls:
@@ -187,9 +197,13 @@ def main(argv):
elif args.prompt:
enter_message()
else:
- print("ERROR: missing message source")
+ print("ERROR: missing message source", file=sys.stderr)
exit(1)
+ # Debug
+ if verbose:
+ srt_error_log("EMAIL: SMTP('%s'), User('%s'), Password('%s'), From('%s'), args('%s')" % (smtpserver,srt_user,srt_passwd,fromaddr,str(args)))
+
# Send the email
send_email()
diff --git a/bin/dev_tools/srt_env.sh b/bin/dev_tools/srt_env.sh
index 1cceb1c5..f36a2329 100755
--- a/bin/dev_tools/srt_env.sh
+++ b/bin/dev_tools/srt_env.sh
@@ -22,9 +22,10 @@ if [ "debug" != "$mode" ] ; then
export SRTDBG_SKIP_CPE_IMPORT=0
export SRT_SKIP_AUTOUPDATE=0
# Email credentials
- export SRT_SMTP=temp_smnp_server
+ export SRT_EMAIL_SMTP=smtp.org.com
export SRT_EMAIL_PASSWD=temp_password
export SRT_EMAIL_USER=temp_user
+ export SRT_EMAIL_FROM=temp_user@org.com
# Defect (e.g. Jira) credentials
export SRT_DEFECT_PASSWD=temp_password
export SRT_DEFECT_USER=temp_user
@@ -42,9 +43,10 @@ else
export SRTDBG_SKIP_CPE_IMPORT=0
export SRT_SKIP_AUTOUPDATE=1
# Email credentials
- export SRT_SMTP=temp_smnp_server
+ export SRT_EMAIL_SMTP=smtp.org.com
export SRT_EMAIL_PASSWD=temp_password
export SRT_EMAIL_USER=temp_user
+ export SRT_EMAIL_FROM=temp_user@org.com
# Defect (e.g. Jira) credentials
export SRT_DEFECT_PASSWD=temp_password
export SRT_DEFECT_USER=temp_user