def run_face_profile_detection(profile_area_dict, face_area_dict,
                               text_area_dict):

    face_cascade = cv2.CascadeClassifier(
        "Data/haarcascade_frontalface_default.xml")
    temp_profile_area_path = "temp_profile_area.jpg"
    start_time = datetime.datetime.now()

    prev_is_face = False
    save_cond = False
    profile_index = 1028390
    time_offset = 0  # in seconds

    face_profile_list = []

    while True:

        screenshot = save_screen_shot(
            *[profile_area_dict[key] for key in profile_area_dict],
            temp_profile_area_path)

        profile_image = cv2.imread(temp_profile_area_path)
        face_image = Functions.get_child_image_from_parent_image(
            profile_image, profile_area_dict, face_area_dict, scale=0.5)
        text_image = Functions.get_child_image_from_parent_image(
            profile_image, profile_area_dict, text_area_dict)

        face_list = face_cascade.detectMultiScale(
            cv2.cvtColor(face_image, cv2.COLOR_BGR2GRAY),  # grayscale version
            scaleFactor=1.1,
            minNeighbors=5,
            minSize=(30, 30),
            flags=cv2.CASCADE_SCALE_IMAGE)

        curr_is_face = len(face_list) != 0

        if len(face_list) > 1:
            continue
        if curr_is_face and not prev_is_face:

            face_profile_list.append(
                Profile.FaceProfile(init_image=screenshot))
            save_cond = True
            print("--------------------------")
            print("new prof added - profile {}".format(profile_index))

        if save_cond:
            face_profile_list[-1].add_image_to_list(screenshot)
            print("\tadding face")
            if face_profile_list[-1].try_parsing_image(
                    text_image=text_image,
                    target_dir=Constants.profile_dir,
                    seconds_into_video=(datetime.datetime.now() -
                                        start_time).total_seconds() * 2 +
                    time_offset,
                    profile_num=profile_index):
                save_cond = False
                profile_index += 1

        prev_is_face = curr_is_face
示例#2
0
    def prof_response(self, arg_list):
        prof_name = " ".join(arg_list)
        prof_list = [
            prof for prof in self.stevens.professor_list
            if prof_name in prof.name.lower()
        ]
        professor = None
        for prof in prof_list:
            if prof.name.lower() == prof_name:
                professor = prof

        if not prof_list:
            return "No professors with name {}".format(prof_name)
        elif len(prof_list) > 1 and professor is None:
            return "Multiple professors found: " + ", ".join(
                [prof.name.title() for prof in prof_list])

        ret_str = "Professor {}:".format(professor.name)
        ret_str += "\n-------------"
        for day_code, section_list in professor.day_section_list_dict.items():
            ret_str += "\n" + self.day_code_bict.find(day_code).title()
            for section in section_list:
                ret_str += "\n\t" + "{} - {}: Room {} - {}".format(
                    Functions.get_pretty_time(section.start_time),
                    Functions.get_pretty_time(section.end_time),
                    section.room_name, section.name)
        return ret_str
示例#3
0
 def rewrite_projection_list(self, projection_list):
     if os.path.exists(self.scenario_json_path):
         os.remove(self.scenario_json_path)
     Functions.dict_to_json(
         [projection.to_dict() for projection in projection_list],
         self.scenario_json_path
     )
