Beispiel #1
0
def main():
    ctrl = True  # 标记是否退出系统
    while (ctrl):
        menu.menu()
        option = input("请选择:")
        option_str = re.sub('\D', '', option)  # 提取数字
        if option_str in ['0', '1', '2', '3', '4', '5', '6', '7']:
            option_int = int(option_str)
            if option_int == 0:
                print("您已退出学生管理系统!")
                ctrl = False
            elif option_int == 1:
                insert.insert()
            elif option_int == 2:
                search.search()
            elif option_int == 3:
                delete.delete()
            elif option_int == 4:
                modify.modify()
            elif option_int == 5:
                sort.sort()
            elif option_int == 6:
                total.total()
            elif option_int == 7:
                show.show()
Beispiel #2
0
def edit_marks(class_name):
    print('all info compile module')
    a = class_name[0]
    b = class_name[1]
    b = b.upper()
    file_name = b + '_' + str(a)
    file_name1 = file_name + '.db'
    con = _sqlite3.connect(file_name1)
    csr = con.cursor()
    try:
        a = 'select * from ' + file_name + ';'
        csr.execute(a)
        x = csr.fetchall()
        print(x)
        con.commit()
        con.close()
        a = str(input('input if you want to add(a) or modify(m) values '))
        if (a.lower() == 'a'):
            add.add_new(file_name)
        elif (a.lower() == 'm'):
            modify.modify(file_name)
        else:
            print('wrong input ')
    except:
        file_name = file_name.rstrip(';')
        add.add(file_name)
Beispiel #3
0
 def speak_w_command(self, add, command):
     print(add, command)
     s = self.speak
     ss = self.scripts
     if command == "right":
         s.Skip("SENTENCE", 1)
         if self.speak_line < len(ss) - 1:
             self.speak_line += 1
             if self.is_train == "t":
                 print(ss[self.speak_line],
                       modify.modify(ss[self.speak_line]))
             s.Speak(modify.modify(ss[self.speak_line]), 3)
             #s.Speak("Hello World", 3)
     elif command == "left":
         s.Skip("SENTENCE", 1)
         if self.speak_line > 1:
             self.speak_line -= 1
             if self.is_train == "t":
                 print(ss[self.speak_line])
             s.Speak(modify.modify(ss[self.speak_line]), 3)
     elif command == "surprised":
         s.Skip("SENTENCE", 1)
         if 0 <= self.speak_line and self.speak_line < len(ss) - 1:
             if self.is_train == "t":
                 print(ss[self.speak_line])
             s.Speak(modify.modify(ss[self.speak_line]), 3)
def saving():
    jsonData = request.get_json(cache=False)
    user=jsonData["userName"]
    type = "Goal"
    if request.method =='GET':
        getData = access(graph, type, user, user)
    elif request.method=='POST':
        postData = [jsonData["userName"], jsonData["savingsName"], jsonData["amount"], jsonData["downpay"],jsonData["term"],jsonData["description"]]
        insert(graph,type,postData)
    elif request.method=='PUT':
        current=["currentItem"]
        mod = jsonData["modItem"]
        modify(graph,type,user,current,mod)
    elif request.method=='DELETE':
        delItem=jsonData["delItem"]
		delete(graph,type,user,delItem)
    def __init__(self, remoteShell, domainAdmin="admin", domain=None):
        self.remoteShell = remoteShell
        self.uptoolPath = "/opt/quest/bin/uptool"     
        self.domainAdmin = domainAdmin
        self.defaultDomain = domain
        
        self.container = container.container(self.remoteShell, self.domainAdmin, self.defaultDomain) 
        self.create = upCreate.create(self.remoteShell, self.domainAdmin, self.defaultDomain)  
        self.delete = upDelete.delete(self.remoteShell, self.domainAdmin, self.defaultDomain) 
        self.depopulate = depopulate.depopulate(self.remoteShell, self.domainAdmin, self.defaultDomain) 
        self.list = upList.list(self.remoteShell, self.domainAdmin, self.defaultDomain) 
        self.membership = membership.membership(self.remoteShell, self.domainAdmin, self.defaultDomain) 
        self.migrate = migrate.migrate(self.remoteShell, self.domainAdmin, self.defaultDomain) 
        self.modify = modify.modify(self.remoteShell, self.domainAdmin, self.defaultDomain) 
        self.populate = populate.populate(self.remoteShell, self.domainAdmin, self.defaultDomain)

        isinstance(self.container, container.container)
        isinstance(self.create, upCreate.create)
        isinstance(self.delete, upDelete.delete)
        isinstance(self.depopulate, depopulate.depopulate)
        isinstance(self.list, upList.list)
        isinstance(self.membership, membership.membership)
        isinstance(self.migrate, migrate.migrate)
        isinstance(self.modify, modify.modify)
        isinstance(self.populate, populate.populate)
