Beispiel #1
0
def telegram_bot_send_photo(photo_path):

    BOT_TOKEN = CommonUtility.getParameterFromFile('BOT_TOKEN')
    BOT_CHATID = str(CommonUtility.getParameterFromFile('BOT_CHATID'))

    url = f"https://api.telegram.org/bot{BOT_TOKEN}/sendPhoto"
    files = {}
    files["photo"] = open(photo_path, "rb")

    requests.get(url, params={"chat_id": BOT_CHATID}, files=files)
Beispiel #2
0
def telegram_bot_send_message(bot_message):

    BOT_TOKEN = CommonUtility.getParameterFromFile('BOT_TOKEN')
    BOT_CHATID = str(CommonUtility.getParameterFromFile('BOT_CHATID'))

    send_text = 'https://api.telegram.org/bot' + \
                                     BOT_TOKEN + \
                       '/sendMessage?chat_id=' + \
                                    BOT_CHATID + \
                  '&parse_mode=Markdown&text=' + bot_message

    requests.get(send_text)
Beispiel #3
0
def execute(page_content, competition_cod):

    squadre_casa = page_content.findAll('div', attrs={"class": "hometeam"})
    squadre_trasferta = page_content.findAll('div',
                                             attrs={"class": "awayteam"})
    prediction_1x2 = page_content.findAll('td',
                                          attrs={"class": "center yellow"})
    prediction_goals_and_res = page_content.findAll(
        'td', attrs={"class": "center32"})[6:]

    df_soccvista_pred = pd.DataFrame(
        index=range(len(squadre_casa)),
        columns=['Home_Team', 'Away_Team', '1x2_Tip', 'OvUn_Tip', 'ExRes_Tip'])
    i = 0
    j = 0

    while (i < len(squadre_casa)):

        df_soccvista_pred.values[i][0] = squadre_casa[j].text
        df_soccvista_pred.values[i][1] = squadre_trasferta[j].text
        df_soccvista_pred.values[i][2] = prediction_1x2[j].text
        df_soccvista_pred.values[i][3] = CommonUtility.getParameterFromFile(
            prediction_goals_and_res[6 * j + 4].text)
        df_soccvista_pred.values[i][4] = prediction_goals_and_res[6 * j +
                                                                  5].text

        i = i + 1
        j = j + 1

    mycursor.execute("DELETE FROM {}.soccervista_predictions \
                      WHERE competition_cod ='{}'".format(
        DB_SCHEMA, competition_cod))

    sql = "INSERT INTO {}.soccervista_predictions (home_team,\
                                                   away_team,\
                                                   1x2_tip,\
                                                   OvUn_tip,\
                                                   ExRes_tip,\
                                                   competition_cod) VALUES (%s,%s,%s,%s,%s,%s)".format(
        DB_SCHEMA)
    for i in df_soccvista_pred.index:
        val = (df_soccvista_pred.values[i][0],df_soccvista_pred.values[i][1],df_soccvista_pred.values[i][2],\
               df_soccvista_pred.values[i][3],df_soccvista_pred.values[i][4],competition_cod)
        mycursor.execute(sql, val)
        mydb.commit()
Beispiel #4
0
    content = ">" + name + ":[" + str(expend_start) + ":" + str(
        expend_end) + "]\n" + seq + "\n"

    extension_file_content += content

    shape_content = ""
    for i in range(expend_start, expend_end):
        shape_content += str(i + 1) + " " + str(
            Reactivity.getReactivity(name, i))

    key = "mir837_" + name + "_" + str(expend_start) + "_" + str(expend_end)
    seq_file_name = "F:\\JIC\\Arabidopsis\\Extension\\" + key + ".seq"
    shape_file = "F:\\JIC\\Arabidopsis\\Extension\\" + key + ".shape"
    ct_file = "F:\\JIC\\Arabidopsis\\Extension\\" + key + ".ct"
    svg_file = "F:\\JIC\\Arabidopsis\\Extension\\" + key + ".svg"
    CommonUtility.CreateFile(seq_file_name, content)
    CommonUtility.CreateFile(shape_file, shape_content)
    command = "fold " + seq_file_name + " " + ct_file + " --dms " + shape_file
    print(command)
    command = "draw.exe " + ct_file + " " + svg_file + " --svg -n 1"
    #print(command)
    count = count + 1
    if count > 500:
        break

fasta_sequences.close()

output_file = open(
    "F:\\JIC\\Arabidopsis\\Extension\\AAACGAACAAAAAACUGAUGG.extension.fasta",
    "w")
output_file.write(extension_file_content)
Beispiel #5
0
import requests
import hashlib
from bs4 import BeautifulSoup
import datetime
import CommonUtility, Utility
import pandas as pd
import mysql.connector
import os
import Soccervista

DB_USER = CommonUtility.getParameterFromFile('DATABASE_USER')
DB_PORT = CommonUtility.getParameterFromFile('DATABASE_PORT')
DB_PWD = CommonUtility.getParameterFromFile('DATABASE_PWD')
DB_SCHEMA = CommonUtility.getParameterFromFile('DATABASE_SCHEMA')
ENV = CommonUtility.getParameterFromFile('ENV')
LEAGUES_LIST_PATH = os.path.dirname(os.getcwd())
HEADERS = {
    'User-Agent':
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) \
            Chrome/61.0.3163.100 Safari/539.36'
}

