Ejemplo n.º 1
0
def comp_mean(fn, sheet, column_1, column_2, column_3):
    rows = p.get_rows(fn, sheet, 1,
                      0)  #determine which rows correspond to relay
    values = p.read_xls_cell(fn, sheet, column_1, column_2, column_3,
                             rows)  #load values from xls
    mean = numpy.mean(values)
    return mean
Ejemplo n.º 2
0
def comp_variance(fn, sheet, column_1, column_2, column_3):
    rows = p.get_rows(fn, sheet, 1,
                      0)  #determine which rows correspond to relay
    values = p.read_xls_cell(fn, sheet, column_1, column_2, column_3,
                             rows)  #load values from xls
    variance = numpy.var(values)
    return variance
Ejemplo n.º 3
0
    def handle_clean(self):
        global G
        global priv
        global pub
        global auths
        global common_key
        global parsed
        
        try:
            inp = SockExt.recv_msg(self.request).strip()                
            data = json.loads(inp)
            print "[" + str(datetime.datetime.now())[:-7] + "] Request for: " + str(data['request'])

            if data['request'] == 'stat':
                #print data['contents']
                #parameters
                contents = data['contents']
                stat_type = contents['type']
                attributes = contents['attributes']
                attr_file = attributes['file']
                attr_sheet = attributes['sheet']
                attr_column_1 = attributes['column_1']
                attr_column_2 = attributes['column_2']
                attr_column_3 = attributes['column_3']
            
                if not str(attr_column_3) in parsed:
                    rows = p.get_rows(attr_file,attr_sheet, num_relays, unique_id) #determine which rows correspond to relay
                    values = p.read_xls_cell(attr_file, attr_sheet, attr_column_1, attr_column_2, attr_column_3, rows) #load values from xls
                    parsed[str(attr_column_3)] = values
                else:
                    values = parsed[str(attr_column_3)]


                if contents['data_type'] == 'sketch':
                    sk_w = attributes['sk_w']
                    sk_d = attributes['sk_d']
                    plain_sketch = generate_sketch(int(sk_w), int(sk_d), values) #construct sketch from values
                    res = plain_sketch.to_JSON()
                    
                elif contents['data_type'] == 'values':
                    evalues = encrypt_values(values, common_key)
                    res = cts_to_json(evalues)
                
                elif contents['data_type'] == 'values_sq':
                    sq_values = square_values(values)
                    evalues = encrypt_values(sq_values, common_key)
                    res = cts_to_json(evalues)
                
                SockExt.send_msg(self.request, json.dumps({'return': res})) #return serialized sketch
                print "[" + str(datetime.datetime.now())[:-7] + "] Request served."
                
                if conf.MEASUREMENT_MODE_RELAY:
                    self.server.shutdown()
            else:
                print "Unknown request type."
                
                    
        except Exception as e:
            print "Exception on incomming connection: ", e
Ejemplo n.º 4
0
Archivo: user.py Proyecto: str4d/Crux
def comp_variance(fn, sheet, column_1, column_2, column_3):
    rows = p.get_rows(fn, sheet, 1, 0) #determine which rows correspond to relay
    values = p.read_xls_cell(fn, sheet, column_1, column_2, column_3, rows) #load values from xls
    variance = numpy.var(values)
    return variance
Ejemplo n.º 5
0
Archivo: user.py Proyecto: str4d/Crux
def comp_mean(fn, sheet, column_1, column_2, column_3):
    rows = p.get_rows(fn, sheet, 1, 0) #determine which rows correspond to relay
    values = p.read_xls_cell(fn, sheet, column_1, column_2, column_3, rows) #load values from xls
    mean = numpy.mean(values)
    return mean