示例#1
0
def textFinalScore(homeTeam, home_runs, awayTeam, away_runs):
    """
    Texts the user the final score at the end of the game.
    param homeTeam: the home team.
    param home_runs: the current runs scored by the home team.
    param awayTeam: the away team.
    param awayRuns: the current runs scored by the away team.
    """
    message = 'Final\n' + homeTeam + ': ' + home_runs + ' ' + awayTeam + ': ' + away_runs
    textmyself(message)
示例#2
0
def textInningScore(inning, homeTeam, home_runs, awayTeam, away_runs):
    """
    Texts the user the current score at the end of each inning.
    param inning: the inning that just ended.
    param homeTeam: the home team.
    param home_runs: the current runs scored by the home team.
    param awayTeam: the away team.
    param awayRuns: the current runs scored by the away team.
    """
    message = 'End ' + inning + ':\n' + homeTeam + ': ' + home_runs + ' ' + awayTeam + ': ' + away_runs
    textmyself(message)
示例#3
0
def textPlay(homeTeam, home_runs, awayTeam, away_runs, playInning, play):
    """
    Texts the user the most recent play.
    param homeTeam: the home team.
    param home_runs: the current runs scored by the home team.
    param awayTeam: the away team.
    param awayRuns: the current runs scored by the away team.
    param playInning: the inning the play occurred.
    param: the play.
    """
    message = playInning + ': ' + play + '\n\n' + homeTeam + ': ' + home_runs + ' ' + awayTeam + ': ' + away_runs
    textmyself(message)
示例#4
0
# City ID, Boston: 4930956
url = 'http://api.openweathermap.org/data/2.5/forecast/city?id=4930956&units=imperial&APPID=' # Add API key here
response = requests.get(url)
response.raise_for_status()

# Load JSON data into a python variable

weatherData = json.loads(response.text)

# Print today's date
#print("Today is " + weekDay+ ", "+ date)

# Print weather descriptions

w = weatherData['list']

tmp = []

for i in w:
	if i['dt_txt'][:10] == today:
		if i['weather'][0]['main'] == 'Rain':
			tmp.append(i['dt_txt'][-8:-3] + ': ' + i['weather'][0]['main'] + ' - ' + i['weather'][0]['description'] \
			+ ' ' + str(i['clouds']['all']) + '%' + ' - ' + str(i['main']['temp']) + '°F' + '\n')
		elif i['weather'][0]['main'] == 'Clouds':
			tmp.append(i['dt_txt'][-8:-3] + ': ' + i['weather'][0]['main'] + ' - ' + i['weather'][0]['description'][:-7] \
			+ ' ' + str(i['clouds']['all']) + '%' + ' - ' + str(i['main']['temp']) + '°F' + '\n')

message = 'Current weather in Boston:\n' + "".join(tmp)
print(message)
textMyself.textmyself(message)
'''
Created on Jul 27, 2017

@author: Himanshu Ranjan
'''

import textMyself

textMyself.textmyself('The boring task is finished now')
示例#6
0
#! python3
# umbrellaReminder.py

import requests, json, pprint

import sys
sys.path.insert(0, r'D:\Drive\Code\Random')
import file
sys.path.insert(0, r'D:\Drive\Code\ATBSWP\Chapter_16')
import textMyself

location = file.myLocation
API = file.wheAPI
url = f'http://api.openweathermap.org/data/2.5/forecast?q={location}&appid={API}'
response = requests.get(url)
response.raise_for_status()
weatherData = json.loads(response.text)
w = weatherData['list']

if w[1]['weather'][0]['main'] == 'Rain':
    weatherTom = w[1]['weather'][0]['main'] + ' - ' + w[1]['weather'][0][
        'description']
    textMyself.textmyself(weatherTom)
    print(weatherTom)
else:
    print('Umbrella not needed')
        if r.status_code == 200:
            verify_cisco = re.compile(r'(ip phone)', re.I)
            mo = verify_cisco.search(r.text)
            print('Cisco ' + mo.group())
            ip_phone += 1

            if mo is not None:
                # If 'ip phone' found,
                # filter out only these models
                typeRegex = re.compile(r'(7942G|7962G|7911G|7925G)')
                mo2 = typeRegex.search(r.text)

                if mo2 is not None:
                    # Model above found
                    print('***FOUND ONE!***')
                    match_phones += 1
                    scrape(r)

    except Exception as err:
        'There was an error'


scan_time = round(time.time() - start_time)
print('The scan took', scan_time, 'seconds to run.')
print(ip_phone, 'IP phones.')
print(match_phones, 'Matching phones.')

textMyself.textmyself('The task completed. {} IP phones. {} matching phones. '
                      'The scan took {} seconds to run.'.format(ip_phone,
                      match_phones, scan_time))
示例#8
0
"""
Umbrella Reminder.
Checks a weather website and texts you if it is raining.
"""

import requests, bs4, time, datetime, textMyself  # text myself needs
# your own details adding to it

# Requests url
url = 'https://weather.com/en-GB/weather/today/l/0686a91b1d358b3b51a3e8afdb37eda3d1a214b4b537eccba697666ab69ac9e7'
res = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'})
res.raise_for_status()
soup = bs4.BeautifulSoup(res.text, 'html.parser')

# Finds the element in the weather site with the weather conditions
weatherElem = soup.find("div", class_="CurrentConditions--phraseValue--2xXSr")

# Will say if it is raining or not by text
if "Rain" in str(weatherElem.text):
    textMyself.textmyself('It gonna rain!')
else:
    print("It is not raining...")

# Set up task scheduler - would use Task Scheduler for windows, with a .bat file
示例#9
0
import os
import pyperclip
from pytube import YouTube
import textMyself

os.chdir(r'C:\Users\SOLO\Downloads')

link = pyperclip.paste() #'https://www.youtube.com/watch?v=fN017XSZN44'

try:
    yt = YouTube(link)
    print(yt.title)
    stream = yt.streams.first()
    stream.download()
    print('Task Completed!')
    textMyself.textmyself(str(yt.title)+'Video from youtube just finished downloading')
except:
    print("Connection Error")




    
    
        
示例#10
0
import textMyself

textMyself.textmyself("Hello Solomon, I am here with Abbey")