Exemple #1
0
def begin():
    suite = unittest.TestSuite()
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestListToDetail))

    timetemp = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
    report_title = '商标交易用例执行报告'
    desc = '商标交易'
    report_file = 'reports\{}_{}.html'.format(report_title, timetemp)
    with open(report_file, 'wb') as report:
        runner = HTMLTestRunner(stream=report, title=report_title, description=desc, verbosity=2)
        runner.run(suite)

    file_path = os.path.join(os.getcwd(), report_file)
    email = SendEmail()
    email.send_mail(report_title, file_path)
Exemple #2
0
def runnerPool():
    devices_Pool = []
    # 检查设备
    devices = adb.attached_devices()
    if devices:
        for item in range(0, len(devices)):
            _app: Dict[str, Union[str, int]] = {
                "devices": devices[item],
                "num": len(devices)
            }
            devices_Pool.append(_app)
        pool = Pool(len(devices))
        pool.map(start, devices_Pool)
        pool.close()
        pool.join()

        #读取logcat日志  获取crash数量  大于0发送邮件
        with open(logFileName, "r", encoding='utf-8') as f:
            data = f.read()
            crash = data.count('Caused by')
            if crash > 0:
                SendEmail().send_main(crash)

    else:
        print("设备不存在?")
Exemple #3
0
def sendEmail(toAddrs, subject, body):
    """ 发送邮件 """
    transport = TSocket.TSocket(HOST, PORT)
    transport = TTransport.TBufferedTransport(transport)
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    client = SendEmail.Client(protocol)
    transport.open()
    b = client.send(toAddrs, subject, body)
    transport.close()
Exemple #4
0
 def wrapper(*args, **kwargs):
     logger = create_logger()
     try:
         fn(*args, **kwargs)
     except Exception as e:
         SendEmail(traceback.format_exc())
         logger.exception("[Error in {}] msg: {}".format(__name__, str(e)))
         with open('xvideos.log', 'a+', encoding='utf-8') as f:
             f.write('\n')
         raise  #主动抛出异常
Exemple #5
0
def main():
    # Make socket
    transport = TSocket.TSocket('localhost', 9090)

    # Buffering is critical. Raw sockets are very slow
    transport = TTransport.TBufferedTransport(transport)

    # Wrap in a protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)

    # Create a client to use the protocol encoder
    client = SendEmail.Client(protocol)

    # Connect!
    print 'connecting ...'
    transport.open()
    b = client.send("*****@*****.**", u'主题', u'内容')
    transport.close()
Exemple #6
0
GARAGE_DOOR_SENSORS = [0, 1]

dirOfThisFile = os.path.dirname(__file__)

# get settings
parser = SafeConfigParser()
print dirOfThisFile
parser.read('/home/andy/houseSettings')
warning_email_1 = parser.get('core settings', 'WARNING_EMAIL1')
warning_email_2 = parser.get('core settings', 'WARNING_EMAIL2')

conn = sqlite3.connect('/home/andy/djangoProjects/leeHouseSite/sqlite/db.sql3')
c = conn.cursor()
for row in c.execute(
        'select t1.* FROM restInterface_door_entry AS t1 LEFT OUTER JOIN restInterface_door_entry AS t2 ON (t1.doorNumber = t2.doorNumber AND t1.id < t2.id) where t2.doorNumber IS NULL;'
):
    if row[1] in GARAGE_DOOR_SENSORS:
        # This door entry is a garage door
        lastGarage = row
        doorStatus = row[2]
        if doorStatus == 1:
            timeDoorHasBeenOpen = datetime.now() - datetime.fromtimestamp(
                lastGarage[3])
            if timeDoorHasBeenOpen.seconds / 60 > MINUTES_TILL_WARNING_SENT:
                # if warning time has passed
                message = "Subject:House Warning: Garage door is OPEN.\n\nHas been open since: "
                message += str(datetime.fromtimestamp(lastGarage[3]))
                SendEmail(warning_email_1, message)
                SendEmail(warning_email_2, message)
Exemple #7
0
'''
__author__:'shimengqi'
__description__:'运行测试框架'
__mtime__:2018/3/8
'''
from log import Log
from TestAllRunner import TestAllRunner
import time
from TestXlsxReport import Report
import TestSuite
import BuyerTestCase
from sendEmail import SendEmail

log = Log()
report = Report()
sendEmail = SendEmail()


