コード例 #1
0
def call(frequence=1):
    print("Loading user emails...")
    to_addr = load_eaddr()
    print(to_addr)

    while True:
        clock = time.localtime()
        today = (clock.tm_year, clock.tm_mon, clock.tm_mday)
        if clock.tm_hour == 0 and clock.tm_min == 1:
            buff.clear()  # 新的一天开始了
            to_addr = load_eaddr()

        latest_xsfw = latest_news(get_news_jwc(get_news_lis(xsfw_url)),
                                  today)  # 获取教务处“学生服务”
        latest_zhfw = latest_news(get_news_jwc(get_news_lis(zhfw_url)),
                                  today)  # 获取教务处“综合服务”
        latest_csee = latest_news(get_news_cess(get_news_lis(csee_url)),
                                  today)  # 信息院

        if len(latest_csee) + len(latest_zhfw) + len(latest_xsfw) > 0:
            all_news = latest_xsfw, latest_zhfw, latest_csee
            with open('infos.txt', 'w+') as f:
                f.write(str(all_news) + '\n')
            print(all_news)
            msg_page = genHTML(all_news)
            send_email(from_addr, to_addr, "又双叒叕出新通知啦", msg_page, pwd)

        time.sleep(60 * frequence - time.localtime().tm_sec)
コード例 #2
0
ファイル: zhandui.py プロジェクト: bobcaoge/my-code
 def dump_object(self):
     try:
         with open("./data.data.tmp", "wb") as fw:
             with open("./data.data", "rb") as fr:
                 fw.write(fr.read())
     except:
         send_email(content="文件存储失败")
     with open("./data.data", "wb") as f:
         f.write(pickle.dumps(self.team))
コード例 #3
0
 def request_permission(self, admin_id, member_id, admin_email,
                        member_name):
     if self.admin_is_present(
             admin_id) and member_id not in self.pending_members(admin_id):
         self.add_member_to_pending_members(admin_id, member_id)
         se.send_email('*****@*****.**', 'eecs_393', admin_email,
                       member_name, member_id, True)
         return True
     else:
         return False
コード例 #4
0
ファイル: weatherWeb.py プロジェクト: Hi-110/weather
def auto_weather_report_Nanshan(running_day, midnight_time, morning_time,
                                check_min, url, email_info):
    global state
    global dayNow
    # start_run=False
    # while not start_run:
    #     time_hour = int(time.strftime(u"%H", time.localtime(time.time())))
    #     if time_hour!=0:
    #         print 'now the time is %s hour, and have to wait to be %s hour to running program' % (
    #         time_hour, 0)
    #         print 'wait %s minutes' % check_min
    #         time.sleep(check_min * 60)
    #     else:
    #         start_run=True
    #         print 'the auto weather report program is start to running...'

    for day in range(1, running_day + 1):
        print 'the auto weather report program for Nanshan is running in day %s, it will running for %s days' % (
            day, running_day)

        state = [u'NA', u'NA', u'NA', u'NA']
        is_midnight = False
        is_morning = False
        while not is_midnight:
            time_hour = int(time.strftime(u"%H", time.localtime(time.time())))
            if time_hour != 0:
                print 'now the time is %s hour, and have to wait to be %s hour to check midnight state' % (
                    time_hour, 0)
                print 'wait %s minutes' % check_min
                time.sleep(check_min * 60)
            else:
                print 'now time is %s in midnight, check weather state...' % (
                    time_hour)
                is_midnight = True
        day_now = time.strftime(u"%Y_%m_%d", time.localtime(time.time()))
        dayNow = day_now
        print day_now
        get_state(2, url[3])
        while not is_morning:
            time_hour = int(time.strftime(u"%H", time.localtime(time.time())))
            if time_hour < morning_time:
                print 'now the time is %s hour, and have to wait to be %s hour to check morning state' % (
                    time_hour, morning_time)
                print 'wait %s minutes' % check_min
                time.sleep(check_min * 60)
            else:
                print 'now time is %s hour in day %s morning , check weather state...' % (
                    time_hour, day_now)
                is_morning = True
        get_state(1, url[3])
        html = getHtml(url[0])
        arr_final = getImg(html, url[1], url[2])
        msg_text, img_file = report(arr_final)
        sendEmail.send_email(email_info, msg_text, img_file, day_now)
        print '%s weather report have send by email !' % day_now
