def send_mail(to, subject, msg, frm, reply_to=None): args = ['-a', "From: {}".format(frm), '-s', subject, to] if reply_to: args = ['-a', 'Reply-To: {}'.format(reply_to)] + args mail(*args, _in=msg)
#!/usr/bin/env python import os.path from sh import curl, cli53, mail TMPFILE = os.path.expanduser('~/.r53dyndns.txt') last_ip = None if os.path.exists(TMPFILE): last_ip = open(TMPFILE).read() current_ip = str(curl('http://canihazip.com/s')).strip() if current_ip != last_ip: output = cli53('rrcreate', '-x', 600, 'nixer.info', "", 'A', current_ip, '--replace', '--wait') with open(TMPFILE, 'w') as fp: fp.write(current_ip) mailtext = 'La nueva ip de nixer.info es %(current_ip)s. \n\n%(output)s' % locals( ) mail('-s', 'nixer.info - notification de cambio de ip', 'ricardo', _in=mailtext)
if not os.path.exists(fname): raise ValueError ('El archivo %s no existe' % fname) if os.path.exists(args.output): if not args.force: raise ValueError ('El archivo de salida %s ya existe (use -f para sobreescribirlo)' % args.output) assert(os.path.splitext(args.output)[-1].lower() == '.avi') tmp = mktemp().strip() tmp_avi = mktemp('--tmpdir=/var/tmp').strip() try: for line in nice.mencoder(args.video, '-oac', 'mp3lame', '-ovc', 'xvid', '-vf', 'scale', '-zoom', '-xy', 720, '-xvidencopts', 'bitrate=1500:me_quality=6:threads=2:pass=1', '-sub', args.subtitulos.decode('latin1'), '-subfont-text-scale', 2.8, '-subcp', args.encoding, '-subpos', 85, '-passlogfile', tmp, '-o', '/dev/null', '-quiet', _iter=True): print line.strip() for line in nice.mencoder(args.video, '-oac', 'mp3lame', '-ovc', 'xvid', '-vf', 'scale', '-zoom', '-xy', 720, '-xvidencopts', 'bitrate=1500:me_quality=6:threads=2:pass=2', '-sub', args.subtitulos.decode('latin1'), '-subfont-text-scale', 2.8, '-subcp', args.encoding, '-subpos', 85, '-passlogfile', tmp, '-o', tmp_avi, '-quiet', _iter=True): print line.strip() shutil.move (tmp_avi, args.output) mail ('-s', "encode de %s terminado" % os.path.basename(args.output), '*****@*****.**', _in='Proceso terminado') finally: if os.path.exists(tmp): os.remove (tmp) if os.path.exists(tmp_avi): os.remove (tmp_avi)
#!/usr/bin/env python import os.path from sh import curl, cli53, mail TMPFILE=os.path.expanduser('~/.r53dyndns.txt') last_ip = None if os.path.exists(TMPFILE): last_ip = open(TMPFILE).read() current_ip = str(curl ('http://canihazip.com/s')).strip() if current_ip != last_ip: output = cli53 ('rrcreate', '-x', 600, 'nixer.info', "", 'A', current_ip, '--replace', '--wait') with open(TMPFILE, 'w') as fp: fp.write(current_ip) mailtext = 'La nueva ip de nixer.info es %(current_ip)s. \n\n%(output)s' % locals() mail ('-s', 'nixer.info - notification de cambio de ip', 'ricardo', _in=mailtext)