コード例 #1
0
def get_ball(reb_count,red_max,blue_count,blue_max):
    # 循环一百遍,一遍代表一年
    for i in range(0,100):
        # 红球(5个,最大35)
        red_ball = luck(reb_count,red_max)
        red_ball.append('-')

        # 篮球(2个,最大12)
        blue_ball = luck(blue_count,blue_max)
        # 如果第3个红球<=10,则再生成一次
        if red_ball[2] <= '10':
            continue
        else:
            # 幸运号码
            ball_list = red_ball+blue_ball
            # 把号码格式化一下,好看点
            beautiful_ball = ''
            for j in range(0,len(ball_list)):
                beautiful_ball += ball_list[j] + ' '
            print(beautiful_ball)

            # 生成图片
            create_image.create_image(beautiful_ball)

            # 发送邮件
            send_mail.send_mail()
            break
コード例 #2
0
    def run_button(self):
        # Sets whatever res you put into the res boxes.
        width = self.ui.width_line.text()
        height = self.ui.height_line.text()
        c.width = int(width)
        c.height = int(height)

        # For the fps
        fps = self.ui.fps_line.text()
        c.fps = int(fps)

        # Print using this length
        length = self.ui.length_line.text()
        c.length_frames = int(length)

        main_text, title_sheet = fs.get_sheet()  # get sheet data and title
        if c.flag_create_image:
            create_image.create_image(
                main_text)  # Creates an png Image using string
        if c.flag_create_video:
            make_video.make_video(
            )  # way of getting png into a movie sequence. Can me done on FFmpeg
        if c.flag_delete_images_when_done:  # deleting images
            os.listdir('images')
            for i in os.listdir('images'):
                os.remove(f"images/{i}")
コード例 #3
0
ファイル: bot.py プロジェクト: zhongdaoyou/slashStock
def get_out_filename(symbol, time_span, quote):
    r = requests.get(CHART_API % (symbol, time_span), stream=True)

    filename = ''
    if r.status_code == 200:
        filename = 'charts/%s-%s.png' % (symbol, now_str())
        final_filename = 'charts/%s-%s-final.png' % (symbol, now_str())
        with open(filename, 'wb') as f:
            r.raw.decode_content = True
            shutil.copyfileobj(r.raw, f)
        create_image(quote, filename, final_filename)

    logging.info('get_chart_filename: %s--%s--%s' %
                 (symbol, time_span, filename))
    return final_filename
コード例 #4
0
ファイル: bot.py プロジェクト: mihirk11/slashStock
def get_out_filename(symbol, time_span, quote):
    r = requests.get(CHART_API % (symbol, time_span), stream=True)

    filename = ''
    if r.status_code == 200:
        filename = 'charts/%s-%s.png' % (symbol, now_str())
        final_filename = 'charts/%s-%s-final.png' % (symbol, now_str())
        with open(filename, 'wb') as f:
            r.raw.decode_content = True
            shutil.copyfileobj(r.raw, f)
        create_image(quote, filename, final_filename)

    logging.info('get_chart_filename: %s--%s--%s' % (symbol, time_span,
                                                     filename))
    return final_filename
コード例 #5
0
def main():
    if request.method == 'POST':
        time_result = request.form["time_result"]
        return redirect(url_for('result', time_result=time_result))
    else:
        answer_area_x, answer_area_y = create_image.create_image()
        return render_template("main.html",
                               answer_area_x=answer_area_x,
                               answer_area_y=answer_area_y)
コード例 #6
0
ファイル: TrackMBTA.py プロジェクト: johnsliao/TrackMBTA
    def on_success(self, data):
        # Twitter settings
        TrackMBTA = Twython(twitter['key'],
                            twitter['secret_key'],
                            twitter['token'],
                            twitter['secret_token'])

        tweet_text = data['text'].lower()
        tweet_from = data['user']['screen_name']
        tweet_id = data['id']
        in_reply_to_status_id = data['in_reply_to_status_id']

        logging.info("TWITTER STREAM TWEET (containg @TrackMBTA): %s" % tweet_text)

        """
            Acceptable tweet format:

            @TrackMBTA <Train Line> <Direction>

        """

        if tweet_from not in BLACKLIST and in_reply_to_status_id is None:
            split_tweet = tweet_text.split(' ') # Not very robust way to parse tweet. Fix later

            my_handle = split_tweet[0] # @TrackMBTA
            route_input = split_tweet[1].lower() # <Train Line>
            direction_input = split_tweet[2].lower() # Direction

            route_id = does_route_exist(route_input)
            direction_name = does_direction_exit(direction_input)

            if route_id is not None:
                if direction_name is not None:
                    logging.info("Tweet received: %s from %s" % (tweet_text, tweet_from))

                    # Will return lat, lon = 0,0 if no train found
                    lat, lon = query_mbta(route_id, direction_name)

                    if lat is not 0 and lon is not 0:
                        # Generate reply tweet
                        reply_tweet = generate_reply_tweet(tweet_from)

                        # Generate google map
                        create_image(lat, lon)

                        # Respond with tweet
                        path_to_map = "./images/maps/%s,%s.jpg" % (lat,lon)

                        if os.path.exists(path_to_map) is True:
                            logging.info("Saving map file to %s" % path_to_map)
                            fname = open(path_to_map, 'rb')
                            logging.info("Generated reply tweet: %s" % reply_tweet)
                            TrackMBTA.update_status_with_media(status=reply_tweet,
                                                               media=fname,
                                                               in_reply_to_status_id=tweet_id)
                        else:
                            raise ImportError("Import file error, %s" % path_to_map)
                    else:
                        generate_error_tweet(TrackMBTA, tweet_from, tweet_id)
                else:
                    generate_error_tweet(TrackMBTA, tweet_from, tweet_id)
            else:
                generate_error_tweet(TrackMBTA, tweet_from, tweet_id)
コード例 #7
0
import torch
from torch.utils.data import DataLoader

from architectures import RCAN
from create_image import create_image
from dataLoader import Loader

net = RCAN(64, 10, 20)
net.load_state_dict(torch.load("div2k/parameters/rcan_parameters.pth"))
net.to(torch.device("cuda:0"))

loader = Loader('val', scale=2, make_crop=False)
create_image(net, loader, "mrcan_result", upscaling=2, multiscale=False)