def email_tweet(to, subject, text, html=None): gmailer.GMAIL_SETTINGS['user'] = settings.GMAIL_USER gmailer.GMAIL_SETTINGS['password'] = settings.GMAIL_PASSWORD gmailer.mail(to=to, subject=subject, text=text, html=html, cache_connection=True)
def alert(pid, eta): """ (str, list) -> None alert accepts process_id(pid) and emails_to_alert(eta) as parameter. >>>alert('20201',['*****@*****.**', '*****@*****.**']) """ for email in eta: mail(pid, email)
def send(to, subject, text, cc=None, bcc=None, reply_to=None, attach=None, html=None, pre=False, custom_headers=None): """ abstracts away the details of our email provider. always use this method instead of gmailer or other future mailers """ return gmailer.mail(to, subject, text, cc=cc, bcc=bcc, reply_to=reply_to, attach=attach, html=html, pre=False, custom_headers=custom_headers)
inserted_students = powerschool.update_students() inserted_teachers = powerschool.update_teachers() homeroom_update_file = powerschool.write_homeroom_upload_file() cnt_update_file = powerschool.write_cnt_upload_file() ps1000.write_host_file() erc.write_erc_update_file() follett() end_time = datetime.datetime.now() elapsed_time = end_time - start_time prowl_subject = 'vlad has run' prowl_body = prowl_body + '\nvlad completed a run at {0}'.format(end_time) prowl_body = prowl_body + '\nElapsed time:{0}'.format(elapsed_time) gmailer.mail(prowl_address, prowl_subject, prowl_body, gmail_user, gmail_pwd) db_host = 'localhost' db_user = configuration_values['db_user'] db_password = configuration_values['db_passwd'] db_name = configuration_values['db_db'] conn = MySQLdb.connect (host = db_host, user = db_user, passwd = db_password, db = db_name) cursor = conn.cursor () sql_string = "INSERT INTO meta_update (time_start, time_end, inserted_aggstats, inserted_attendance, inserted_attendance_code, inserted_attendance_taken, inserted_cc, inserted_courses, inserted_graduation_requirements, inserted_log, inserted_period, inserted_schedulecatalogs, inserted_schedulecc, inserted_schedulecoursecatalogs, inserted_scheduledepartments, inserted_scheduleperiods, inserted_sections, inserted_stored_grades, inserted_students, inserted_students_calculated, inserted_teachers) VALUES ('{0}','{1}','{2}','{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}')".format(start_time, end_time, inserted_aggstats, inserted_attendance, inserted_attendance_code, inserted_attendance_taken, inserted_cc, inserted_courses, inserted_graduation_requirements, inserted_log, inserted_period, inserted_schedulecatalogs, inserted_schedulecc, inserted_schedulecoursecatalogs, inserted_scheduledepartments, inserted_scheduleperiods, inserted_sections, inserted_stored_grades, inserted_students, inserted_students_calculated, inserted_teachers) print 'Executing sql_string:' print sql_string cursor.execute(sql_string)
def generate_playlist(self): """ """ print 'Minutes:', self.number_of_minutes_in_new_playlist print 'Source:', self.source_playlist_path print 'Generated:', self.generated_playlist_path song_list = [] for m3u_line in self.line_at_a_time: if m3u_line[0:7] == '#EXTM3U': print 'Found the first line' elif m3u_line[0:8] == '#EXTINF:': just_data = m3u_line.replace('#EXTINF:','') split_m3u_line = just_data.split(',', 1) # limit the splits to one in case the title string contains a comma track_seconds = split_m3u_line[0].replace('\n','') track_title = split_m3u_line[1].replace('\n','') else: original_track_path_with_line_ending = m3u_line original_track_path = original_track_path_with_line_ending.replace('\n','') new_track_path = original_track_path.replace(ORIGINAL_ITUNES_MUSIC_DIRECTORY, self.music_directory) song_list.append([track_title, track_seconds, new_track_path]) track_seconds = '' track_title = '' new_track_path = '' random.shuffle(song_list) self.file_writer.write('#EXTM3U\n') email_title = 'Selections from playlist {0} for {1}\n'.format(self.source_playlist_name, self.now_iso) email_body = '' total_minutes = 0 total_songs = 0 i = 0 self.sqlite_cursor.execute('CREATE TABLE IF NOT EXISTS plays (id INTEGER PRIMARY KEY, title TEXT, path TEXT, playlist TEXT, date TEXT)') while total_minutes < (self.number_of_minutes_in_new_playlist): self.file_writer.write('#EXTINF:' + song_list[i][1] + ',' + song_list[i][0] + '\n' + song_list[i][2] + '\n') title = song_list[i][0].replace("'","") path = song_list[i][2].replace("'","") sql = "INSERT INTO plays (title, path, playlist, date) VALUES ('{0}', '{1}', '{2}', '{3}');".format(title,path, self.source_playlist_name, self.now_iso) print sql self.sqlite_cursor.execute(sql) total_minutes = total_minutes + (int(song_list[i][1])/60) song_email_line = song_list[i][0] + '\n' email_body += song_email_line i = i + 1 total_songs = total_songs + 1 print email_body self.file_writer.write('') print 'songList contains {0} songs'.format(total_songs) gmailer.mail(PROWL_ADDRESS, email_title, email_body, GMAIL_USER, GMAIL_PASSWORD) self.sqlite_connection.commit() self.sqlite_connection.close() self.file_writer.close() self.file_reader.close() # Careful in formatting the argument strings. From the online docs: # Windows users have to use the --option-name="value" syntax instead of the --option-name value syntax. player_args = [PATH_TO_VLC, '--play-and-exit', self.generated_playlist_path] p = subprocess.Popen(player_args)
inserted_students = powerschool.update_students() inserted_teachers = powerschool.update_teachers() homeroom_update_file = powerschool.write_homeroom_upload_file() cnt_update_file = powerschool.write_cnt_upload_file() ps1000.write_host_file() erc.write_erc_update_file() follett() end_time = datetime.datetime.now() elapsed_time = end_time - start_time prowl_subject = 'vlad has run' prowl_body = prowl_body + '\nvlad completed a run at {0}'.format(end_time) prowl_body = prowl_body + '\nElapsed time:{0}'.format(elapsed_time) gmailer.mail(prowl_address, prowl_subject, prowl_body, gmail_user, gmail_pwd) db_host = 'localhost' db_user = configuration_values['db_user'] db_password = configuration_values['db_passwd'] db_name = configuration_values['db_db'] conn = MySQLdb.connect(host=db_host, user=db_user, passwd=db_password, db=db_name) cursor = conn.cursor() sql_string = "INSERT INTO meta_update (time_start, time_end, inserted_aggstats, inserted_attendance, inserted_attendance_code, inserted_attendance_taken, inserted_cc, inserted_courses, inserted_graduation_requirements, inserted_log, inserted_period, inserted_schedulecatalogs, inserted_schedulecc, inserted_schedulecoursecatalogs, inserted_scheduledepartments, inserted_scheduleperiods, inserted_sections, inserted_stored_grades, inserted_students, inserted_students_calculated, inserted_teachers) VALUES ('{0}','{1}','{2}','{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}')".format( start_time, end_time, inserted_aggstats, inserted_attendance, inserted_attendance_code, inserted_attendance_taken, inserted_cc, inserted_courses, inserted_graduation_requirements, inserted_log, inserted_period, inserted_schedulecatalogs, inserted_schedulecc,