Exemple #1
0
def sendJobEmail(jei, content, svr_stmp):
	if len(jei.header_addition) > 0 :
		content = jei.header_addition + content
	em = sendEmail.buildEMail(jei.toAddr, jei.fromAddr, jei.subject, content)

	try:
		svr_stmp.sendmail(jei.fromAddr, jei.toAddr, em.as_string())
	except:
		sLog = hxColorString.colorString("Failure:", '2' )
		sLog += hxColorString.colorString(jei.toAddr, '1;31') 
		print(sLog, file=sys.stderr)
		#print("Failure to diliver email:" + toAddr, file=sys.stderr)
		#print(sys.exc_info()[0], file=sys.stderr)
		return False

	sLog = "Success:"
	sLog += jei.toAddr
	print(sLog)
	return True
Exemple #2
0
def main():
	if len(sys.argv) >= 2:
		word = ' '.join(sys.argv[1:])
		#getword(word)

		wi = getInfo(word)
		s = colorString(wi.sKey, '2;4') + ' [' + colorString(wi.sPron, '32;1')  + ']'
		print(s)

		s = '释义:'
		print(colorString(s, '2'))
		s = '\t' + wi.sDef
		s = s.replace('\n', '\n\t')
		print(colorString(s, '36;1'))

		s ='例句:'
		print(colorString(s, '2'))
		s = '\n\t'
		s = s.join(wi.sExample)
		s = '\t' + s
		#s = s.replace('<em>'+wi.sKey+'</em>', colorString(wi.sKey, '7'))
		s = re.sub(r'<em>(\w+)</em>', colorString(r'\1','7'), s)
		print(s)
	else:
		print('usage:dict [word]')