# -*- coding: utf-8 -*-
from __future__ import division
import json
import os
import sys
import base64
import struct

def read_json_file(file_name):
    '''just read config of poll'''
    if os.path.exists(file_name):
        f = open(file_name, 'r')
        data = f.read()
        dev_data = json.loads(data)
        f.close()
        return dev_data
    else:
        return None

def data_transfer(data):
    scope_data = ""
    decoded_data = ""
    list_data = []
    scope_data = data["data"]
    decoded_data = base64.b64decode(scope_data)
    list_data = list(struct.unpack("<2400H", decoded_data))
    return list_data

# listdir=os.listdir("C:\Users\harry-shen\Desktop\\fiveWave\\")
# for eachfile in listdir:
#     with open("C:\Users\harry-shen\Desktop\\fiveWave\\"+eachfile,"r") as rf:
#         data=rf.readlines()
#         # print data[0]
#         data=eval(data[0])
#         data_transfer(data)