示例#4
0
    def get_dataframe(self):
        curr_datetime = self.start_datetime
        datetime_list = []
        amount_list = []
        while True:
            if curr_datetime >= self.end_datetime:
                break
            datetime_list.append(curr_datetime)
            amount_list.append(self.amount)

            if self.frequency == "daily":
                curr_datetime += datetime.timedelta(days=1)
            elif self.frequency == "weekly":
                curr_datetime += datetime.timedelta(days=7)
            elif self.frequency == "biweekly":
                curr_datetime += datetime.timedelta(days=14)
            elif self.frequency == "monthly":
                curr_datetime = Functions.add_months(curr_datetime, 1)
            elif self.frequency == "yearly":
                curr_datetime = Functions.add_months(curr_datetime, 12)

        data = {"result": amount_list}
        full_dataframe = pd.DataFrame(data, index=datetime_list, columns=list(data.keys()))
        full_dataframe = full_dataframe.sort_index()
        return full_dataframe
    def __str__(self):

        ret_str = "CalendarInfo (from the 'LT Sheets -> Calendar Info' Google Sheet" + "\n"
        ret_str += Functions.tab_str(Functions.dict_to_str(self.ip_id_dict)) + "\n"
        ret_str += Functions.tab_str(Functions.dict_to_str(self.param_dict))

        return ret_str
示例#6
0
    def __init__(self, parent_course, xml):

        self.xml = xml

        self.main_attrib_dict, self.meeting_dict_list, self.requirement_dict_list = self.get_dictionaries(
        )

        self.section = self.main_attrib_dict.get("section")
        self.title = self.main_attrib_dict.get("title")
        self.call_number = self.main_attrib_dict.get("call_number")
        self.activity = str(
            Functions.find_first_occurrence_in_dicts("activity",
                                                     *self.meeting_dict_list))
        self.room = Functions.find_first_occurrence_in_dicts(
            "room", *self.meeting_dict_list)
        self.min_credit = self.main_attrib_dict.get("min_credit")
        self.max_credit = self.main_attrib_dict.get("max_credit")

        self.subject_id, self.course_id, self.id = self.get_subject_course_section_id_list(
        )
        self.parent_course = parent_course

        self.day_list = Functions.find_first_occurrence_in_dicts(
            "day", *self.meeting_dict_list)

        self.start_time, self.end_time = self.get_times()
        self.time_dict = self.get_time_dict()
示例#7
0
 def check_dirs(self):
     if not os.path.exists(self.statement_source_files_dir):
         os.mkdir(self.statement_source_files_dir)
     if not os.path.exists(self.clean_statement_files_dir):
         os.mkdir(self.clean_statement_files_dir)
     if not os.path.exists(self.account_json_path):
         Functions.dict_to_json(self.account_dict, self.account_json_path)
示例#8
0
    def update_curr_balance(self):
        self.curr_balance = self.statement_cleaner.super_statement_df[
            "running_balance"][-1]

        self.account_dict = self.get_account_dict()
        if not os.path.exists(self.account_json_path):
            os.remove(self.account_json_path)
        Functions.dict_to_json(self.account_dict, self.account_json_path)
示例#9
0
def update_stevens(stevens, stevens_save_filename, room_schedule_url):
    if os.path.exists(stevens_save_filename):
        curr_time = datetime.datetime.today()
        time_elapsed = curr_time - stevens.time_updated
        if time_elapsed.total_seconds() > Constants.stevens_update_duration:
            stevens = Stevens.Stevens(room_schedule_url=room_schedule_url)
            Functions.pickle_object(stevens, stevens_save_filename)
            print("{} - Stevens object updated".format(curr_time))
    return stevens
