Exemple #1
0
def main():
    if not os.path.exists(FILE_DIR):
        os.mkdir(FILE_DIR)
    if TEST_MODE:
        f = open("rirakkuma.html", "r")
        p = f.read()
        f.close()
    else:
        req = urllib2.Request(URL)
        response = urllib2.urlopen(req)
        p = response.read()
    rh = RilakkumaHTML()
    rh.feed(p)
    img_path = rh.get_img()
    img_file = img_path.split("/")[1]
    filename = datetime.now().strftime("%Y%m%d.gif")
    save_path = os.path.join(FILE_DIR, filename)
    if __has_image(img_file):
        __log("Already img file in save dir", img_file)
        return
    url = URL + img_path
    req = urllib2.Request(url)
    response = urllib2.urlopen(req)
    page = response.read()
    f = open(save_path, "w")
    f.write(page)
    f.close()
    __log("Fetch new image", img_file)
    __save_detail(img_file)
    if NOTIFICATION:
        tweet.main()
    return
Exemple #2
0
def main():
	global PBon
	global PBobj
	PB=""
	thread = Thread(target = op.thread_func, args = (t_stop,))
	thread.start()
	while True:
		options = ["Choose one of the following"]
		options.append("Cricket Scores")
		options.append("Coding Contest Updates")
		options.append("Tweets")
		options.append("Custom Notification with user defined frequency")
		options.append("Remove any set notification")
		if(PB == ""):
			options.append("Want Notifications on Your PushBullet Devices? Enter Access Token here.")
			PBon = 0
		else:
			options.append("PushBullet Device Set Up Successfully. Want to remove the Access Token?")
			PBon = 1
		options.append("Quit")
		try:
			optionChosen = ip.getUserInput(options)
		except KeyboardInterrupt:
			exitApp()
		if optionChosen == len(options)-1:
			exitApp()
		if(optionChosen == len(options) -2):
			if(PB == ""):
				PB=ip.inputData("PushBullet","Enter Valid Access Token")
				if PB != "":
					try:
						PBobj=Pushbullet(PB) 
						PBon = 1
						op.popUp("Notify","Successfull Setup",1)
					except Exception as e:
						op.popUp("PushBullet","Wrong Access Token or Network Error\nTry Again",0)
						PB=""
			else:
				op.success()
				PB=""
			continue
		if(optionChosen == 1):
			cricket.main()

		if(optionChosen == 2):
			coding.main()

		if(optionChosen == 3):
			tweet.main()

		if(optionChosen == 4):
			custom.getData()
		
		if(optionChosen == 5):
			remove.main()
Exemple #3
0
# import libraries
import tweet

print("NLP Crawler 0.1")

if __name__ == "__main__":
    tweet.main()

line_cnt = sum(1 for line in f) #行数を取得
d = datetime.datetime.today()
random.seed(d.hour + d.second)
ran = random.randint(2,line_cnt)
f.close()

#一行読み出し
line = linecache.getline(argv,ran)

#もし乱数で見出しを引いてしまった時の処理
if re.search(r'== +\S+ ==', line):
    ran = ran - 2
    line = linecache.getline(argv,ran)
    pass
line = line.replace('*','')

#見出しを持ってくる
for i in reversed(range(ran)):
    topic_line = linecache.getline(argv,i)
    if re.search(r'== +\S+ ==', topic_line):
        topic_line = topic_line.replace('==','')
        topic_line = topic_line.replace(' ','')
        break
        pass
    pass

now_tweet = tweet_day + 'の' + topic_line + line
print (now_tweet)

tweet.main(now_tweet)
line_cnt = sum(1 for line in f)  #行数を取得
d = datetime.datetime.today()
random.seed(d.hour + d.second)
ran = random.randint(2, line_cnt)
f.close()

#一行読み出し
line = linecache.getline(argv, ran)

#もし乱数で見出しを引いてしまった時の処理
if re.search(r'== +\S+ ==', line):
    ran = ran - 2
    line = linecache.getline(argv, ran)
    pass
line = line.replace('*', '')

#見出しを持ってくる
for i in reversed(range(ran)):
    topic_line = linecache.getline(argv, i)
    if re.search(r'== +\S+ ==', topic_line):
        topic_line = topic_line.replace('==', '')
        topic_line = topic_line.replace(' ', '')
        break
        pass
    pass

now_tweet = tweet_day + 'の' + topic_line + line
print(now_tweet)

tweet.main(now_tweet)
Exemple #6
0
upSpeedList = []

#runs speedtest-cli 3 times and stores down and up values with lists
while i < 3:
 #print(i)
 downSpeed, upSpeed = check_speedTest()
 downSpeedList.append(downSpeed)
 upSpeedList.append(upSpeed)
 i = i + 1

#Add up both lists to get a total
for itemDown, itemUp in zip(downSpeedList, upSpeedList):
    downTotal = downTotal + float(itemDown)
    upTotal = upTotal + float(itemUp)

#Get averages of download and upload speed
avgDown = downTotal/3
avgUp = upTotal/3

#Find out if averages meet the requirements to send out a tweet
if avgDown < 50.0 and avgUp < 10.0:
    tweet.main("Why pay for 150Mbps when I am receiving %.2fmbps download and %.2fmbps upload on average. "
               "Please fix! #comcast #comcastsucks" % (avgDown, avgUp))
else:
    if avgDown < 40.0:
        tweet.main("Paying for 150Mbps and I am receiving %.2fmbps download on average. Please fix! "
                   "#comcast #xfinity #comcastdoesntcare" % avgDown)
    else:
        sys.exit(0)

def lambda_handler(event, context):
    success, tw = main()
    return {'statusCode': 200, 'body': tw, 'success': success}