def transaction():
    jsonData = request.get_json(cache=False)
    user=jsonData["userName"]
    type = "Transaction"
    if request.method =='GET':
        getData = access(graph, type, user, user)
    elif request.method=='POST':
        postData = [jsonData["userName"], jsonData["transName"], jsonData["transDate"], jsonData["transLocation"],jsonData["transAmount"]]
        insert(graph,type,postData)
    elif request.method=='PUT':
        current=["currentItem"]
        mod = jsonData["modItem"]
        modify(graph,type,user,current,mod)
    elif request.method=='DELETE':
        delItem=jsonData["delItem"]
		delete(graph,type,user,delItem)
Beispiel #7
0
def site(domain):
    queue = deque()
    try:
        soup = BeautifulSoup(
            user_agent('http://www.baidu.com/s?wd=site:' + domain),
            'html.parser')
    except Exception as e:
        print(e)
        return

    allDomainRecorders = soup.find_all(['a'])
    print('解析百度站点查询 “' + domain + '” 成功')
    for item in allDomainRecorders:
        classLabel = item.get('class')

        if not classLabel:
            continue
        if 'c-showurl' not in classLabel:
            continue

        domainRecorder = item.string
        if domainRecorder is None:
            continue
        pattern = re.compile(r'/ $')
        domainRecorder = pattern.sub('', item.string)
        print('获取百度收录域名 “' + domainRecorder + '” 成功')
        queue.append(domainRecorder)

    if not queue.__contains__(domain):
        return
    if not queue.__contains__('www.' + domain):
        return

    print('此域名 "' + domain + '" 符合百度收录要求,已保存')
    fp = open("./Results/BaiDu_Results.txt", "a", encoding="utf-8")
    fp.write(domain)
    fp.write(u"\n")
    fp.close()
    current = gloVar.current
    modify(current + 1)
Beispiel #8
0
import time
import cmh
import modify,download

mon = time.localtime().tm_mon
day = time.localtime().tm_mday
page_list = []
url_list = []
title_list = []
pop_list = []
index_list = []
y = 0
cmh.get_article_url(page_list, url_list, title_list, pop_list, index_list)

for x in url_list:
	catch = title_list[y]
	index =str(index_list[y])
	title_list[y] =catch[1:len(catch)-1] +"_"+str(index_list[y])
	
	try:
		soup = download.download(x,title_list[y])
		modify.modify(soup,title_list[y])
		y +=1
	except:
		pass
Beispiel #9
0
#svr = svm.SVR()
###svr = RandomForestRegressor(n_estimators=400)
##GRB = GradientBoostingRegressor()
#grid = GridSearchCV(svr,parameter_range)
##clf = linear_model.SGDRegressor()
##clf.fit(samples_train,responses_train)
##results = clf.predict(samples_test)
##grid.fit (samples_train[0], responses_train[:,0])
Mo =[]
Mo_tem = []
for t in range (0,10):    
    locals()['clf' + str(0)]  = svm.SVR(C=ind[0],kernel='rbf', epsilon = ind[1],gamma =0.001)  
    X_train, X_test, y_train, y_test = cross_validation.train_test_split(samples[0], responses[:,0], test_size=0.2, random_state=0)
    locals()['clf' + str(0)].fit (X_train,y_train[:,0])
    results = locals()['clf' + str(0)].predict(X_test)
    mo = modify(results, y_test[:,0])
    Mo_tem = np.append(Mo_tem,mo)