示例#10
0
    def do_prof_response(self, command_list):
        if not command_list:
            self.write_text(self.lt_sheets.sheet_to_simple_response("prof"))
        else:

            prof_name = " ".join(command_list)

            curr_time = datetime.datetime.today()
            prev_time = curr_time - datetime.timedelta(days=1)
            next_time = curr_time - datetime.timedelta(days=-1)

            day_code_list = Stevens.get_day_code_list([
                prev_time.strftime("%A"),
                curr_time.strftime("%A"),
                next_time.strftime("%A")
            ])

            found_prof_section_list_dict = {}
            for prof_key in self.stevens.prof_section_list_dict:
                if prof_name.lower() in prof_key.lower():
                    found_prof_section_list_dict[
                        prof_key] = self.stevens.prof_section_list_dict[
                            prof_key]

            if len(found_prof_section_list_dict) == 0:
                self.write_text("No professor found")
            elif len(found_prof_section_list_dict) > 1:
                str_ret = "Multiple professors found:"
                for found_prof_key in found_prof_section_list_dict:
                    str_ret += "\n{}{}".format(Constants.groupme_tab,
                                               found_prof_key)
                self.write_text(str_ret)
            else:
                str_ret = ""
                for found_prof_key in found_prof_section_list_dict:
                    str_ret += "Professor found: {}".format(found_prof_key)
                    filtered_section_list = []
                    for section in found_prof_section_list_dict[
                            found_prof_key]:
                        if section.day.lower() in day_code_list:
                            filtered_section_list.append(section)

                    if len(filtered_section_list) == 0:
                        str_ret += "\n{}No sections found with day codes [{}]".format(
                            Constants.groupme_tab, ", ".join(day_code_list))
                    else:
                        for section in filtered_section_list:
                            str_ret += "\n{}Room: {}  |  {}: {} - {}".format(
                                Constants.groupme_tab, section.room.name,
                                Stevens.get_day_from_code(
                                    section.day).title()[:3],
                                Functions.get_nice_time_format(
                                    section.start_time),
                                Functions.get_nice_time_format(
                                    section.end_time))

                self.write_text(str_ret)
 def add_components(self):
     Functions.add_to_layout(
         self,
         self.banner_image,
         Functions.add_to_layout(
             self.selector_group,
             AddSelectorButton.AddSelectorButton(stevens=self.stevens, selector_group=self.selector_group)),
         self.start_button
     )
    def __init__(self):
        self.value_l_l_dict = {sheet.title: Functions.empty_strings_to_none(sheet.get_all_values())
                               for sheet in Google.get_google_sheets("LT Sheets")}
        self.value_list_list = self.value_l_l_dict["Calendar Info"]

        self.split_l_l_l = Functions.split_2d_list_by_vertical_none_list(self.value_list_list)

        self.ip_id_dict = self.get_ip_id_dict()
        self.param_dict = self.get_param_dict()
示例#13
0
 def simple_player_str(self):
     return Functions.str_to_length(
             "{} by {}".format(
                 self.name,
                 ", ".join([x.name for x in self.artist_list])
             ),
             30
         ) + \
         "[" + Functions.str_to_length(int((self.current_placement / self.duration) * 30) * "-", 30,
                                       do_dots=False) + "]"