コード例 #5
0
ファイル: weeklyReport.py プロジェクト: arlw87/photoFrame
 def sendReport(self, txEmail, rxEmail, emailSubject, PSWD, message):
     #in this function an email will be created and sent to the developer
     print("Send Email")
     self.emailSubject = emailSubject
     self.message = message
     self.emailAccountPSWD = PSWD
     self.rxEmail = rxEmail
     self.txEmail = txEmail
     reportEmail.send_email(self.txEmail, self.rxEmail,
                            self.emailAccountPSWD, self.emailSubject,
                            self.ReportLocation, self.message)
コード例 #6
0
def camPreviewPhoto():
    global i
    global j
    i = i + 1
    camera = PiCamera()
    camera.start_preview()
    sleep(5)
    camera.capture('/home/pi/Desktop/CCTV/photos/image%s.jpg' % i)
    camera.stop_preview()
    camera.close()
    send_email(get_image_file())
コード例 #7
0
def new_friend(name):
    image = face_recognition.load_image_file('New friends/emmmm.jpg')
    face_locations = face_recognition.face_locations(image)
    face_encodings = face_recognition.face_encodings(image, face_locations)
    global ecodinglist, namelist
    ecodinglist.append(face_encodings[0])
    namelist.append(name)
    np.save('resources/ecodinglist.npy', ecodinglist)
    np.save('resources/namelist.npy', namelist)
    sendEmail.send_email(name)
    return
コード例 #8
0
def camPreviewVideo():
    global i
    global j
    j = j + 1
    i = i + 1
    camera = PiCamera()
    camera.start_preview()
    camera.start_recording('/home/pi/Desktop/CCTV/videos/video%s.h264' % j)
    sleep(9)
    camera.stop_recording()
    sleep(3)
    camera.capture('/home/pi/Desktop/CCTV/photos/image%s.jpg' % i)
    camera.stop_preview()
    camera.close()
    send_email(get_image_file())
コード例 #9
0
ファイル: getMorning.py プロジェクト: ALeiQ/MorningNews
def get_morning(type='分钟'):
    logging.info('Start catching......')
    receive_emails = []

    with open('receive_emails', 'r') as f:
        for x in f.readlines():
            x = solve_email(x)
            if x:
                receive_emails.append(x)

    web_html = get_html(main_web)
    items = get_items(web_html)
    link_dates = get_link_dates(items)

    new_link = link_dates[0]
    if type in new_link.date:
        new_html = get_html(new_link.url)
        title, message = get_message(new_html)
        em = send_email(title, message, receive_emails)
        em.do_send()
        logging.info('早报任务执行完成')
        return True
    else:
        logging.warning('未抓取到早报,10分钟后重试')
        return False
コード例 #10
0
ファイル: app.py プロジェクト: cmoralesmani/cesarmorales-api
def post_send_email():
    response = ''
    if request.method == 'POST':
        try:
            name = request.form['name']
            from_addr = request.form['email']
            subject = request.form['subject']
            msg_text = request.form['message']

            send_email(name, from_addr, subject, msg_text)
            response = 'OK'
        except SendError as inst:
            response = inst.message
        except Exception:
            response = 'Error desconocido.'

    return response
