def fetch_all_events(): # Function to help filter out events that have no start time def filter_events_with_starttime(event_data): if event_data['event_dates']['starting_day'] is None: return False else: return True url = "http://open-api.myhelsinki.fi/v1/events/?language_filter=en" data = requests.get(url).json() all_events = data['data'] all_events = filter(filter_events_with_starttime, all_events) events = [] event_names = [] for item in all_events: event = create_event(item) if event.name not in event_names: events.append(event) event_names.append(event.name) else: event_to_add_st = next((x for x in events if x.name == event.name), None) event_to_add_st.add_start_time(event.start_time[0]) # sort alphabetically # events.sort(key=get_event_name) return events
def bookingCreate(): if google_auth.is_logged_in(): user_info = google_auth.get_user_info() email = user_info['email'] picture = user_info['picture'] name = user_info['name'] if request.method == 'GET': return render_template('booking-create.html', email=email, picture=picture, name=name) elif request.method == 'POST': if '""' in request.form['create-booking'] \ or 'Select Duration' in request.form['create-booking']: # some fields not selected error = 'Error with booking. Please try again.' return render_template('booking-create.html', email=email, picture=picture, name=name, error=error) array_2d = json.loads(request.form['create-booking']) ref_code = create_event(array_2d, email, name) return render_template("confirmation.html", email=email, picture=picture, name=name, refCode=ref_code) else: return redirect(url_for("google_auth.login"))
def result(): creds = credentials.Credentials(**session['creds']) print(creds) service = build('calendar', 'v3', credentials=creds) # check available and create calendar/events if request.method == 'POST': title = request.form['Task Name'] timezone = request.form['Timezone'] length = request.form['Duration'] frequency = request.form['Frequency'] earliest_time = request.form['Earliest'] latest_time = request.form['Latest'] cal_id = create_calendar(service, title, timezone) vacant = vacancy_based_on_freq(service, int(length), int(frequency), int(earliest_time), int(latest_time), timezone) for index, value in vacant.items(): available_start = vacant[index][0] start = (available_start + timedelta(minutes=15)).isoformat() end = (available_start + timedelta(minutes=(15 + int(length)))).isoformat() result = create_event(service, cal_id, start, end, title, frequency, length, timezone) # session['creds'] = creds_dict(creds) return render_template('result.html')
def fetch_nearby(lat, lon): url = 'http://open-api.myhelsinki.fi/v1/events/?language_filter=en&distance_filter=' \ + str(lat) + '%2C' + str(lon) + '%2C2' data = requests.get(url).json() results = data['data'] sample_arr = results[:3] events = [] for item in sample_arr: event = create_event(item) events.append(event) print(events[0].name, events[0].lat, events[0].lon, events[0].address, events[0].start_time, events[0].end_time) return events
def event_add(params): ''' add an event to the calendar ''' # extract name, date and time name = params['name'] param_time = params['time'] param_date = params['date'] # process date and time inputs start, end = process_time(param_time, param_date, duration=1, z=True) # check if the selected time slot is available is_available = check(start, end) if is_available: event_id = create_event(start, end, name) answer = "Well received. The ID of your appointment is " + event_id else: answer = "This time slot is already reserved" return answer
def __init__(self, parent, friend, system_user): tk.Frame.__init__(self, parent, bd=1) self.parent = parent self.friend = friend b_events = ttk.Button(self, text="Event podium", command=lambda : friend.open_eventpodium(0)) b_events.pack(side=tk.TOP, fill=tk.X, pady=5) b_profile = ttk.Button(self, text="Profile page", command=lambda : friend.open_profile(system_user)) b_profile.pack(side=tk.TOP, fill=tk.X, pady=5) b_custom = ttk.Button(self, text="Create new event", command=lambda: create_event(system_user)) b_custom.pack(side=tk.TOP, fill=tk.X, pady=5) b_check = ttk.Button(self, text="My events",command=lambda : friend.open_eventpodium(1)) b_check.pack(side=tk.TOP, fill=tk.X, pady=5) self.s_search = tk.StringVar() tb_search = tk.Entry(self, width=20, textvariable=self.s_search) tb_search.pack(side=tk.TOP, fill=tk.X) b_search = ttk.Button(self, text="Search",command=lambda: self.search()) b_search.pack(side=tk.TOP, fill=tk.X)
def test_create_event_no_dates(): test_event = create_event(data[5]) assert test_event.start_time == 'No starting date announced' and test_event.end_time == 'No ending date announced'
def test_create_event_no_address(): test_event = create_event(data[4]) assert test_event.address == 'No address announced'
def test_create_event_no_tags(): test_event = create_event(data[3]) assert test_event.tags == ['The event has no tags']
def test_create_event_no_location(): test_event = create_event(data[2]) assert test_event.lat is None and test_event.lon is None
def test_create_event_no_url_link(): test_event = create_event(data[1]) assert test_event.link is None
def jarvis(): time.sleep(10) greet() labelString2.set("Hi " + getName() + ", what can I do for you?") window.update() speak("Hi " + getName() + ", what can I do for you?") while True: # btn1.configure(bg='grey') data = recordAudio() if "what time is it" in data: labelString2.set(ctime()) window.update() speak(ctime()) elif "exit" in data or "close" in data or "goodbye" in data: labelString2.set( "I feeling very sweet after meeting with you but you are going! i am very sad") window.update() speak( "I feeling very sweet after meeting with you but you are going! i am very sad") exit() elif "send mail" in data or "email" in data: labelString2.set( "Enter a Email ID of User who u want to send mail") window.update() speak("Enter a Email ID of User who u want to send mail") email_id = simpledialog.askstring( "Input", "Enter Email ID", parent=window) if email_id is not None: print(email_id) labelString2.set("Tell a subject for mail : ") window.update() speak("Tell a subject for mail : ") email_subject = recordAudio() labelString2.set("Tell a Email Body : ") window.update() speak("Tell a Email Body : ") email_body = recordAudio() send_mail(text=email_body, subject=email_subject, to_emails=[email_id]) labelString2.set("Mail sent successfully") window.update() speak("Mail sent successfully") else: labelString2.set("You haven't entered Email ID yet") window.update() speak("You haven't entered Email ID yet") elif "check for any new mail" in data: new_mail = get_inbox() labelString2.set("you have mail from " + new_mail) window.update() speak("you have mail from " + new_mail) elif "schedule meeting" in data: speak("Enter date in DD/MM/YYYY format") dt_string = simpledialog.askstring( "Input", "Enter date in DD/MM/YYYY format", parent=window) speak("Enter time in HH:MM format") t = simpledialog.askstring( "Input", "Enter time in HH:MM format", parent=window) dt_string = dt_string + " " + t dt = datetime.datetime.strptime(dt_string, "%d/%m/%Y %H:%M") print(dt) currentDate = datetime.datetime.today() if dt <= currentDate: labelString2.set( "Given date should be greater than todays date") window.update() speak("Given date should be greater than todays date") else: labelString2.set("Tell a summary for meeting : ") window.update() speak("Tell a summary for meeting : ") summary = recordAudio() create_event(dt, summary) labelString2.set("Meeting scheduled successfully") window.update() speak("Meeting scheduled successfully") elif "check for any meeting scheduled" in data: events = list_events() for event in events: start = event["start"].get( "dateTime", event["start"].get("date")) labelString2.set("you have meeting scheduled on " + start) window.update() speak("you have meeting scheduled on " + start) print(start, event["summary"]) elif "shutdown" in data: labelString2.set( "Hold On a Sec ! Your system is on its way to shut down") window.update() speak("Hold On a Sec ! Your system is on its way to shut down") os.system("shutdown -s") elif "hibernate" in data or "sleep" in data: labelString2.set("Hibernating..") window.update() speak("Hibernating..") os.system("shutdown.exe /h") elif "change name" in data or "name change" in data: labelString2.set("Tell a new name") window.update() speak("Tell a new name") name = recordAudio() if name: setName(name) labelString2.set(f"okay, i will remember that {name}") window.update() speak(f"okay, i will remember that {name}") elif "open youtube" in data or "open video online" in data: webbrowser.open("www.youtube.com") labelString2.set("Opening Youtube") window.update() speak("opening youtube") elif "open github" in data: webbrowser.open("https://www.github.com") labelString2.set("Opening Github") window.update() speak("opening github") elif "open facebook" in data: webbrowser.open("https://www.facebook.com") labelString2.set("Opening Facebook") window.update() speak("opening facebook") elif "open instagram" in data: webbrowser.open("https://www.instagram.com") labelString2.set("Opening Instagram") window.update() speak("opening instagram") elif "open google" in data: webbrowser.open("https://www.google.com") labelString2.set("Opening Google") window.update() speak("opening google") elif "open yahoo" in data: webbrowser.open("https://www.yahoo.com") labelString2.set("Opening Yahoo") window.update() speak("opening yahoo") elif "open amazon" in data or "shop online" in data: webbrowser.open("https://www.amazon.com") labelString2.set("Opening Amazon") window.update() speak("opening amazon") elif "open flipkart" in data: webbrowser.open("https://www.flipkart.com") labelString2.set("Opening Flipkart") window.update() speak("opening flipkart") elif "what\"s up" in data or "how are you" in data: stMsgs = ["Just doing my thing!", "I am fine!", "Nice!", "I am nice and full of energy", "i am okey ! How are you"] ans_q = random.choice(stMsgs) labelString2.set(ans_q) window.update() speak(ans_q) user_reply = recordAudio() if "fine" in user_reply or "ok" in user_reply: labelString2.set("Okay") window.update() speak("okay..") elif "not" in user_reply or "sad" in user_reply or "upset" in user_reply: labelString2.set("Oh Sorry..") window.update() speak("oh sorry..") elif "who are you" in data or "about you" in data or "your details" in data: labelString2.set("I am ALICE, Your Virtual Assistant") window.update() speak("I am ALICE, Your Virtual Assistant") elif "hey alice" in data or "hello alice" in data: name = getName() labelString2.set("Hello " + name + " How may i help you") window.update() speak("Hello " + name + " How may i help you") elif "open calculator" in data or "calculator" in data: labelString2.set("Opening calculator") window.update() speak("opening calculator") call(["calc.exe"]) elif "open notepad" in data or "notepad" in data: labelString2.set("Opening Notepad") window.update() speak("opening notepad") call(["notepad.exe"]) elif "search for" in data and "youtube" not in data: search_term = data.split("for")[-1] url = f"https://google.com/search?q={search_term}" webbrowser.get().open(url) labelString2.set( f"Here is what I found for {search_term} on google") window.update() speak(f"Here is what I found for {search_term} on google") elif " on youtube" in data: search_term = data.split("on")[-1] url = f"https://www.youtube.com/results?search_query={search_term}" webbrowser.get().open(url) labelString2.set(f"Here is what I found for {search_term}") window.update() speak(f"Here is what I found for {search_term}") elif "don't listen" in data or "stop listening" in data: labelString2.set( "for how much time you want to stop assistant from listening commands") window.update() speak("for how much time you want to stop assistant from listening commands") a = int(recordAudio()) labelString2.set("Sleeping..") window.update() speak("Sleeping..") time.sleep(a) elif "locate " in data: search_term = data.split(" ")[-1] url = f"https://www.google.com/maps/place/{search_term}" webbrowser.get().open(url) labelString2.set( f"Here is what I found for {search_term} on google map") window.update() speak(f"Here is what I found for {search_term} on google map") elif "check battery status" in data: battery = psutil.sensors_battery() plugged = battery.power_plugged percent = str(battery.percent) plugged = "Plugged In" if plugged else "Not Plugged In" labelString2.set(percent+'% available and system is '+plugged) window.update() speak(percent+'% available and system is '+plugged) elif 'show news' in data: try: jsonObj = urlopen('http://newsapi.org/v2/top-headlines?' 'country=us&' 'apiKey=ef7399983f78497983b23c2da7e0efcc') data = json.load(jsonObj) i = 1 labelString2.set('Here are some top worldwide news : ') window.update() speak('here are some top worldwide news ') print('''=============== TIMES OF INDIA ============''' + '\n') for item in data['articles']: if(i > 3): break else: print(str(i) + '. ' + item['title'] + '\n') print(item['description'] + '\n') speak(str(i) + '. ' + item['title'] + '\n') i += 1 except Exception as e: print(str(e))
from create_event import create_event from view_all_events import view_all_events from edit_event import edit_event from delete_event import delete_event import sqlite3 conn = sqlite3.connect('dummy_data.db') c = conn.cursor() delete_event(int(input('Delete event ID:'))) #view_all_events() #edit_event(int(input('Event ID:'))) # Create Event Tests ''' name = input ('Event name: ') start_date = input ('Start Date: ') end_date = input ('End Date: ') venue = input ('Venue: ') create_event(name, start_date, end_date, venue) #create_event('Some Festival', '12-2-2010', '14-2-2010', 'Mombasa') '''
def run(*args): from create_event import create_event create_event(*args)
def test_create_event_no_image(): test_event = create_event(data[6]) assert test_event.img_link is None
# Navigate to shifts page driver.get('https://psschedule.reflexisinc.co.uk/wfmmcdirlprd/rws/ess/ess_notice_board.jsp?mm=ESS') # Grab the starting date and convert to datetime starting_date = driver.find_element_by_name('weekstarts').text[-10:] current_date = datetime.datetime(int(starting_date[-4:]), int(starting_date[3:5]), int(starting_date[0:2])) if not is_events_this_week(current_date): shift_information = get_shifts(current_date) proceed = ask_if_correct(shift_information) if proceed == 'y': for item in shift_information: create_event(item) next_week = driver.find_element_by_id('rightImg') if 'visible' in next_week.get_attribute('style'): next_week.click() current_date += datetime.timedelta(days=7) if not is_events_this_week(current_date): shift_information = get_shifts(current_date) proceed = ask_if_correct(shift_information) if proceed == 'y': for item in shift_information: create_event(item)
def test_create_event_nameless(): test_event = create_event(data[0]) assert test_event.name == 'No name announced'
def admin_page(): """Update Admin changes to our database.""" # print "I am in the method" #import pdb; pdb.set_trace() event_id = request.form.get("eventid") event_name = request.form.get("eventname") event_date = request.form.get("eventdate") event_description = request.form.get("eventdesc") event_status = request.form.get("eventstatus") event_spots = request.form.get("noofspots") print "*********************************************************" print event_id print event_name print datetime print event_description print event_status print event_spots print "*********************************************************" print event_id , event_name,event_date,event_description,event_status,event_spots event_count = Event.query.filter_by(event_id=event_id).count() print event_count if event_count == 0 : new_event = Event(event_name=event_name,event_date=datetime.strptime(event_date , '%Y-%m-%d'),event_length=1,event_description=event_description,event_status=event_status,no_of_spots=event_spots,no_of_reg_spots=0,no_of_waitlist_spots=0,recurring='Yes' ,created_id=500 ) print "I am inside insert *****************************" print event_name print event_date print event_description print event_status print event_spots print "########*********************************************************" eventmessage = {} eventmessage['eventname'] = event_name eventmessage['eventdate'] = event_date eventmessage['eventdesc'] = event_description print "*********************************************************########" db.session.add(new_event) db.session.commit() print eventmessage templateobj = EmailTemplate(template_name='eventadd.txt', values=eventmessage) message = templateobj.render() usertobenotified = User.query.filter_by(reminder="Yes").all() for user in usertobenotified: print user.email_address send_notification(user.email_address,Eventadd,message) print message create_event(event_name,event_date,event_description) # print eventmessage # print ('before sending email template email') print "I am here ********************************************" return "The event is updated" else: change_event = Event.query.get(event_id) change_event.event_id = event_id change_event.event_name=event_name change_event.event_date=datetime.strptime(event_date , '%Y-%m-%d') change_event.event_length=1 change_event.event_description=event_description change_event.event_status=event_status change_event.no_of_spots=event_spots change_event.recurring = 'Yes' change_event.created_id = 500 #admin_event = Event(event_id = event_id,event_name=event_name,event_date=datetime.now(),event_length=1,event_description=event_description,event_status=event_status,no_of_spots=event_spots,recurring = 'Yes', created_id=500) #db.session.add(admin_event) db.session.commit() # print event_id , event_name,event_date,event_description,event_status,event_spots return "The event is updated"
def admin_page(): """Update Admin changes to our database.""" # print "I am in the method" #import pdb; pdb.set_trace() event_id = request.form.get("eventid") event_name = request.form.get("eventname") event_date = request.form.get("eventdate") event_description = request.form.get("eventdesc") event_status = request.form.get("eventstatus") event_spots = request.form.get("noofspots") print "*********************************************************" print event_id print event_name print datetime print event_description print event_status print event_spots print "*********************************************************" print event_id, event_name, event_date, event_description, event_status, event_spots event_count = Event.query.filter_by(event_id=event_id).count() print event_count if event_count == 0: new_event = Event(event_name=event_name, event_date=datetime.strptime(event_date, '%Y-%m-%d'), event_length=1, event_description=event_description, event_status=event_status, no_of_spots=event_spots, no_of_reg_spots=0, no_of_waitlist_spots=0, recurring='Yes', created_id=500) print "I am inside insert *****************************" print event_name print event_date print event_description print event_status print event_spots print "########*********************************************************" eventmessage = {} eventmessage['eventname'] = event_name eventmessage['eventdate'] = event_date eventmessage['eventdesc'] = event_description print "*********************************************************########" db.session.add(new_event) db.session.commit() print eventmessage templateobj = EmailTemplate(template_name='eventadd.txt', values=eventmessage) message = templateobj.render() usertobenotified = User.query.filter_by(reminder="Yes").all() for user in usertobenotified: print user.email_address send_notification(user.email_address, Eventadd, message) print message create_event(event_name, event_date, event_description) # print eventmessage # print ('before sending email template email') print "I am here ********************************************" return "The event is updated" else: change_event = Event.query.get(event_id) change_event.event_id = event_id change_event.event_name = event_name change_event.event_date = datetime.strptime(event_date, '%Y-%m-%d') change_event.event_length = 1 change_event.event_description = event_description change_event.event_status = event_status change_event.no_of_spots = event_spots change_event.recurring = 'Yes' change_event.created_id = 500 #admin_event = Event(event_id = event_id,event_name=event_name,event_date=datetime.now(),event_length=1,event_description=event_description,event_status=event_status,no_of_spots=event_spots,recurring = 'Yes', created_id=500) #db.session.add(admin_event) db.session.commit() # print event_id , event_name,event_date,event_description,event_status,event_spots return "The event is updated"