示例#14
0
def section_list_to_string(section_list):
    str_ret = ""
    for i, section in enumerate(section_list):
        if i != 0:
            str_ret += "\n"
        str_ret += "{}: {} - {} | {} ({})".format(
            get_day_from_code(section.day.lower())[:3].title(),
            Functions.get_nice_time_format(section.start_time),
            Functions.get_nice_time_format(section.end_time),
            section.course_name, section.professor)
    return str_ret
    def get_statement_df(self):
        statement_df = pandas.DataFrame(data={
            col_name: []
            for col_name in Statement.Statement.col_name_list
        })

        starting_balance = Functions.clean_money_str(
            self.dataframe["Beginning Balance"].iloc[0])
        ending_balance = Functions.clean_money_str(
            self.dataframe["Ending Balance"].iloc[-1])
        temp_dataframe = self.dataframe.drop(columns=[
            "Statement Period Venmo Fees", "Year to Date Venmo Fees",
            "Beginning Balance", "Ending Balance", "Disclaimer"
        ])
        temp_dataframe = temp_dataframe.drop(temp_dataframe.index[0])
        temp_dataframe = temp_dataframe.drop(temp_dataframe.index[-1])

        statement_df["date"] = [
            datetime.datetime.strptime(x, "%Y-%m-%dT%H:%M:%S")
            for x in temp_dataframe["Datetime"]
        ]
        statement_df["amount"] = [
            Functions.clean_money_str(x)
            for x in temp_dataframe["Amount (total)"]
        ]
        # statement_df["running_balance"] = temp_dataframe["Running Bal."]
        statement_df["transaction_code"] = list(temp_dataframe["ID"])
        # statement_df["address"] = temp_dataframe["Description"]
        statement_df["description"] = list(temp_dataframe["Note"])
        statement_df["status"] = list(temp_dataframe["Status"])
        statement_df["funding_source"] = list(temp_dataframe["Funding Source"])
        statement_df["destination"] = list(temp_dataframe["Destination"])
        statement_df["from"] = list(temp_dataframe["From"])
        statement_df["to"] = list(temp_dataframe["To"])

        statement_df = statement_df.set_index(['date'])

        running_balance_list = []
        for i, amount in enumerate(statement_df["amount"]):

            if i == 0:
                running_balance_list.append(starting_balance + amount)
            else:
                if statement_df["funding_source"][i] in ["Venmo balance", ""]:
                    running_balance_list.append(running_balance_list[-1] +
                                                amount)
                else:
                    running_balance_list.append(running_balance_list[-1])
            running_balance_list[-1] = round(running_balance_list[-1], 2)

        statement_df["running_balance"] = running_balance_list

        return statement_df
    def update_section_layout_from_course(self, course):

        self.pop_up.curr_course = course
        self.pop_up.selector_button.text = course.get_name()

        Functions.clear_layout(self.section_layout)

        grid_layout = GridLayout(cols=len(course.activity_dict.keys()),
                                 pos_hint={
                                     'center_x': .5,
                                     'center_y': .5
                                 })

        for activity_key in course.activity_dict:
            grid_layout.add_widget(
                Label(text=Section.Section.activity_dict[activity_key],
                      size_hint=(1, .1),
                      pos_hint={
                          'center_x': .5,
                          'center_y': .5
                      }))

        for activity_key in course.activity_dict:
            activity_layout = BoxLayout(orientation="vertical",
                                        padding=10,
                                        spacing=10,
                                        size_hint=(1, None),
                                        pos_hint={
                                            'center_x': .5,
                                            'center_y': .5
                                        })
            activity_layout.bind(
                minimum_height=activity_layout.setter('height'))

            activity_layout.add_widget(
                ChoiceLayout(label_text="All", check_box_status=True))
            for section in course.activity_dict[activity_key]:
                activity_layout.add_widget(
                    ChoiceLayout(label_text=section.id,
                                 check_box_status=False))

            scroll_view = ScrollView(
                size_hint=(1, 1),
                pos_hint={
                    'center_x': .5,
                    'center_y': .5
                },
                do_scroll_x=False,
            )
            scroll_view.add_widget(activity_layout)
            grid_layout.add_widget(scroll_view)

        self.section_layout.add_widget(grid_layout)
示例#17
0
 def __str__(self, **kwargs):
     header = "Section: {}".format(self.id)
     if kwargs.get("print_section_dicts"):
         ret_str = Functions.dict_to_string(self.main_attrib_dict,
                                            "main_attrib_dict")
         for i, meeting_dict in enumerate(self.meeting_dict_list):
             ret_str += "\n" + Functions.dict_to_string(
                 meeting_dict, "meeting_dict: count = " + str(i))
         for i, requirement_dict in enumerate(self.requirement_dict_list):
             ret_str += "\n" + Functions.dict_to_string(
                 requirement_dict, "requirement_dict: count = " + str(i))
         return header + "\n" + Functions.tab_string(ret_str)
     return header
 def get_song_time_text(self):
     text = "{}/{}".format(
         Functions.milliseconds_to_minute_format(
             self.song.current_placement),
         Functions.milliseconds_to_minute_format(self.song.duration))
     return EasyText.EasyText(
         text=text,
         x=0,
         y=self.screen_height * .8,
         size=self.screen_height / 5,
         font_file="FontFolder/Product Sans Regular.ttf",
         color=(255, 255, 255),
         opacity=140,
         draw_center=False)
