Beispiel #1
0
    def handle(self, *args, **options):
        Headword.objects.all().delete()

        self.stdout.write("Deleted Headwords!")
        self.stdout.write("Loading new data...")
        # load(items_path=options['items'], extra_meaning_path=options['meaning'], extra_phrases_path=options['phrases'])
        load(items_path=options['items'],
             combined_file=True,
             extra_phrases_path=options['phrases'])
        self.stdout.write("Done!")
def server_dll(bit_stream):
    data = ""
    checks = load(settings.ERROR_CHECKING)
    framer = load(settings.FRAMING_SCHEME)
    frames = framer().de_frame(bit_stream)
    for frame in frames:
        decoded = checks(frame).decode()
        if decoded != "":
            data += bits2str(decoded)
        else:
            return ""
    return data
def client_dll(msg):
    data = str2bits(msg)
    checks = load(settings.ERROR_CHECKING)
    error_generator = load(settings.ERROR_GENERATOR)
    framer = load(settings.FRAMING_SCHEME)

    packets = make_packets(data)
    frames_to_send = []
    for packet in packets:
        encoded_ = checks(packet).encode()
        errored_ = error_generator(encoded_)
        framed_ = framer().en_frame(errored_)
        frames_to_send.append(framed_)
    return frames_to_send
Beispiel #4
0
def client_physical(frames):
    line_schemes = load(settings.LINE_CODING_SCHEME)
    encoded_frames = []
    for frame in frames:
        encoded_ = line_schemes(frame).encode()
        encoded_frames.append(encoded_)
    return encoded_frames
    def run(self):
        #expand_all = self.locate(type='xpath', locator='//a[@id="facetapi-link--6607"]').click()
        _all_subjects = self.locate(type='xpath',
                                    locator='//li[@class="expanded last"]'
                                    '/div[@class="item-list"]'
                                    '/ul/li[@class="leaf"]/a',
                                    multiple=True)
        all_subject_links = {
            subject.get_attribute('id'): subject.get_attribute('href')
            for subject in _all_subjects if subject
        }
        # Setup CSV and np array
        explored_subjects = utils.load(term=self.args.term,
                                       school=self.args.school,
                                       col_name='Department_Abbreviation',
                                       test=self.args.test,
                                       reset=self.args.reset)

        for code in filter(lambda x: (x not in explored_subjects),
                           list(all_subject_links.keys())):
            self.subject_course_info = []
            course_info = CourseInfo.copy()
            self.driver.get(all_subject_links[code])
            self.process_subject(course_info)
            # Save to csv
            if self.args.save:
                explored_subjects = np.append(explored_subjects, code)
                utils.save(dict_list=self.subject_course_info,
                           ref_template=CourseInfo,
                           term=self.args.term,
                           school=self.args.school,
                           explored_subjects=explored_subjects,
                           test=self.args.test)
        return explored_subjects
Beispiel #6
0
 def run(self, args):
     # Sorter All Programs Button
     self.locate(
         type='xpath',
         locator="//ul[@id='sorter-classes']/li/a[@data-sort-by='data-code']"
     ).click()
     _all_programs = self.locate(type='xpath',
                                 locator="//ul[@id='sortable-classes']/li",
                                 multiple=True)
     # Setup CSV and np array
     explored_subjects = utils.load(term=args.term,
                                    school=args.school,
                                    col_name='Department_Abbreviation',
                                    test=args.test,
                                    reset=args.reset)
     all_codes = [
         element.get_attribute('data-code') for element in _all_programs
     ]
     explored_adj = len(explored_subjects)
     for idx, code in enumerate(
             filter(lambda x: (x not in explored_subjects), all_codes)):
         self.locate(
             type='xpath',
             locator=
             "//ul[@id='sorter-classes']/li/a[@data-sort-by='data-code']"
         ).click()
         subject = self.locate(
             type='xpath',
             locator=f"//ul[@id='sortable-classes']/li[@data-code='{code}']"
         )
         self.subject_course_info = []
         course_info = CourseInfo.copy()
         course_info['Department_Name'] = subject.get_attribute(
             'data-title')
         course_info['Department_Abbreviation'] = code
         print(
             f'Selected Subject {code} - {int(((idx+explored_adj)/len(all_codes))*100)}% complete'
         )
         subject_link = self.locate(driver=subject, type='tag',
                                    locator='a').get_attribute('href')
         self.driver.get(subject_link)
         self.process_subject(course_info)
         # Save to csv
         if args.save:
             explored_subjects = np.append(explored_subjects, code)
             utils.save(dict_list=self.subject_course_info,
                        ref_template=CourseInfo,
                        term=args.term,
                        school=args.school,
                        explored_subjects=explored_subjects,
                        test=args.test)
         # Return to home page each iteration
         self.driver.back()
     return explored_subjects
 def run(self, args):
     _subject_select = self.locate(type='xpath',
                                   locator="//select[@id='crit-subject']")
     _subject_options = self.locate(driver=_subject_select,
                                    type='tag',
                                    locator='option',
                                    multiple=True)
     _search_button = self.locate(type='id', locator='search-button')
     # Setup CSV and np array
     explored_subjects = utils.load(term=args.term,
                                    school=args.school,
                                    col_name='Department_Abbreviation',
                                    test=args.test,
                                    reset=args.reset)
     # Main Campus Only
     _campus_select_main_campus = self.locate(
         type='xpath',
         locator="//select[@id='crit-camp']/option[@value='BLDR']").click()
     explored_adj = len(explored_subjects)
     for idx, subject in enumerate(
             filter(
                 lambda x: (x.get_attribute('value') and x.get_attribute(
                     'value') not in explored_subjects), _subject_options)):
         # Make a class for the subject
         self.subject_course_info = []
         course_info = CourseInfo.copy()
         # Get the Subject Name, and add values to course_info
         course_info['Department_Abbreviation'] = saubject.get_attribute(
             'value')
         course_info['Department_Name'] = subject.text.rsplit(' ', 1)[0]
         print(
             f'Selected Subject {course_info["Department_Abbreviation"]} - {int(((idx+explored_adj)/len(_subject_options))*100)}% complete'
         )
         subject.click()
         # Eliminate Error of search button off-screen
         self._click(_search_button)
         self.process_subject(course_info)
         # Save to csv
         if args.save:
             explored_subjects = np.append(
                 explored_subjects, course_info['Department_Abbreviation'])
             utils.save(dict_list=self.subject_course_info,
                        ref_template=CourseInfo,
                        term=args.term,
                        school=args.school,
                        explored_subjects=explored_subjects,
                        test=args.test)
     return explored_subjects
def server_physical(bit_stream):
    line_schemes = load(settings.LINE_CODING_SCHEME)
    decoded_bit_stream = line_schemes(bit_stream).decode()
    return decoded_bit_stream