Mo = np.mean(Mo_tem)
Mo_tem =[]
#a = np.abs(responses_test[:,0]-results)
#b = responses_test[:,0]-results
#sum_ = 0
#num_ = 0
#for i in range(results.shape[0]):
#    if (responses_test[:,0][i] != 0):
#        sum_ = sum_ + a[i]/responses_test[:,0][i]
#        num_ = num_ + 1
#print 'Dist'+str(0)+'eva: %f' %(sum_/num_)

for i in range(1,66):
##    for R in range(0,KmeanPOI[size_index].shape[0]):
Beispiel #10
0
Mo = []
Mos = []
Mo_tem = []
for t in range(0, 1):
    locals()['clf' + str(0)] = svm.SVR(C=ind[0],
                                       kernel='rbf',
                                       epsilon=ind[1],
                                       gamma=0.001)
    #    locals()['clf' + str(0)] = RandomForestRegressor(n_estimators = 1500, max_features=0.5,min_samples_leaf= 50, n_jobs =  - 1, verbose=1)
    X_train, X_test, y_train, y_test = cross_validation.train_test_split(
        samples[0], Responses[:, 0], test_size=0.2, random_state=t)
    locals()['clf' + str(0)].fit(X_train, y_train)
    results = locals()['clf' + str(0)].predict(X_test)
    Response = y_test
    print 'dis' + str(0 + 1) + 'rounds:' + str(t)
    mo = modify(results, y_test)
    Mo_tem = np.append(Mo_tem, mo)
Mo = np.mean(Mo_tem)
Mo_tem = []
Mos = np.append(Mos, Mo)
results_m = [max(i + Mo, 1) for i in results]

for i in range(1, 66):
    for e in range(0, 1):
        locals()['clf' + str(i)] = svm.SVR(C=ind[0],
                                           kernel='rbf',
                                           epsilon=ind[1],
                                           gamma=0.001)
        #        locals()['clf' + str(i)] = RandomForestRegressor(n_estimators = 1500, max_features=0.5,min_samples_leaf= 50, n_jobs =  - 1, verbose=1)
        X_train, X_test, y_train, y_test = cross_validation.train_test_split(
            samples[i], Responses[:, i], test_size=0.2, random_state=e)
from modify import modify

FILE_NAME = 'mobile.dbs'


def init():
    if not os.path.isfile(FILE_NAME):
        data = []
        with open(FILE_NAME, 'wb') as fp:
            pickle.dump(data, fp, protocol=0)
            print(FILE_NAME + " created")


if __name__ == '__main__':
    init()
    while True:
        # os.system("clear")
        print("1.Add\n2.Delete\n3.Modify\n4.Search\n5.Display\n6.Exit")
        choice = int(input("Enter your choice:"))
        if choice == 1:
            addMobile()
        elif choice == 2:
            delete()
        elif choice == 3:
            modify()
        elif choice == 4:
            search.search()
        elif choice == 5:
            display()
        else:
            break
