def test(): return render_template("test.html", weather = weather.get_weather(), quote = quote.format_quote(quote.get_quote()), food = food.get_food_master(), bus_bcc = bus.get_predictions_for("Busch Campus Center"), bus_hill = bus.get_predictions_for("Hill Center"))
def generate(url): get_name = urlparse.parse_qs(urlparse.urlparse(url).query)['name'][0] get_image = urlparse.parse_qs(urlparse.urlparse(url).query)['image'][0] get_quote = urlparse.parse_qs(urlparse.urlparse(url).query)['quote'][0] print get_name print get_image print get_quote print '>> getting image' image_data = flickr.get_pic(get_image) print '>> getting artist_name' artist_name = wikipedia.get_title(get_name) print '>> getting quote' song_title = quote.get_quote(get_quote) print '>> writing image' u = uuid.uuid4() fp = open('image-%s.jpg' % u, 'wb') fp.write(image_data); fp.close(); print '>> visual manip' cmd = ['sh', 'fakealbum.sh', str(u), str(artist_name), str(song_title)] subprocess.call(cmd) print '>> returning image' gen_image = open('gen-%s.jpg' % u, 'rb').read(); cmd = ['rm', 'gen-%s.jpg' % u] return gen_image;
async def echo(message: types.Message): """ Answer to random queries """ try: answer = quote.get_quote(model) except: answer = "Я не понимаю этот запрос :(" await message.answer(answer)
def post(self): urlfetch.set_default_fetch_deadline(60) body = json.loads(self.request.body) logging.info('request body:') logging.info(body) self.response.write(json.dumps(body)) update_id = body['update_id'] try: message = body['message'] except: message = body['edited_message'] message_id = message.get('message_id') date = message.get('date') text = message.get('text') fr = message.get('from') chat = message['chat'] chat_id = chat['id'] if not text: logging.info('no text') return def reply(msg=None): if msg: json_keyboard = json.dumps({ 'keyboard': [["Quote"]], 'one_time_keyboard': False, 'resize_keyboard': True }) resp = urllib2.urlopen( BASE_URL + 'sendMessage', urllib.urlencode({ 'chat_id': str(chat_id), 'text': msg.encode('utf-8'), 'disable_web_page_preview': 'true', 'reply_markup': json_keyboard, })).read() else: logging.error('no msg specified') resp = None logging.info('send response:') logging.info(resp) if text == 'Quote': q_id, q_text = get_quote() reply('Quote %s:\n%s' % (q_id, q_text)) if text.startswith('/'): if text == '/start': reply('Press "Quote".') setEnabled(chat_id, True) elif text == '/stop': setEnabled(chat_id, False)
async def on_message(message): # Listen to the messages and react accordingly if a bot command is called. # Ignore messages sent by the bot if message.author == client.user: return if message.content.startswith(f"{config.PREFIX}{config.QUOTE_COMMAND}"): motivational_quote = quote.get_motivated() msg = f'{motivational_quote["text"]}\n-{motivational_quote["author"]}' await message.channel.send(f"```{msg}```") if message.content.startswith(f"{config.PREFIX}{config.GDQ_COMMAND}"): msg = quote.get_quote() await message.channel.send(f"```{msg}```")
def index(): decision = [ 'Almost Certainly', 'Extremely unlikely', 'Without doubt', "It's Doubtful", 'Most Probably', 'Only you can know', 'Only time will tell', "It's hard to tell", 'Who knows', 'Je ne sais pas', 'Yes', 'NO #YOLO' ] decision = random.choice(decision) quote_and_author = get_quote().split(":::") quote = quote_and_author[1] author = quote_and_author[0] return render_template("index.html", decision=decision, author=author, quote=quote)
def index(): decision = ['Almost Certainly', 'Extremely unlikely', 'Without doubt', "It's Doubtful", 'Most Probably', 'Only you can know', 'Only time will tell', "It's hard to tell", 'Who knows', 'Je ne sais pas', 'Yes', 'NO #YOLO'] decision = random.choice(decision) quote_and_author = get_quote().split(":::") quote = quote_and_author[1] author = quote_and_author[0] return render_template("index.html", decision=decision, author=author, quote=quote)
from quote import get_quote import tweepy from dotenv import load_dotenv import os load_dotenv() # Load environment variables file # Set the access keys for Twitter auth = tweepy.OAuthHandler(os.getenv("API_KEY"), os.getenv("API_SECRET_KEY")) auth.set_access_token(os.getenv("ACCESS_TOKEN"), os.getenv("ACCESS_TOKEN_SECRET")) # Set up the Twitter API api = tweepy.API(auth) # Tweets the quote api.update_status(get_quote())
def test_get_quote(self): qv = quote.get_quote() self.assertEqual(qv['quote'], 'What gets measured, gets managed.') self.assertEqual(qv['attribution'], 'Peter Drucker')
# Run Code start_time = time.time() now = datetime.datetime.now() date = datetime.datetime.strftime(now, '%Y-%m-%d') angie_zip = trips.angie_location(date) elizabeth_zip = trips.elizabeth_location(date) # Build content that's relevant & consistent to all members ep_text, ep_url = earthporn.get_image() # [0]=id, [1]=quote, [2]=times_served, [3]=author, [4]=link quote_data = quote.get_quote() move_data = move.get_move() (entertainment_article, entertainment_summary, entertainment_link, entertainment_image) = entertainment.get_eonline() sports_title, sports_sub_title = entertainment.get_sports() sports_link = 'http://espn.go.com/' today = datetime.datetime.strftime(datetime.datetime.now(), '%B %-d, %Y') email_data = {} email_data['today'] = today email_data['quote'] = quote_data[1]
def get_quote(): return flask.jsonify(quote.format_quote(quote.get_quote()))