示例#19
0
    def get_times(self):

        start_time = Functions.find_first_occurrence_in_dicts(
            "start_time", *self.meeting_dict_list)
        end_time = Functions.find_first_occurrence_in_dicts(
            "end_time", *self.meeting_dict_list)

        if (self.subject_id + self.course_id).replace(
                " ", "").lower() in ScheduleTests.test_schedule_0:
            print("{}: \t{} - {}\t{}".format(
                (self.subject_id + self.course_id + self.id).replace(
                    " ", "").lower(), start_time, end_time, self.day_list))

        if type(start_time) == str and type(end_time) == str:
            split_start_time = str(start_time).split(":")
            split_end_time = str(end_time).split(":")

            start_time = [int(split_start_time[0]), int(split_start_time[1])]
            end_time = [int(split_end_time[0]), int(split_end_time[1])]

            if start_time[0] < Constants.minimum_section_start:
                start_time[0] += 12
                end_time[0] += 12

            if (self.subject_id + self.course_id).replace(
                    " ", "").lower() in ScheduleTests.test_schedule_0:
                print("\t", start_time[0], start_time[1], "\t | ", end_time[0],
                      end_time[1])

            if start_time[0] > 24:
                start_time[0] -= 12
                if (self.subject_id + self.course_id).replace(
                        " ", "").lower() in ScheduleTests.test_schedule_0:
                    print("\ttime changed")
            if end_time[0] > 24:
                end_time[0] -= 12
                if (self.subject_id + self.course_id).replace(
                        " ", "").lower() in ScheduleTests.test_schedule_0:
                    print("\ttime changed")

            start_time = datetime.time(start_time[0], start_time[1])
            end_time = datetime.time(end_time[0], end_time[1])

            if (self.subject_id + self.course_id).replace(
                    " ", "").lower() in ScheduleTests.test_schedule_0:
                print("\t", start_time.strftime('%I:%M %p'), " | ",
                      end_time.strftime('%I:%M %p'))

        return start_time, end_time
示例#20
0
    def __str__(self):
        statement_df = self.statement_df.copy()

        if statement_df.empty:
            return "empty dataframe"

        statement_df = statement_df.applymap(lambda x: Functions.str_to_length(
            x, 20, do_dots=True, do_left=True))
        statement_df.columns = statement_df.columns.map(
            lambda x: Functions.str_to_length(
                x, 20, do_dots=True, do_left=True))
        statement_df.index = statement_df.index.map(
            lambda x: Functions.str_to_length(
                x, 10, do_dots=True, do_left=True))
        return statement_df.to_string()
示例#21
0
def main():

    twitch_credentials_dict = Functions.parse_json(Constants.twitch_credentials_file_path)
    twitch_oauth_dict = TwitchLib.get_oauth_dict(twitch_credentials_dict["client_id"], twitch_credentials_dict["secret"])

    streamer = Streamer.Streamer(
        credentials_dict=twitch_credentials_dict,
        oauth_dict=twitch_oauth_dict,
        **TwitchLib.get_streamer_dict(twitch_credentials_dict["client_id"], twitch_oauth_dict["access_token"])["data"][0]
    )

    print("Current followers as of {}:".format(Functions.get_pretty_time(datetime.datetime.now())))
    print(Functions.tab_str("\n".join([str(x) for x in streamer.get_follower_list()]), 1))
    print("-------------\n")
    streamer.listen_for_followers()
