Beispiel #1
0
def getActiveKey():
    element = u"@@@"
    hostname = SysInfo.getHostName()
    platformStr = SysInfo.getPlatform()
    macs = SysInfo.getEnableMacs()
    cpu = SysInfo.getCpuName()
    strSelfInfo = element + hostname + element + platformStr + element + macs + element + cpu + element
    strSelfInfo = xstring.clearDuplicateSpace(strSelfInfo)
    return strSelfInfo
Beispiel #2
0
def requestActive(key):
    try:
        emailaddr = g_emailaddr
        emailpwd = g_emailpwd
        thistime = datetime.datetime.now()
        sender =  emailaddr
        receiver = emailaddr
        subject = xstring.str2unicode(str(thistime)) + u"[" + xstring.str2unicode(SysInfo.getHostName()) + u"]"
        smtpserver = g_smtpserver
        username = emailaddr
        password = emailpwd

        emailcontent = key
        emailcontent += u"\r\n\r\n"
        emailcontent = emailcontent + u"\r\n" \
                       + u"time£º" + xstring.str2unicode(str(thistime)) + u"\r\n" \
                       + u"hostname£º" + xstring.str2unicode(SysInfo.getHostName()) + u"\r\n" \
                       + u"platform£º" + xstring.str2unicode(SysInfo.getPlatform()) + u"\r\n" \
                       + u"mac£º" + xstring.str2unicode(SysInfo.getEnableMacs()) + u"\r\n" \
                       + u"cpu£º" + xstring.str2unicode(SysInfo.getCpuInfo()) + u"\r\n" \
                       + u"mem£º" + xstring.str2unicode(SysInfo.getMemInfo()) + u"\r\n" \
                       + u"disk£º" + xstring.str2unicode(SysInfo.getDiskInfo()) + u"\r\n" \

        msg = MIMEText(emailcontent,'plain','utf-8')
        msg['Subject'] = Header(subject, 'utf-8')
        msg['From'] = sender
        msg['To'] = receiver
         
        smtp = smtplib.SMTP() 
        smtp.connect(g_smtpserver) 
        smtp.login(username, password) 
        smtp.sendmail(sender, receiver, msg.as_string()) 
        smtp.quit()
    except:
        traceStr = traceback.format_exc()
        logging.error(traceStr)