コード例 #11
0
def success():
    if request.method == 'POST':
        email = request.form["Email"]
        location = request.form["Place"]
        locationUpdated = location.lower().replace(" ", "")
        print(locationUpdated)
        HitsForPlace = db.session.query(Data).filter(
            Data.place_ == locationUpdated).count()
        find = glob.glob("static/maps/map-{}-*.html".format(locationUpdated))
        print(find, email, location)
        update = False
        try:
            pl = find[0]
            print(pl)
            dateString = pl[-15:-5]
            now = datetime.now().strftime("%Y-%m-%d")
            print(now)
        except:
            update = True

        if update == True or NeedUpdate(dateString, now) == True:
            if find:
                os.remove("static/maps/map-{}-{}.html".format(
                    locationUpdated, dateString))
            string = Findall(location)
        else:
            string = "pass"
            print(dateString, locationUpdated)
            sav.saveVal(dateString, locationUpdated, 10)
            print(sav.getDate(), sav.getLoc())

        if string == "pass":
            data = Data(email, locationUpdated)
            db.session.add(data)
            db.session.commit()
            mapName = "/static/maps/map-{}-{}.html".format(
                sav.getLoc(), sav.getDate())

            send_email(email, HitsForPlace)
            return render_template("Success.html", mapName=mapName)
        else:
            return render_template(
                "Home.html",
                text=
                "Looks Like Something Went Wrong Or We Dont Serve that Location YET!"
            )
コード例 #12
0
def contact():
    if request.method == 'POST':
        greeting = "Successfully sent your message"
        # Grab form data
        name = request.form['name']
        email = request.form['email']
        phone = request.form['phone']
        message = request.form['message']

        # Create email fields
        subject = f"Blog message from {name}"
        content = f"Message:\n{message}\n\nEmail: {email}\n\nPhone: {phone}"

        # Send email
        send_email(subject, content)
        return render_template('contact.html', greeting=greeting)

    elif request.method == 'GET':
        greeting = "Contact Me"
        return render_template('contact.html', greeting=greeting)
コード例 #13
0
def alerts():
    if request.method == 'POST':
        e_subject = request.form['subject']
        e_message = request.form['message']
        send_email(e_subject, e_message)
    return render_template('alerts.html')
コード例 #14
0
 def reject(self, member_email, admin_id, admin_name):
     se.send_email('*****@*****.**', 'eecs_393', member_email,
                   admin_name, admin_id, False)
     return True
コード例 #15
0
            to_addr = load_eaddr()

        latest_xsfw = latest_news(get_news_jwc(get_news_lis(xsfw_url)),
                                  today)  # 获取教务处“学生服务”
        latest_zhfw = latest_news(get_news_jwc(get_news_lis(zhfw_url)),
                                  today)  # 获取教务处“综合服务”
        latest_csee = latest_news(get_news_cess(get_news_lis(csee_url)),
                                  today)  # 信息院

        if len(latest_csee) + len(latest_zhfw) + len(latest_xsfw) > 0:
            all_news = latest_xsfw, latest_zhfw, latest_csee
            with open('infos.txt', 'w+') as f:
                f.write(str(all_news) + '\n')
            print(all_news)
            msg_page = genHTML(all_news)
            send_email(from_addr, to_addr, "又双叒叕出新通知啦", msg_page, pwd)

        time.sleep(60 * frequence - time.localtime().tm_sec)


if __name__ == '__main__':
    print("Running...")
    try:
        call(frequence=15)
    except Exception as e:
        print(e)
        err = str(traceback.print_exc())
        send_email(from_addr, [
            "*****@*****.**",
        ], "(#°Д°)崩溃鸟", err, pwd)
コード例 #16
0
ファイル: showsgoCrawler.py プロジェクト: ueg1990/shows-alert
	# d.show_list.add(show)


print len(TvShows.objects.all())

print len(Episode.objects.all())

for u in UserProfile.objects.all():
	if u.newuser:
		for show in u.show_list.all():
			latest_episode = Episode.objects.filter(show=show).order_by('-creation_date')[:1]
			latest_episode = latest_episode[0]
			if u.email_notification: # EMAIL
				to = u.user.email
				s = 'Here is link to the latest episode of ' + latest_episode.getSeasonAndEpisode() +' : \n' + latest_episode.getShowLink()
				send_email(to,'Shows Alert Update', s)
		u.newuser = False
		u.save()