Beispiel #12
0
def speak_scripts():
    global cut_loop
    global input_word2
    th = None

    speak = wincl.Dispatch("SAPI.SpVoice")
    speak.Rate = -3
    speak.Priority = 1 #0, 1, 2
    speak.SynchronousSpeakTimeout = 0
    speak_line = -1
    lines = setup.read_files(is_train, username, num)
    #speak.SpeakCompleteEvent = print_some()
    #print(speak.SpeakCompleteEvent)
    #print(speak.WaitForSingleObject(speak.SpeakCompleteEvent, -1))

    while True:
        #print("input_word2", input_word2 == "")
        if input_word2 == "":
            input_word = input("""
コマンドを選んでください
r->同じ行を繰り返して読む
u->次の行を読み上げる
d->前の行を読み上げる
>""")
        else:
            input_word = input_word2
            input_word2 = ""
        #if len(input_word) > 1:
        #    input_word = input_word[0]
        if len(input_word) > 0 and input_word[0] == "u":
            speak.Skip("SENTENCE", 1)
            #speak.Pause()
            if speak_line < len(lines) - 1:
                speak_line += 1

                if is_train == "t":
                    print(lines[speak_line])
                speak.Speak(modify.modify(lines[speak_line]), 3)
        elif len(input_word) > 0 and input_word[0] == "d":
            speak.Skip("SENTENCE", 1)
            if speak_line > 0:
                speak_line -= 1

                if is_train == "t":
                    print(lines[speak_line])

                speak.Speak(modify.modify(lines[speak_line]), 3)
        elif len(input_word) > 0 and input_word[0] == "r":
            speak.Skip("SENTENCE", 1)
            if 0 <= speak_line and speak_line < len(lines) - 1:

                if is_train == "t":
                    print(lines[speak_line])

                speak.Speak(modify.modify(lines[speak_line]), 3)
        elif len(input_word) > 0 and input_word[0] == "h":
            print(datetime.now().strftime("%Y/%m/%d %H:%M:%S.%f'"))
            f = open(username + str(num) + 'test.txt','a')
            f.write(datetime.now().strftime("%Y/%m/%d %H:%M:%S") + '\n')
            f.close()
        elif  input_word == "w":
            speak.Skip("SENTENCE", 1)
            if speak_line < len(lines) - 2:
                speak_line += 1

                words = modify.modify(lines[speak_line]).split(" ")
                #input_word2 = ""
                howmanytimes_speak = 0
                howmany_thread = 0
                for word in words:
                    #for cw in modify.change_words:
                    #    if word in cw:
                    #        ws = word.split(cw)
                    speak.Speak(word, 3)
                    while speak.WaitUntilDone(0) == False:
                        is_start_reading = True
                        if howmanytimes_speak == 0 and howmany_thread == 0:
                            th = multi()
                            howmany_thread += 1
                            cut_loop = False
                    else:
                        howmanytimes_speak += 1
                        print(word)
                        if howmanytimes_speak == len(words):
                            print("\007")
                            is_start_reading = False
                            cut_loop = True
                            #event.set()
                            #event.clear()
                            #th.join()

        elif input_word == "s":
            sys.exit()
        elif input_word == "a":
            speak.Rate += 1
        elif input_word == "m":
            speak.Rate -= 1

        elif input_word in ["1", "2", "3", "4", "5", "6", "7", "8", "9"]:
            speak.Rate = int(input_word) - 6
        else:
            print(input_word)
Beispiel #13
0
##clf = linear_model.SGDRegressor()
##clf.fit(samples_train,responses_train)
##results = clf.predict(samples_test)
##grid.fit (samples_train[0], responses_train[:,0])
Mo = []
Mo_tem = []
for t in range(0, 10):
    locals()['clf' + str(0)] = svm.SVR(C=ind[0],
                                       kernel='rbf',
                                       epsilon=ind[1],
                                       gamma=0.001)
    X_train, X_test, y_train, y_test = cross_validation.train_test_split(
        samples[0], responses[:, 0], test_size=0.2, random_state=0)
    locals()['clf' + str(0)].fit(X_train, y_train[:, 0])
    results = locals()['clf' + str(0)].predict(X_test)
    mo = modify(results, y_test[:, 0])
    Mo_tem = np.append(Mo_tem, mo)
