<commit_before>import sys
import cv2
import numpy as np
import pickle
from cv_pickle import CVPickle

class CVError(Exception):
    def __init__(self, message):
        self.message = message
    def __str__(self):
        return repr(self.message)

class Assistant:
    def __init__(self, test_mode=False):
        self.test_mode = test_mode

    def handle_frame(self, header, raw_data):
        if self.test_mode:
            return self.handle_test(header, raw_data)

        # PERFORM Cognitive Assistant Processing
        sys.stdout.write("TEST processing: \n%s\n" % header)
        step = header["step"]


        img_array = np.asarray(bytearray(raw_data), dtype=np.int8)
        cv_image = cv2.imdecode(img_array, -1)

        result = {}
        step = int(float(step))
        print "ste"
        print step
        if step == 0:
            result = self.initial_check(cv_image)
        elif step == 1:
            print "initi setup"
            result = self.initial_setup(cv_image)
        elif step == 2:
            print "OK"


        return result


    def handle_test(self, header, raw_data):
        sys.stdout.write("processing: \n%s\n" % header)
        step = int(float(header["step"]))

        if step == 0:
            result = {  "warning" : "Room looks good.",
                      "next_step" : 1 }

        elif step == 1:
            print "initial setup"
            result = {  "warning": "Device looks okay. Please put it on your arm.",
                          "next_step": 1 }
        elif step == 2:
            print "OK"

        return result


    def initial_check(self, img):
<commit_msg>added basic serverside template<commit_after>import sys
import cv2
import numpy as np
import pickle
from cv_pickle import CVPickle

class CVError(Exception):
    def __init__(self, message):
        self.message = message
    def __str__(self):
        return repr(self.message)

class Assistant:
    def __init__(self, test_mode=False):
        self.test_mode = test_mode

    def handle_frame(self, header, raw_data):
        if self.test_mode:
            return self.handle_test(header, raw_data)

        # PERFORM Cognitive Assistant Processing
        sys.stdout.write("TEST processing: \n%s\n" % header)
        step = header["step"]


        img_array = np.asarray(bytearray(raw_data), dtype=np.int8)
        cv_image = cv2.imdecode(img_array, -1)

        result = {}
        step = int(float(step))
        print "ste"
        print step
        if step == 0:
            # STEP 0: INITIAL CHECK
            result = self.initial_check(cv_image)
        elif step == 1:
             # STEP 1: CHECK MONITOR UPRIGHT
            print "initi setup"
            result = self.initial_setup(cv_image)
        elif step == 2:
            # STEP 2: MONITOR ON RIGHT HAND, PALM UP
        elif step == 3:
            # STEP 3: DISTANCE BTWN CUFF AND WRIST
        elif step == 4:
            # STEP 4: STRAP TIGHTENED
        elif step == 5:
            # STEP 5: ELBOW ON SURFACE
        elif step == 6:
            # STEP 6: LEFT HAND ON HEART
        elif step == 7:
            # STEP 7: CUFF ON SAME LEVEL AS LEFT HAND / START MEASUREMENT
        elif step == 8:
            # STEP 8: ALL INDICATORS ON
        elif step == 9:
            # STEP 9: STABLE READING ON SCREEN

        return result


    def handle_test(self, header, raw_data):
        sys.stdout.write("processing: \n%s\n" % header)
        step = int(float(header["step"]))

        if step == 0:
            result = {  "warning" : "Room looks good.",
                      "next_step" : 1 }

        elif step == 1:
            print "initial setup"
            result = {  "warning": "Device looks okay. Please put it on your arm.",
                          "next_step": 1 }
        elif step == 2:
            print "OK"

        return result


    def initial_check(self, img):

{'fraction_non_alphanumeric': 0.09717948717948718, 'fraction_numerical': 0.010512820512820513, 'mean_word_length': 1.796415770609319, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5477148', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1137, 'n_words': 347}