def send_email(subject, message, recipients, image_png=None): import smtplib import email import email.mime import email.mime.multipart import email.mime.text import email.mime.image import interface config = interface.load_config() sender = config.get('email') smtp = smtplib.SMTP('localhost') msg_root = email.mime.multipart.MIMEMultipart('related') msg_text = email.mime.text.MIMEText(message, 'plain') msg_text.set_charset('utf-8') msg_root.attach(msg_text) if image_png: fp = open(image_png, 'rb') msg_image = email.mime.image.MIMEImage(fp.read(), 'png') fp.close() msg_root.attach(msg_image) msg_root['Subject'] = subject msg_root['From'] = 'Luigi' msg_root['To'] = ','.join(recipients) smtp.sendmail(sender, recipients, msg_root.as_string())
def video(self): result = load_config() if not result['ret'] or (result['ret'] and result['msg'] == ''): QMessageBox.warning(self, "警告", "请先连接设备!", QMessageBox.Yes, QMessageBox.Yes) return str_type = self.sender().objectName().split('_')[-1] print(str_type) if str_type == 'close': close_camera_client() self.video_pannel.setPixmap(self.background_camera) return cameraThread = threading.Thread(target=self.thread_camera, args=(self.video_pannel, str_type)) cameraThread.start()
def mqtt_send(command=None): global server_topic result = load_config() if result['ret']: device_id = result['msg'] else: return result if command and device_id: try: server_topic = 'aicar_pc' + device_id print('topic: ' + server_topic + ' command: ' + command) client.publish(server_topic, command, 1) return {'ret': True, 'msg': ''} except Exception as e: return {'ret': False, 'msg': 'error : '+str(e)} elif not command: return {'ret': False, 'msg': '指令不得为空!'} else: return {'ret': False, 'msg': '请先连接设备!!!'}
def __init__(self): import interface config = interface.load_config() streaming_jar = config.get('hadoop', 'jar') super(DefaultHadoopJobRunner, self).__init__(streaming_jar=streaming_jar)
def __init__(self): import interface config = interface.load_config() streaming_jar=config.get('hadoop', 'jar') super(DefaultHadoopJobRunner, self).__init__(streaming_jar=streaming_jar)