for i in Episode.objects.all():
	if i.sent == False:
		for u in i.show.users.all(): # Loop through all the users and use their emails
			p = UserProfile.objects.get(user=u) # Get corresponding UserProfile 
			if p.email_notification: # EMAIL
				to = u.email
				s = 'Here is link to the latest episode of ' + i.getSeasonAndEpisode() +' : \n' + i.getShowLink()
				send_email(to,'Shows Alert Update', s)
				i.sent = True
				i.save()
			if p.sms_notification: # SMS
				a = 0
コード例 #17
0
c = conn.cursor()
c.execute('PRAGMA journal_mode= WAL')
d = conn.cursor()
d.execute('PRAGMA journal_mode= WAL')
for row in c.execute('SELECT * FROM core_songDB'):
    if row[6] == 0:
        t = (row[1], )
        d.execute('UPDATE core_songDB SET karaoke_created=1 WHERE full_name=?',
                  t)
        conn.commit()
        separate(row[1], row[2], row[5])
        u = (row[3], )
        e = conn.cursor()
        e.execute('PRAGMA journal_mode= WAL')
        f = conn.cursor()
        f.execute('PRAGMA journal_mode= WAL')
        for row1 in e.execute(
                'SELECT * FROM core_songDB WHERE hash_code=? AND email_sent = 0',
                u):
            send_email(row1[5], row1[2])
            v = (row1[1], )
            f.execute(
                'UPDATE core_songDB SET email_sent=1 WHERE full_name=? AND email_sent=0',
                v)
            conn.commit()
        e.close()
        f.close()
c.close()
d.close()
conn.close()
コード例 #18
0
def profile(request):
    email = request.user.email
    username = request.user.username
    songs = reversed(songDB.objects.filter(user_name=username))
    if request.method == 'POST' and request.FILES:
        BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        myfile = request.FILES['myfile']
        fs = FileSystemStorage(location=os.path.join(BASE_DIR, 'media/songs'))
        song_name = fs.save(myfile.name, myfile)
        to_email_id = email
        file_name = username + song_name
        uploaded_file_url = fs.url(song_name)
        song_location = os.path.join(BASE_DIR, 'media/songs/' + song_name)
        file_location = os.path.join(BASE_DIR, 'media/songs/' + file_name)
        os.rename(song_location, file_location)

        if re.search(".mp3", file_location):
            converter(file_location)
            os.remove(file_location)
            rev_location = file_location[::-1]
            rev_location = re.sub("3pm.", "vaw.", rev_location)
            file_location = rev_location[::-1]

            rev_name = file_name[::-1]
            rev_name = re.sub("3pm.", "vaw.", rev_name)
            file_name = rev_name[::-1]

        BLOCKSIZE = 65536
        hasher = hashlib.md5()
        with open(file_location, 'rb') as afile:
            buf = afile.read(BLOCKSIZE)
            while len(buf) > 0:
                hasher.update(buf)
                buf = afile.read(BLOCKSIZE)
                # store email+song,email,song,hashcode,score,karaoke True/False
                # songDB.objects.create(full_name=file_name,name_of_song=song_name,hash_code = hasher.hexdigest(), score = 100,email_id = to_email_id)
        hash_exists = songDB.objects.filter(hash_code=hasher.hexdigest())
        if hash_exists:

            if hash_exists[0].karaoke_created == 1 and hash_exists[0].email_sent == 1:
                songDB.objects.create(user_name=username, full_name=file_name, name_of_song=song_name, hash_code=hasher.hexdigest(),
                                      score=0, email_id=to_email_id, karaoke_created=1, email_sent=1)

                if (os.path.join(BASE_DIR, 'media/karaoke/' + hash_exists[0].full_name)) != (
                        os.path.join(BASE_DIR, 'media/karaoke/' + file_name)):
                    copyfile(os.path.join(BASE_DIR, 'media/karaoke/' + hash_exists[0].full_name),
                             os.path.join(BASE_DIR, 'media/karaoke/' + file_name))
                    copyfile(os.path.join(BASE_DIR, 'media/vocals/' + hash_exists[0].full_name),
                             os.path.join(BASE_DIR, 'media/vocals/' + file_name))

                send_email(email, song_name)
            else:
                songDB.objects.create(user_name = username, full_name=file_name, name_of_song=song_name, hash_code=hasher.hexdigest(),
                                      score=0, email_id=to_email_id, karaoke_created=1)

        else:
            songDB.objects.create(user_name = username, full_name=file_name, name_of_song=song_name, hash_code=hasher.hexdigest(), score=0,
                                  email_id=to_email_id)
        # import threading
        # separate_thread=myThread(1,file_name,song_name,to_email_id)
        # separate_thread.start()
        # freq_karaoke, time = freq_array(filename)
        songs = reversed(songDB.objects.filter(user_name=username))
        return render(request, 'core/profile.html', {
            'uploaded_file_url': uploaded_file_url, 'filename': song_name,
            'email_id': email, 'songs':songs})
    return render(request, 'core/profile.html', {'songs':songs})