Mo = np.mean(Mo_tem)
Mo_tem = []
#a = np.abs(responses_test[:,0]-results)
#b = responses_test[:,0]-results
#sum_ = 0
#num_ = 0
#for i in range(results.shape[0]):
#    if (responses_test[:,0][i] != 0):
#        sum_ = sum_ + a[i]/responses_test[:,0][i]
#        num_ = num_ + 1
#print 'Dist'+str(0)+'eva: %f' %(sum_/num_)

for i in range(1, 66):
    ##    for R in range(0,KmeanPOI[size_index].shape[0]):
Beispiel #14
0
    def run(self, key, cyIO):

        #  Display Active Python Process Threads.
        # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
        if eval(cyIO.getInfo("verbose")) == True:
            t_array = str(
                list(map(lambda x: x.getName(), threading.enumerate())))
            mirror.text("\r\nActive Threads = {")
            mirror.text("   " + t_array)
            mirror.text("} \r\n")

        tasks.queue.clear()

        #  Bypass Sending Header Data.
        # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
        if eval(cyIO.getInfo("noheader")) == False:

            #  Connected. Send Device Header to Data Stream.
            # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
            if eval(cyIO.getInfo("status")) == True and eval(
                    cyIO.getInfo("noweb")) == False:
                cyIO.sendInfo("device")
                cyIO.sendInfo("serial")
                cyIO.sendInfo("keymodel")
                cyIO.sendInfo("config")
                cyIO.sendInfo("datamode")
                cyIO.sendData(
                    1, "CyKITv2:::Info:::delimiter:::" +
                    str(ord(cyIO.getInfo("delimiter"))))

        self.generic = cyIO.getInfo("generic")

        #  Update Local Variables from ControllerIO Dictionary.
        # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

        for index in self.configFlags:
            setattr(self, index, eval(cyIO.getInfo(index)))

        #  EPOC+ Mode. (Direct USB Connection)
        # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
        if key == "":
            while self.running:
                time.sleep(0)

                if eval(cyIO.getInfo("status")) != True:
                    time.sleep(0)
                    self.running = False
                    continue
            return
        AES_key = key

        #  Create AES(ECB) Cipher.
        # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
        try:
            print(key)
            AES_key = bytes(bytearray(key))
            cipher = AES.new(AES_key, AES.MODE_ECB)

        except Exception as exception:
            mirror.text(
                " eegThread.run() : E1. Failed to Create AES Cipher ::: " +
                (str(exception)))

        while self.running:

            time.sleep(0)

            if self.blankdata == True:
                try:
                    if self.blank_data[self.KeyModel] == None:
                        mirror.text(
                            " ¯¯¯¯ No 'blankdata' for this model. Disabling 'blankdata' Mode."
                        )
                        self.blankdata = False
                        return
                    data = self.blank_data[self.KeyModel]
                    join_data = ''.join(map(chr, data))
                    time.sleep(0)  # Slow it down.
                    encrypted_blank_cipher = b"0" + (cipher.encrypt(
                        bytes(join_data, 'latin-1')))
                except Exception as e:
                    mirror.text(
                        " ¯¯¯¯ eegThread.run() Failed to Create Blank Cipher. Disabling 'blankdata' Mode."
                    )
                    mirror.text(" =E.4: " + str(e))
                    self.blankdata = False
                    return

                if eeg_driver == "pyusb":
                    tasks.put(encrypted_blank_cipher[1:])

            if eeg_driver == "pyusb" and self.blankdata == False:

                print(self.device)
                task = self.device.read(0x82, 32, 100)
                print('2')
                tasks.put(task.tostring())

            sleep_time = time.time()
            dataLoss = 0

            pre_deep_learning = []

            while not tasks.empty() and self.running == True:
                time.sleep(0)

                if eeg_driver == "pyusb":
                    if self.blankdata == False:
                        try:
                            task = self.device.read(0x82, 32, 1000)
                            tasks.put(task.tostring())
                        except Exception as e:
                            if str(e.errno) != "10060":
                                mirror.text("Error.eeg() = " + str(e.errno))
                                exc_type, ex, tb = sys.exc_info()
                                imported_tb_info = traceback.extract_tb(tb)[-1]
                                line_number = imported_tb_info[1]
                                print_format = "{}: Exception in line: {}, message: {}"
                            if 'dataLoss' not in locals():
                                dataLoss = 0
                            dataLoss += 1
                            if dataLoss > 50:
                                mirror.text(
                                    "\r\n ░░░ Device Interference or Turned Off ░░░ \r\n"
                                )
                                if cyIO.isRecording() == True:
                                    cyIO.stopRecord()
                    else:
                        time.sleep(0)
                        tasks.put(encrypted_blank_cipher[1:])

                #  Update Run-Time Config Options.
                # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
                self.format = int(cyIO.getInfo("format"))
                self.datamode = int(cyIO.getInfo("datamode"))
                self.delimiter = cyIO.getInfo("delimiter")
                self.baseline = eval(cyIO.getInfo("baselinemode"))

                try:
                    counter_data = ""
                    packet_data = ""
                    filter_data = ""
                    if eeg_driver == "pyusb":
                        task = tasks.get()
                        data = cipher.decrypt(task)
                        if self.outputraw == True:
                            mirror.text(str(list(task)))

                    self.getSeconds = int(time.time() % 60)

                    #  Epoc+
                    # ¯¯¯¯¯¯¯¯
                    if self.KeyModel == 6 or self.KeyModel == 5:

                        if str(data[1]) == "16":
                            if self.datamode == 2:
                                continue

                        if str(data[1]) == "32":
                            self.format = 1
                            if self.datamode == 1:
                                continue

                        if self.nocounter == True:
                            counter_data = ""
                        else:
                            counter_data = str(data[0]) + self.delimiter + str(
                                data[1]) + self.delimiter

                        # ~Format 0: (Default) (Decode to Floating Point)
                        # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
                        if self.format < 1:

                            packet_data_list = []
                            for i in range(2, 16, 2):
                                packet_data = packet_data + str(
                                    self.convertEPOC_PLUS(
                                        str(data[i]), str(
                                            data[i + 1]))) + self.delimiter
                                packet_data_list.append(
                                    float(
                                        self.convertEPOC_PLUS(
                                            str(data[i]), str(data[i + 1]))))

                            for i in range(18, len(data), 2):
                                packet_data = packet_data + str(
                                    self.convertEPOC_PLUS(
                                        str(data[i]), str(
                                            data[i + 1]))) + self.delimiter
                                packet_data_list.append(
                                    float(
                                        self.convertEPOC_PLUS(
                                            str(data[i]), str(data[i + 1]))))

                            packet_data = packet_data[:-len(self.delimiter)]
                            #mirror.text(str(packet_data))
                            pre_deep_learning.append(packet_data_list)
                            if (len(pre_deep_learning) >= 512):
                                pre_deep_learning_array = np.array(
                                    pre_deep_learning[-256:])
                                pre_deep_learning_array = np.reshape(
                                    pre_deep_learning_array, [256, -1])
                                filterarray = np.array(
                                    pre_deep_learning[-512:])
                                filterarray = np.reshape(
                                    filterarray, [512, -1])
                                pre_deep_learning = pre_deep_learning[-512:]
                                global pre_filter
                                pre_filter = filterarray
                                global npeeg
                                npeeg = pre_deep_learning_array
                                modify(pre_filter)
                                modify2(npeeg)
                                self.baseline = False

                            #  Averages Signal Data and Sends to Client.
                            # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                            if self.baseline == True:

                                if (int(time.time() % 60) - self.baseSeconds
                                    ) == 1:  # Baseline Every Second.
                                    #mirror.text("BASELINE ¯¯¯¯¯¯¯ " + str(self.baseline))
                                    try:
                                        if 'baseline_values' in locals():
                                            baseline_last = baseline_values
                                        baseline_values = [
                                            float(x) for x in
                                            packet_data.split(self.delimiter)
                                        ]

                                        if baseline_values != None and 'baseline_last' in locals(
                                        ):
                                            baseline_values = list(
                                                map(operator.add,
                                                    baseline_last,
                                                    baseline_values))
                                            set_values = ([2] *
                                                          len(baseline_values))
                                            baseline_values = list(
                                                map(operator.truediv,
                                                    baseline_values,
                                                    set_values))

                                            #  Re-order values.
                                            # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
                                            # self.epocOrder = [2,3,0,1,4,5,6,7,8,9,12,13,10,11]
                                            #baseline_new = [baseline_values[i] for i in self.epocOrder]

                                            cyIO.setBaseline(baseline_values)

                                            send_baseline = [
                                                0.0, float(str(data[1]))
                                            ] + baseline_values

                                            send_baseline = str(send_baseline)

                                            send_baseline = send_baseline[1:]

                                            send_baseline = send_baseline[:(
                                                len(send_baseline) - 1)]
                                            if self.outputdata == True:
                                                mirror.text(
                                                    "Python Baseline:::")
                                                mirror.text(str(send_baseline))

                                            cyIO.sendData(
                                                1, "CyKITv2:::Baseline:::" +
                                                str(send_baseline))

                                    except Exception as e:
                                        exc_type, ex, tb = sys.exc_info()
                                        imported_tb_info = traceback.extract_tb(
                                            tb)[-1]
                                        line_number = imported_tb_info[1]
                                        print_format = "{}: Exception in line: {}, message: {}"
                                        mirror.text(
                                            " ¯¯¯¯ eegThread.run() Error Creating Baseline Data."
                                        )
                                        mirror.text(" =E.7: " +
                                                    print_format.format(
                                                        exc_type.__name__,
                                                        line_number, ex))
                                self.baseSeconds = int(time.time() % 60)

                            #  Contact Quality. RMS Value.
                            # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
                            #if self.quality == True:
                            #baseline_values = map(math.sqrt, baseline_values)

                            if self.nobattery == False:
                                packet_data = packet_data + self.delimiter + str(
                                    data[16]) + str(self.delimiter) + str(
                                        data[17])

                            if self.outputdata == True:
                                pass
                                # print(packet_data)
                                #mirror.text(str(counter_data + packet_data))

                    try:
                        if self.filter == True and self.format == 0:
                            if 'baseline_values' in locals():
                                mirror.text(str("Baseline:"))
                                mirror.text(str(packet_data))
                                if self.nocounter == False:
                                    split_packet = packet_data.split(
                                        self.delimiter)
                                    split_packet = split_packet[:-2]
                                else:
                                    split_packet = packet_data.split(
                                        self.delimiter)

                                convert_packet = [
                                    float(x) for x in split_packet
                                ]
                                filter_data = map(operator.sub,
                                                  baseline_values,
                                                  convert_packet)
                                mirror.text(str("subtract::"))
                                mirror.text(str(convert_packet))
                                packet_data = str(filter_data)
                                packet_data = packet_data[1:]
                                packet_data = packet_data[:(len(packet_data) -
                                                            1)]

                    except OSError as e:
                        error_info = str(e.errno)
                        if error_info == "10035":
                            self.time_delay += .001
                            time.sleep(self.time_delay)
                            continue

                        if error_info == 9 or error_info == 10053 or error_info == 10035 or error_info == 10054:
                            mirror.text("\r\n Connection Closing.\r\n")

                            tasks.queue.clear()
                            if self.generic == True:
                                cyIO.onClose("0")
                            else:
                                cyIO.onClose("1")
                                if eeg_driver == "pywinusb":
                                    self.device.close()
                                cyIO.stopRecord()
                            continue
                        mirror.text(
                            " ¯¯¯¯ eegThread.run() Error creating OpenVibe Data and or Filtering Data."
                        )

                except Exception as e:
                    exc_type, ex, tb = sys.exc_info()
                    imported_tb_info = traceback.extract_tb(tb)[-1]
                    line_number = imported_tb_info[1]
                    print_format = "{}: Exception in line: {}, message: {}"
                    mirror.text(" ¯¯¯¯ eegThread.run() Error Formatting Data.")
                    mirror.text(" =E.8: " + print_format.format(
                        exc_type.__name__, line_number, ex))

                    #  So Long. Merci for the <)))<.
                    # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
        print('stopped!!!!!!!!!!!!!!!!!!!!!!!!!!')
