def generate_week(weeks=1): pendulum.week_starts_at(pendulum.SUNDAY) pendulum.week_ends_at(pendulum.SATURDAY) result = [] for week in range(0, weeks): result.append(generate_week_for_date(pendulum.now().add(weeks=week))) return result
def _augmented_data(report_options) -> Mapping[str, Any]: if report_options.get("reportPeriod") is None: return {} else: now = pendulum.now("utc") if report_options["reportPeriod"] == "DAY": now = now.subtract(days=1) data_start_time = now.start_of("day") data_end_time = now.end_of("day") elif report_options["reportPeriod"] == "WEEK": now = now.subtract(weeks=1) # According to report api docs # dataStartTime must be a Sunday and dataEndTime must be the following Saturday pendulum.week_starts_at(pendulum.SUNDAY) pendulum.week_ends_at(pendulum.SATURDAY) data_start_time = now.start_of("week") data_end_time = now.end_of("week") # Reset week start and end pendulum.week_starts_at(pendulum.MONDAY) pendulum.week_ends_at(pendulum.SUNDAY) elif report_options["reportPeriod"] == "MONTH": now = now.subtract(months=1) data_start_time = now.start_of("month") data_end_time = now.end_of("month") else: raise Exception([{"message": "This reportPeriod is not implemented."}]) return { "dataStartTime": data_start_time.strftime(DATE_TIME_FORMAT), "dataEndTime": data_end_time.strftime(DATE_TIME_FORMAT), "reportOptions": report_options, }
def setup(): pendulum.set_local_timezone(pendulum.timezone("America/Toronto")) yield pendulum.set_test_now() pendulum.set_locale("en") pendulum.set_local_timezone() pendulum.week_starts_at(pendulum.MONDAY) pendulum.week_ends_at(pendulum.SUNDAY)
def setup(): pendulum.set_local_timezone(pendulum.timezone("America/Toronto")) yield pendulum.set_test_now() pendulum.set_locale("en") pendulum.set_local_timezone() pendulum.week_starts_at(pendulum.MONDAY) pendulum.week_ends_at(pendulum.SUNDAY)
def test_week_starts_at_invalid_value(): with pytest.raises(ValueError): pendulum.week_starts_at(-1) with pytest.raises(ValueError): pendulum.week_starts_at(11)
def test_week_starts_at(): pendulum.week_starts_at(pendulum.SATURDAY) dt = pendulum.now().start_of("week") assert dt.day_of_week == pendulum.SATURDAY assert dt.date().day_of_week == pendulum.SATURDAY
import smtplib, datetime, shlex, subprocess, sys, os import pandas as pd import pendulum #Python and GAM script to rotate passwords and email to sites and district contacts #the information of the passwords. For use to have 5 Guest accounts available weekly for #sites to have guests join Zoom meetings and whatnot. #Campuses is where you put in what campus you are updating a guest login for, and then whom you are emailing #to. The third field is used by the program to story the body of the email that gets mailed out. campuses = [('ahs', '*****@*****.**', ''), ('chs', '*****@*****.**', ''), ('llhs', '*****@*****.**', ''), ('mhs', '*****@*****.**', '')] #docontacts is where you would put in District level people who need to be aware of what then #passwords are for each site. docontacts = '[email protected],[email protected]' pendulum.week_starts_at(pendulum.MONDAY) pendulum.week_ends_at(pendulum.FRIDAY) today = pendulum.now().add(days=3) start = today.start_of('week') end = today.end_of('week') theweekof = "for the week of " + start.strftime( '%B %d') + " to " + end.strftime('%B %d') df = pd.DataFrame(campuses, columns=['campusname', 'contacts', 'emailbody']) wordfile = xp.locate_wordfile() mywords = xp.generate_wordlist(wordfile=wordfile, min_length=2, max_length=8) for x in df.index: msg = EmailMessage() df['emailbody'][x] = "Passwords for Guest accounts this week are:\n\n" for i in range(5): password = xp.generate_xkcdpassword(mywords, delimiter="",