コード例 #19
0
import datetime
import calendar
import smtplib
import os
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import sendEmail

sendEmail.send_email(1)
コード例 #20
0
ファイル: nex.py プロジェクト: JugurthaK/nex
import requests
from bs4 import BeautifulSoup
from keywords import keywords
from findTitle import findTitle
from sendEmail import send_email

URL = 'https://hackernoon.com'
page = requests.get(URL).content
divs = BeautifulSoup(page, 'html.parser').findAll("div", class_="title")

send_email('Jugurtha', findTitle(keywords, divs), keywords)
#print(findTitle(keywords, divs))
コード例 #21
0
 def reject(self, member):
     se.send_email('*****@*****.**', 'eecs_393',
                   member.get_email_address(), self.get_organization_name(),
                   self.get_organization_id(), False)
     return True
コード例 #22
0
                padding: 3px 10px 3px 10px;
              }}
              th.Url, th.Price {{ width: 10% }}
              th.Product {{ width: 80%; }}
            
              </style>
              </head>
              <html>
                <body>
                <br>
                  <table class="mytable">
                    <tr>
                      <th class="Product">Product</th>
                      <th class="Price">Price</th>
                      <th class="Url">Url</th>
                    </tr>
                    <tbody>
                    <tr>
                    <td>{title}</td>
                    <td>£{price}</td>
                    <td><a href={url}>link</a></td>
                    </tr>
                    </tbody>
                  </table>
                </body>
              </html>
              """.format(title=' '.join(title.split()[:15]),
                         price=price,
                         url=url)
        send_email(username, [username], 'Notified', message)
コード例 #23
0
    prog='execute')

parser.add_argument('-d',
                    '--debug',
                    default=os.environ.get('DEBUG', False),
                    action='store_true',
                    help='run in debug mode')

args = parser.parse_args()

if args.debug:
    logging.basicConfig(level=logging.DEBUG,
                        format="%(asctime)s %(levelname)s | %(message)s")
else:
    logging.basicConfig(level=logging.INFO,
                        format="%(asctime)s %(levelname)s | %(message)s")

logger = logging.getLogger(__name__)

# Execute the programs
try:

    # Export the information to excel file
    exportToExcel.export_to_excel()

    # Send Email attachment
    sendEmail.send_email()

except Exception as e:
    logger.exception("Exceptions occured while executing tasks {0}".format(e))
コード例 #24
0
 def requestPermission(self, admin: Administrator) -> bool:
     se.send_email('*****@*****.**', 'eecs_393',
                   admin.get_email_adderss(), self.get_name(),
                   self.get_id(), True)
     return True
コード例 #25
0
def test(username, password, log_file):

    url = "http://passport.weibo.cn/sso/login"
    headers = {
        "Host":
        "passport.weibo.cn",
        "Connection":
        "keep-alive",
        "Origin":
        "https://passport.weibo.cn",
        "Referer":
        "https://passport.weibo.cn/signin/login?entry=mweibo&r=https%3A%2F%2Fweibo.cn%2F&backTitle=%CE%A2%B2%A9&vt=",
        "User-Agent":
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
    }
    another_headers = {
        "Host":
        "passport.weibo.cn",
        "Connection":
        "keep-alive",
        "User-Agent":
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
    }
    data = {
        "username": username,
        "password": password,
        "savestate": "1",
        "r": "https://weibo.cn",
        "ec": "0",
        "pagerefer": "https://weibo.cn/pub/?vt=",
        "entry": "mweibo",
        "wentry": "",
        "loginfrom": "",
        "client_id": "",
        "code": "",
        "qq": "",
        "mainpageflag": "1",
        "hff": "",
        "hfp": ""
    }
    sess = requests.Session()
    try:
        # 用户登录
        sess.post(url=url, headers=headers, data=data, timeout=1)
        log(log_file=log_file,
            message="succeeded to login weibo, started a new session")
    except Exception as e:
        log(log_file=log_file, message="failed to login weibo\n" + str(e))
        send_email(content="failed to login weibo\n" + str(e),
                   subject="An exception occured")
        raise e
    home_url = "http://weibo.cn/"
    # response = sess.get(url, verify=False)
    panda_url = "http://weibo.cn/u/5406698634?page=4"
    panda_header = {
        "Host": "weibo.cn",
        "Connection": "keep-alive",
        "User-Agent":
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36",
        "Referer": "https://weibo.cn/u/5406698634?page=3",
    }
    another_panda_header = {
        "Host": "weibo.cn",
        "Connection": "keep-alive",
        "User-Agent":
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36",
        "Referer": "https://weibo.cn/u/5406698634?page=2",
    }
    another_panda_url = "http://weibo.cn/u/5406698634"
    error = 1
    while True:
        time.sleep(random.random())
        try:
            sess.get(url=panda_url,
                     headers=panda_header,
                     verify=False,
                     timeout=5)
            # sess.get(url = another_panda_url  , headers=another_panda_header, verify=False)
            log(log_file=log_file,
                message="succeeded to get the web_page whose url is {0}".
                format(panda_url))
            print("get panda_url")
        except Exception as e:
            # 记录异常信息
            log(log_file=log_file,
                message="failed to get the web_page whose url is {0}".format(
                    panda_url))
            # 记录异常原始信息
            log(log_file=log_file, message="\n" + str(e))
            send_email(
                content="failed to get the web_page whose url is {0}\n".format(
                    panda_url) + str(e),
                subject="An exception occured")
            print("----------------------------------------")
            print(e)
            print("----------------------------------------")
            # raise Exception()
            error += 1
            # 应对服务器强制断开连接的情况
            if error > 10:
                raise Exception()
            continue

        try:
            sess.get(url=home_url, verify=False, timeout=5)
            log(log_file=log_file,
                message="succeeded to get the web_page whose url is {0}".
                format(home_url))
            print("get home")
        except Exception as e:
            log(log_file=log_file,
                message="failed to get the web_page whose url is {0} \n".
                format(home_url) + str(e))

            send_email(
                content="failed to get the web_page whose url is {0}\n".format(
                    home_url) + str(e),
                subject="An exception occured")
            print("----------------------------------------")
            print(e)
            print("----------------------------------------")
            error += 1
            # 应对服务器强制断开连接的情况
            if error > 10:
                raise Exception()
            continue
            # raise e

        # time.sleep(random.random())
        # response = sess.get(url = another_panda_url, headers=another_panda_header, verify=False)
        global num
        global loop
        print(num, loop, num + (loop - 1) * 3000)
        log(log_file=log_file,
            message=
            "the current num of this batch is {0}, loop is {1}, total num is {2}"
            .format(num, loop, num + (loop - 1) * 3000))
        num = num + 1
        # if num > 3:
        # raise Exception()
        if num > 3000:
            send_email(content="开始第{0}回爬取,共爬取了{1}次".format(
                loop, (loop) * 3000),
                       subject="number")
            loop += 1
            num = 0
            log(log_file=log_file,
                message=
                "end this session, the num is placed with 0, a new session will be created"
                )
            break
コード例 #26
0
ファイル: jira_3.py プロジェクト: oilbean/count
        for m in range(len(today_issues)):

            all_today_issues.append(today_issues[m])
            all_version_issues.append(version_issues[m])
            all_group_issue1.append(group_issue1[m])

            all_excel_data.append(excel_data[m])

    logging.info("今日缺陷" + str(all_today_issues))
    logging.info("版本缺陷汇总" + str(all_version_issues))
    logging.info("分组情况" + str(all_group_issue1))

    total = today_total(all_today_issues, all_version_issues)

    write_email(all_today_issues, all_version_issues, total, all_group_issue1)
    excel_name = str(datetime.date.today()) + "BUG统计"

    a = today_issues_title + all_today_issues
    b = version_issues_title + all_excel_data

    # excel.write(excel_name,a,b,group_issue1)

    all_group_issue1 = ["缺陷分组"] + all_group_issue1

    excel.write(excel_name, a, b, all_group_issue1)

    with open(os.getcwd() + '/Template/' + 'recevers.txt', 'r') as f:
        recevers = f.read().splitlines()

    sendEmail.send_email(excel_name, recevers, "em.html")
コード例 #27
0
    # Open the email template
    message = open("assignmentsEmail.txt", "r").read()

    # Grab the current URM's email
    email = urmEmails[urm]

    # Grab the URM's first name
    firstName = urm.split(',')[1].split(' ')[1]

    # Enforce that the Lifetime Household Recognition for prospects that have not given shows up as 0
    assignment['Lifetime Household Recognition'] = assignment[
        'Lifetime Household Recognition'].fillna(0)

    # Enforce that any other missing data shows up as a blank space
    assignment = assignment.fillna('')

    # Format Lifetime Household Recognition as currency
    assignment['Lifetime Household Recognition'] = assignment.apply(
        lambda x: "${:,.0f}".format(x['Lifetime Household Recognition']),
        axis=1)

    # Insert the URM's first name and assignments into the email template
    message = message.format(firstName, assignment.to_html(index=False))

    # Send the email to the current URM
    send_email(sender='sender',
               recipient=email,
               subject='Newly Assigned Prospects',
               message=message,
               cc=['cc_addresses'])
コード例 #28
0
while True:
    try:
        token_str = json.loads(
            get_html('https://www.wesai.com/index.php?r=user/getcuruser')
        )['data']['token'].encode('utf8')
        print token_str
        bs_txt_html = get_html(
            'https://www.wesai.com/api/rest/' + token_str +
            '/Java/item/queryItem/%7B%22itemQuery%22:%7B%22allPlatform%22:false,%22cityId%22:%220%22,%22cityName%22:%22%E5%85%A8%E5%9B%BD%22,%22itemTypeId%22:null,%22itemTypePid%22:%228a8283eb55dfd9600156029f3ce00011%22,%22keyword%22:null,%22onlineId%22:null,%22showStartTime%22:null,%22showEndTime%22:null,%22venueId%22:%22%22,%22orderType%22:null,%22curpage%22:1,%22pagesize%22:8%7D%7D?v=1487678065856'
        )
        #         print bs_txt_html
        bs_txt_html_str = bs_txt_html.encode('utf-8')
        bs_txt_html_str_json = json.loads(bs_txt_html_str)
        bs_txt_html_str_json_array = bs_txt_html_str_json['itemResult'][
            'items']
        for one_bs_txt_html_str_json_array in bs_txt_html_str_json_array:
            one_bs_txt_html_str_json_array_one_str = one_bs_txt_html_str_json_array[
                'itemTitleCN'].encode('utf8')
            if '杭州' in one_bs_txt_html_str_json_array_one_str:
                send_email(text='开始卖票了')
                #此处可以发邮件 发短信 做推送通知
                sleep(60 * 5)
        sleep(30)
    except:
        pass
# print bs_txt_html_str
# bs_txt_html_list =bs_txt_html.findAll('div', {'class':'ddleft'})
# for one_bs_txt_html_list in bs_txt_html_list:
#     print rm_all_pasce(one_bs_txt_html_list.get_text().encode('utf-8'))
# print(len(bs_txt_html_list))