Beispiel #15
0
RT = responses[0:590]
responses_test = np.array(RT)

ind=[7,1]     
Mo =[]
Mos = []
Mo_tem = []
for t in range (0,1):    
    locals()['clf' + str(0)]  = svm.SVR(C=ind[0],kernel='rbf', epsilon = ind[1],gamma =0.001)  
#    locals()['clf' + str(0)] = RandomForestRegressor(n_estimators = 1500, max_features=0.5,min_samples_leaf= 50, n_jobs =  - 1, verbose=1)
    X_train, X_test, y_train, y_test = cross_validation.train_test_split(samples[0], Responses[:,0], test_size=0.2, random_state=t)
    locals()['clf' + str(0)].fit (X_train,y_train)
    results = locals()['clf' + str(0)].predict(X_test)
    Response = y_test
    print 'dis'+str(0+1)+'rounds:'+str(t)
    mo = modify(results, y_test)
    Mo_tem = np.append(Mo_tem,mo)
Mo = np.mean(Mo_tem)
Mo_tem =[]
Mos = np.append(Mos,Mo)
results_m = [max(i+Mo,1) for i in results]

for i in range(1,66):
    for e in range(0,1):        
        locals()['clf' + str(i)]  = svm.SVR(C=ind[0],kernel='rbf', epsilon = ind[1],gamma =0.001)