mydb = mysql.connector.connect(user=DB_USER,
                               password=DB_PWD,
                               host='127.0.0.1',
                               auth_plugin='mysql_native_password')
mycursor = mydb.cursor()

Utility.telegram_bot_sendlog("START main_soccervista.py")

now = datetime.datetime.now()
Beispiel #6
0
import CommonUtility
import requests
import sys

BOT_TOKEN = str(CommonUtility.getParameterFromFile('BOT_TOKEN'))
BOT_CHATID = str(CommonUtility.getParameterFromFile('BOT_CHATID'))

if __name__ == '__main__':

    with open("notifications//{}".format(sys.argv[1]),
              "r") as bot_message_file:
        bot_message = bot_message_file.read()

    send_text = 'https://api.telegram.org/bot' + \
                                     BOT_TOKEN + \
                       '/sendMessage?chat_id=' + \
                                     BOT_CHATID + \
                  '&parse_mode=Markdown&text=' + \
                                     '\U0001F6A8 \U0001F6A8 \U0001F6A8 \U0001F6A8 \U0001F6A8 \U0001F6A8 \U0001F6A8  \n ' + \
                                     bot_message

    requests.get(send_text)
import datetime
import CommonUtility
import pandas as pd
import mysql.connector

DB_USER = CommonUtility.getParameterFromFile('DATABASE_USER')
DB_PORT = CommonUtility.getParameterFromFile('DATABASE_PORT')
DB_PWD = CommonUtility.getParameterFromFile('DATABASE_PWD')
DB_SCHEMA = CommonUtility.getParameterFromFile('DATABASE_SCHEMA')
LEAGUES_LIST_PATH = CommonUtility.getParameterFromFile('LEAGUES_LIST_PATH')

mydb = mysql.connector.connect(user=DB_USER,
                               password=DB_PWD,
                               host='127.0.0.1',
                               auth_plugin='mysql_native_password')
mycursor = mydb.cursor()

now = datetime.datetime.now()


def execute(page_content, competition_cod, hash):

    teams = page_content.findAll(
        'td',
        attrs={"class": "participant_name col_participant_name col_name"})
    points = page_content.findAll('td', attrs={"class": "points col_points"})

    df_rankings = pd.DataFrame(index=range(len(teams)),
                               columns=['Team', 'Points'])
    i = 0
Beispiel #8
0
def build_bot_message(last_match, method_match, soccervista_prediction,
                      soccervista_goals, soccervista_exactresult, tip,
                      rank_home, points_home, rank_away, points_away,
                      number_of_teams):

    bot_message_last_match = "\n \
\U0001F4C5 {} \n \
{} \n \
\U000026BD {}-{} \n \
\U00002714 {}:{} \n \
\U0001F3B2 @{} @{} @{} \n \
-------------------------------- \n".format(
        str(last_match[7].day) + '/' + str(last_match[7].month) + '/' +
        str(last_match[7].year),
        CommonUtility.getParameterFromFile(last_match[8]), last_match[0],
        last_match[1], last_match[5], last_match[6], last_match[2],
        last_match[3], last_match[4])

    bot_message_next_match = "\n \
\U0001F4C5 {} \U0000231A {} \n \
\n \
{} \n \
\n \
\U000026BD {}-{} \n \
\n \
\U0001F3B2 @{} @{} @{} \n  \
\n \
\U0001F449 Tip: {} \n \
\n \
Rankings: {}° vs {}° \n \
Points: {} pts vs {} pts \n \
Top {}% vs Top {}% \n \
\n \
Soccervista Prediction: \n \
{} \n \
{} \n \
{}".format(
        str(method_match[5]).split(' ')[0][8:10] + '/' +
        str(method_match[5]).split(' ')[0][5:7] + '/' +
        str(method_match[5]).split(' ')[0][:4],
        str(method_match[5]).split(' ')[1][:5],
        CommonUtility.getParameterFromFile(method_match[6]), method_match[0],
        method_match[1], method_match[2], method_match[3],
        method_match[4], tip, int(rank_home), int(rank_away), int(points_home),
        int(points_away), round((rank_home / number_of_teams) * 100, 0),
        round((rank_away / number_of_teams) * 100, 0), soccervista_prediction,
        soccervista_goals, soccervista_exactresult)

    telegram_bot_send_message(bot_message_last_match + bot_message_next_match)

    file_name = "{}_{}_{}_{}".format(
        method_match[0].replace(' ', '-'), method_match[1].replace(' ', '-'),
        str(method_match[5]).split(' ')[0][8:10] + '_' +
        str(method_match[5]).split(' ')[0][5:7] + '_' +
        str(method_match[5]).split(' ')[0][:4],
        str(method_match[5]).split(' ')[1][:5])

    text_file = open("notifications//{}.txt".format(file_name), "w+")

    text_file.write(bot_message_last_match + bot_message_next_match)
    text_file.close()

    scheduler(file_name)