Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)

        def check_mail_config(job):
    
    errors={}

    defaul_port=dict(normal=25, ssl=465, tls=587)
    
    mail=job.get('mail', 'yes')
    if mail!='fail':
        mail=boolean.get(mail, None)
    
    if mail==None:
        errors['mail']='mail must have a value in (yes, no, fail)'
    else:
        job['mail']=mail

    magikmon=job.get('magikmon', '')
    if magikmon:
        if not url_re.match(magikmon):
            errors['magikmon']='not a valid URL'
        else:
            if job['program']=='esxmon':
                up=urlparse.urlparse(magikmon)
                if up[1].lower().startswith('monitoring.magikmon.com') and up[2].lower().startswith('/sendbackup'):
                    magikmon=''
                    # don't send esxmon status to MagiKmon backup service 
                    # errors['magikmon']='Cannot report status to MagikMon backup service'
                    
    job['magikmon']=magikmon
    
    if mail:
        try:
            job['smtp_host']=smtp_host=job['smtp_host'].encode('ascii')
        except UnicodeEncodeError:
            errors['smtp_host']='invalid hostname or ip address'
        else:
            if not valid_ipRE.match(smtp_host):
                if not valid_hostnameRE.match(smtp_host):
                    errors['smtp_host']='invalid hostname or ip address'
                else:
                    try:
                        ip=socket.gethostbyname(smtp_host)
                    except socket.gaierror:
                        errors['smtp_host']='cannot resolve address'
    
        smtp_mode=job['smtp_mode'].lower()
        if not smtp_mode in ('normal', 'ssl', 'tls'):
            errors['smtp_mode']='mode must be in "normal", "ssl", or "tls"'
        else:
            job['smtp_mode']=smtp_mode
            if smtp_mode in ('ssl', 'tls') and not hasattr(socket, 'ssl'):
                errors['smtp_mode']='this version of python has no support for SSL'
            if smtp_mode=='ssl' and not hasattr(smtplib, 'SMTP_SSL'):
                errors['smtp_mode']='this version of python has no SSL support for SMTP'
                
        job['smtp_login']=job.get('smtp_login')
        job['smtp_password']=job.get('smtp_password')

        smtp_port=job.get('smtp_port', defaul_port.get(smtp_mode, 25))
        try:
            port=int(smtp_port)
        except Exception:
            errors['smtp_port']='must be an integer'
        else:
            if not (0
    


src/m/k/mksbackup-1.0.4/mksbackuplib/main.py   mksbackup(Download)
from datetime import datetime, timedelta
 
from archiver import boolean, check_mail_config, Destinations, sendmail, Manager, send_mail_report, write_status, ftp_url_re
 
import cron
            job['msg_header']=''
 
        mail_config_errors=check_mail_config(job)
 
        # check job parameters