#        locals()['clf' + str(i)] = RandomForestRegressor(n_estimators = 1500, max_features=0.5,min_samples_leaf= 50, n_jobs =  - 1, verbose=1)
        X_train, X_test, y_train, y_test = cross_validation.train_test_split(samples[i], Responses[:,i], test_size=0.2, random_state=e)
        locals()['clf' + str(i)].fit (X_train,y_train)
        locals()['result' + str(i)]= locals()['clf' + str(i)].predict(X_test)
        print 'dis'+str(i+1)+'rounds:'+str(e)
        mo = modify(locals()['result' + str(i)],y_test)
Beispiel #16
0
	auth = lg_authority.AuthRoot()
	auth__doc = "The object that serves authentication pages"


	@cherrypy.expose
	def index(self):
		output = ""

		output += getIndexContent()

		output = getPage(output, '')

		return output 

if __name__ == '__main__':

	#cherrypy.config.update({'server.socket_port':index_port})
	cherrypy.config.update(cherry_settings)
	
	index = index()
	index.upload = upload.upload()
	index.manage = manage.manage()
	index.modify = modify.modify()
	index.download = download.download()
	index.learn = learn.learn()
	index.support = support.support()
	index.visualize = visualize.visualize()
	#index.dashboard = dashboard.dashboard()
	cherrypy.quickstart(index)

Beispiel #17
0
                #tcpSerSock.close()
                break

            time.sleep(2)

            if (choice == '2'):

                x = temp[1]
                y = temp[2]

                x = int(x)
                y = int(y)

                duty_s = temp[3]
                duty_s = int(duty_s)

                modify.modify(duty_s, x, y)
                break

            if (choice == '3'):

                duty_s = temp[1]
                duty_s = int(duty_s)
                maintain.maintain(duty_s)

    except KeyboardInterrupt:
        ldr.close()
        GPIO.cleanup()

tcpSerSock.close()