示例#22
0
    def download_statements(self):

        base_download_url = self.get_base_download_url()

        download_url_list = []
        for start_date_str, end_date_str in self.get_start_end_date_tuple_list():
            download_url_list.append(base_download_url.format(start_date=start_date_str, end_date=end_date_str))
            print("Download url:", download_url_list[-1])

        account = self.account_list[0]

        if self.current_statement_csv_name in os.listdir(account.statement_source_files_dir):
            os.remove(account.statement_source_files_dir + "/" + self.current_statement_csv_name)

        for i, (start_date_str, end_date_str) in enumerate(self.get_start_end_date_tuple_list()):
            download_url = base_download_url.format(start_date=start_date_str, end_date=end_date_str)
            print(start_date_str, end_date_str, "   ", end="")

            new_csv_name = "{} to {}.csv".format(start_date_str, end_date_str)
            if i == 0:
                new_csv_name = self.current_statement_csv_name
            new_cvs_path = account.statement_source_files_dir + "/" + new_csv_name

            if not os.path.exists(new_cvs_path):
                print(download_url, end=" - ")
                for _ in range(4):
                    self.driver.get(download_url)
                    csv_path = Functions.wait_for_temp_file(self.parent_bank.profile.temp_download_dir, 4)
                    if csv_path:
                        os.rename(csv_path, new_cvs_path)
                        break
                print(new_cvs_path, "created!")
            else:
                print(new_cvs_path, "exists!")
示例#23
0
    def __init__(self, **kwargs):

        self.child_widget = kwargs.get("child_widget")

        super().__init__(**Functions.remove_from_dict(kwargs, "child_widget"))

        self.add_widget(self.child_widget)
示例#24
0
    def get_term(self):

        xml_file_name = "StevensFiles/XML Sources/" + self.term_key + ".xml"
        if Functions.is_connected():
            urllib.request.urlretrieve(Constants.term_url_dict[self.term_key],
                                       xml_file_name)
        return Term.Term(Et.parse(xml_file_name))
示例#25
0
 def __str__(self, **kwargs):
     ret_str = "Course ID: {}, section count: {}".format(
         self.id, len(self.section_list))
     if kwargs.get("print_section_list"):
         for section in self.section_list:
             ret_str += "\n" + Functions.tab_string(
                 section.__str__(**kwargs))
     return ret_str
 def __str__(self, **kwargs):
     ret_str = "Subject ID: {}, course count: {}".format(
         self.id, len(self.course_list))
     if kwargs.get("print_course_list"):
         for course in self.course_list:
             ret_str += "\n" + Functions.tab_string(
                 course.__str__(**kwargs))
     return ret_str
示例#27
0
    def __init__(self, parent_account, file_path):

        self.file_path = file_path
        self.data_list_list = Functions.csv_to_list_list(self.file_path)

        self.dataframe = self.get_dataframe()

        super().__init__(parent_account, file_path, self.get_statement_df())
示例#28
0
    def get_dictionaries(self):

        main_attrib_dict = {}
        meeting_dict_list = []
        requirement_dict_list = []

        for element in self.xml.iter():
            if element.tag == "Course":
                main_attrib_dict = Functions.clean_dict(element.attrib)
            elif element.tag == "Meeting":
                meeting_dict_list.append(Functions.clean_dict(element.attrib))
            elif element.tag == "Requirement":
                requirement_dict_list.append(
                    Functions.clean_dict(element.attrib))
            else:
                print("Different Element Tag: " + element.tag)

        return main_attrib_dict, meeting_dict_list, requirement_dict_list
示例#29
0
 def __str__(self):
     ret_str = "name: {}".format(self.name) + "\t"
     ret_str += "article_count: {}".format(self.article_count) + "\t"
     ret_str += "keyword_list: {}".format(self.keyword_list)
     for i, article in enumerate(self.article_list):
         ret_str += "\n"
         ret_str += Functions.tab_str("Article {}: {}".format(
             i, str(article)))
     return ret_str
示例#30
0
    def get_subject_course_section_id_list(self):

        data_list = Functions.string_to_alternating_letter_to_num(self.section)

        subject_identifier = data_list[0]
        course_identifier = data_list[1]
        section_identifier = "".join(data_list[2:])

        return subject_identifier, course_identifier, section_identifier