class Running:
    def __init__(self):
        self.sheet = report.get_worksheet()

    def write_data(self, runcase, passcase, failcase, passrate, time):
        report.write_cell(self.sheet, "E3", runcase)
        report.write_cell(self.sheet, "E4", passcase)
        report.write_cell(self.sheet, "E5", failcase)
        report.write_area(self.sheet, "F4:F6", time, 's')
        report.write_area(self.sheet, "G4:G6", passrate, '%')

    def running(self):
        '''运行测试框架'''
Exemple #8
0
from getCityCode import GetCityCode
from weather import Weather
from sendEmail import SendEmail

city = '上海'
# city = '西安' # 要查询的城市地址
msg_to = ['', '']  # 收件人邮箱,可以写多个。
msg_from = ''   # 发件人邮箱
password = ''  # 发件人邮箱授权码

code = GetCityCode(city).getCode()
print(code)
result = Weather().getWea(code)
print(result)
SendEmail(result, msg_to, city, msg_from, password).send()
#---------------------------------------

import requests
from bs4 import BeautifulSoup
from prettytable import PrettyTable
from xpinyin import Pinyin
import time
from sendEmail import SendEmail

p = Pinyin()

mailto_list = ['*****@*****.**', '*****@*****.**']
mail_host = "smtp.126.com"          #定义smtp主机
mail_user = "******"   #用户名
mail_pass = "******"       #口令
mail = SendEmail(mail_host, mail_user, mail_pass)

stock_dict = {
    '上证指数': '000001',
    # '西藏天路': '600326',
    '中国人寿': '601628',
    '远大智能': '002689',
    # '尚荣医疗': '002551',
    # '唐山港': '601000',
    # '常铝股份': '002160',
    # '珠海港': '000507',
    # '兴业矿业': '000426',
    # '西部建设': '002302'
}

stock_alert_value_high = {
Exemple #10
0
        fromAddr = EMAIL_USER
        email = MIMEText(body, 'plain', 'utf-8')
        email['Subject'] = Header(subject, 'utf-8').encode()
        email['From'] = fromAddr
        email['To'] = toAddrs

        try:
            server = smtplib.SMTP(EMAIL_HOST, EMAIL_PORT)
            # server.set_debuglevel(1)
            server.login(fromAddr, EMAIL_PASSWORD)
            server.sendmail(fromAddr, [addr.strip() for addr in toAddrs.split(",")], email.as_string())
            server.quit()
        except Exception, e:
            logger.error("Sending email failure, error: %s" % (str(e)))
            return False
        else:
            logger.info("Sending email success")
            return True


if __name__ == '__main__':
    executor = SendEmailExecutor()
    processor = SendEmail.Processor(executor)
    transport = TSocket.TServerSocket(port=PORT)
    tfactory = TTransport.TBufferedTransportFactory()
    pfactory = TBinaryProtocol.TBinaryProtocolFactory()

    server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
    logger.info('Starting the server...')
    server.serve()
}

stock_alert_value_low = {
    '中国人寿': 27.50,
    '远大智能': 6.60,
}

baseUrl = "https://gupiao.baidu.com/stock/"


def getCurrentTime():
    return time.strftime('%H:%M:%S', time.localtime(time.time()))


while True:
    mail = SendEmail(mail_host, mail_user, mail_pass)
    x = PrettyTable([
        "Stock Name", "Current Price", "Rate", "Change", "Max", "Min", "Time"
    ])
    x.align["Stock Name"] = "l"
    x.padding_width = 1

    currentTime = getCurrentTime()

    if currentTime >= "09:30:00" and currentTime <= "11:30:00" or currentTime >= "13:00:00" and currentTime <= "15:03:00":
        for key, value in stock_dict.items():
            if value.startswith('00') and value != '000001':
                stockCode = 'sz'
            elif value.startswith('60') or value == '000001':
                stockCode = 'sh'
Exemple #12
0
#---------------------------------------

import os
import urllib
import urllib2
import cookielib
import re
import time
from bs4 import BeautifulSoup
from sendEmail import SendEmail

mailto_list = ['*****@*****.**', '*****@*****.**']
mail_host = "smtp.126.com"  #定义smtp主机
mail_user = "******"  #用户名
mail_pass = "******"  #口令
mail = SendEmail(mail_host, mail_user, mail_pass)


#获取当前时间
def getCurrentTime():
    return time.strftime('[%Y-%m-%d %H:%M:%S]', time.localtime(time.time()))


#获取登录RT时隐藏附加的一个Next值
def getNext(data):
    soup = BeautifulSoup(data, "html.parser")
    next = soup.find("input", {"name": "next"})['value']
    return next


#通过详情页获取最后更新时间和人
Exemple #13
0
    'charset': 'utf8',
}

