Example #1
0
    def get_response(self, request):
        result = "OK"
        header = ""

        message = io.StringIO(request)
        sections = sectionize(message)
        
        try:
            for h in sections.keys():
                header = h
                if re.match("PUT", header):
                    result = self.put_resource(header, sections[header], self.header_file_map)
                    self.ratchet_hub.log_info(self.name, "Done with '%s'" % header)
                elif re.match("GET", header):
                    result = self.get_resource(header, sections[header], self.header_file_map)
                    self.ratchet_hub.log_info(self.name, "Done with '%s'" % header)
                else:
                    self.log_error("Unrecognized header: %s" % header)
                    result = "TODO: Handle %s" % header
        except Exception as e:
            self.log_error("Problem with request: " % message)
            error_message = "Couldn't find header (%s) in snapshot service" % (header)
            self.log_error(error_message)
            result = error_message

        return result
Example #2
0
    def process_app_data(self, cond_data):
        output = StringIO.StringIO()
        sections = sectionize(StringIO.StringIO(cond_data))
        [start, end] = sections["params"].split("\t")

        my_dates = self.get_dates(start, end)

        staff_lines = sections["staff"]
        track_staff = self.get_track_staff(staff_lines)

        tracks = track_staff.keys()
        tracks.sort()

        out_lines = sections["outdays"]
        vacations = self.get_vacations(track_staff["All"], out_lines, my_dates)

        # Print streams
        self.print_params(start, end, output)
        self.print_day_stream(my_dates, output)
        self.print_track_stream(tracks, output)
        self.print_outday_stream(tracks, track_staff, vacations, output)

        result = output.getvalue()
        output.close()
        return result
Example #3
0
    def get_inputs(self, headers=None):
        if not headers:
            headers = self.get_headers()

        result = []
        for h in headers:
            input_data = StringIO.StringIO(self.snapshot_requester.make_request(h))
            input_sections = sectionize(input_data)
            result.append(input_sections["data"])
        return result
Example #4
0
    def process_app_data(self, cond_data):
        output = StringIO.StringIO()
        sections = sectionize(StringIO.StringIO(cond_data))

        parsed_data = {}
        for team in sections.keys():
            parsed_data[team] = json.loads(sections[team])

        self.print_dimension_stream("teams", parsed_data.keys(), output)

        # Extract skills
        skills = self.gather_skills(parsed_data)
        self.print_dimension_stream("skills", skills, output)

        # Print data
        self.print_quarters(parsed_data, skills, output)
        self.print_resource_data(parsed_data, skills, output)
        self.print_unassigned(parsed_data, skills, output)

        result = output.getvalue()
        output.close()

        return result