# 创建连接对象
db = pymysql.connect(
    host=ConnectConfig['host'],
    port=ConnectConfig['port'],
    user=ConnectConfig['user'],
    passwd=ConnectConfig['passwd'],
    charset=ConnectConfig['charset'],
)
cursor = db.cursor()
cursor.execute('show databases')
name = "Emails"
cursor.execute('use ' + name)
# 查询Emails表中所有记录
cursor.execute('select * from Emails')
emails = cursor.fetchall()
faillist = []
flag = True
#逐一发送邮件
for email in emails:
    sendemail = SendEmail()
    flag = sendemail.sendEmail(email[0], email[1])
    if not flag:
        faillist.append(email)
    time.sleep(2)
cursor.close()
db.close()
print("共发送失败" + str(len(faillist)) + "个")
Exemple #14
0
#---------------------------------------

import os
import urllib
import urllib2
import cookielib
import re
import time
from bs4 import BeautifulSoup
from sendEmail import SendEmail

mailto_list = ['*****@*****.**', '*****@*****.**']
mail_host = "smtp.126.com"      #定义smtp主机
mail_user = "******"       #用户名
mail_pass = "******"   #口令
mail = SendEmail(mail_host, mail_user, mail_pass)

#获取当前时间
def getCurrentTime():
    return time.strftime('[%Y-%m-%d %H:%M:%S]', time.localtime(time.time()))

#获取登录RT时隐藏附加的一个Next值
def getNext(data):
    soup = BeautifulSoup(data, "html.parser")
    next = soup.find("input", {"name": "next"})['value']
    return next

#通过详情页获取最后更新时间和人
def getLatestUpdated(url):
    #print url
    op = opener.open(url)
Exemple #15
0
# _*_ coding:utf-8 _*_
__author__ = 'Lee'
from sendEmail import SendEmail
from sendEmail import SendHtmlEmail
sendmail = SendEmail.SendEmail('测试发送邮件')
sendmail.sendMail()

#smail=SendHtmlEmail.SendHtmlEmail("D:\\WORK\\AutoTest\\Report")
#smail.send_mail_html()
Exemple #16
0
# @Time    : 2019/12/2 11:17
# @Author  : Libuda
# @FileName: spider.py
# @Software: PyCharm
import xlrd
from xlutils.copy import copy
from selenium import webdriver
import time
import datetime
from sendEmail import SendEmail
from copy import deepcopy

send = SendEmail()
user_list = ['*****@*****.**']

phone_num = 13281890000
wait_time = 3  # 各个阶段等待时间
time_jiange = 30  # 时间间隔 隔多长时间执行脚本一次
start_date = datetime.datetime.strptime("2019-12-1 00:00:00", "%Y-%m-%d %H:%M:%S")  # 起始时间
end_date = datetime.datetime.strptime("2019-12-7 18:00:00", "%Y-%m-%d %H:%M:%S")  # 结束时间
ding_num = 5  # 链接条数报警阈值

driver = webdriver.Chrome(r"C:\Users\lenovo\PycharmProjects\Spider\chromedriver.exe")
link_file_path = r"C:\Users\lenovo\PycharmProjects\leetcode-python-\樊登读书脚本\link.xls"
phone_file_path = r"C:\Users\lenovo\PycharmProjects\leetcode-python-\樊登读书脚本\phone_number.xls"

link_ecel = xlrd.open_workbook(link_file_path)
link_tables = link_ecel.sheet_by_index(0)
link_get_col = 2
link_write_col = 3
Exemple #17
0
import rootpath
# import HTMLTestRunner_PY3
import HTMLTestRunner_PY333
from log import Log
from sendEmail import SendEmail

log = Log()
suit = testsuit.set_suit()
now = time.strftime('%Y-%m-%d %H-%M-%S', time.localtime(time.time()))
print(now)
rootPath = rootpath.get_rootpath()
# reportPath=rootPath+r'\result\report'+'\\'+now+'result.html'
reportPath = rootPath + '/result/report' + '/' + now + 'result.html'
print(reportPath)
fp = open(reportPath, 'wb')
runner = HTMLTestRunner_PY333.HTMLTestRunner(stream=fp,
                                             title=u'测试报告',
                                             description=u'用例执行情况')
runner.run(suit)
SendEmail().sendEmail(reportPath)

# # 定时任务
# k=1
# while k<2:
#     timing=time.strftime('%H:%M',time.localtime(time.time()))
#     if timing=='15:45':
#         log.info('开始运行测试脚本!')
#         runner.run(suit)
#         log.info('运行完成退出')
#         SendEmail().sendEmail(reportPath)