def body_iq_test_device_connect_during_activity(device): print("---------------------------------------") print("- DEVICE CONNECT DURING ACTIVITY TEST -") print("---------------------------------------") device.disconnect() print("") print("Start an activity") print("") time.sleep(10) device = util.connection(["\x49\x42\x41\x00"]) rl = device.itm_subscribe_req("\x49\x42\x41\x00\x00") pub = device.itm_poll(expect="publish", timeout=10) assert pub == None print("") print("Stop your activity") print("") # Wait for activity to be finished and published to not pollute following tests time.sleep(10) print("") print("TESTS PASSED") return device
def body_iq_test_clear_activities(device): print("-------------------------") print("- CLEAR ACTIVITIES TEST -") print("-------------------------") device.disconnect() print("") print("Do 2 activities (6 steps by activity is enough)") print("") time.sleep(45) device = util.connection(["\x49\x42\x41\x53\x00", "\x49\x42\x41\x00"]) print "Cleaning all stored activities...." notif = ActivitySettings() notif.activity_discard_stored_data = 1 # Publish to intel/body/activity/setting and Wait response pub = device.itm_topic_req("\x49\x42\x41\x53\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") else: print("topic_rsp: status %s"%(str(pub['status']))) assert pub['status'] == 0 # Try to get activities print "Trying to get activities..." rl = device.itm_subscribe_req("\x49\x42\x41\x00\x00") # return code is none when subscribe is OK assert rl == None pub = device.itm_poll(expect="publish", timeout=30) # No publish sent by the device => return code is none assert pub == None print("") print("TESTS PASSED") return device
def create_adjacency_matrix(word_list): line_count = len(word_list) matrix = [[False for _ in range(line_count)] for _ in range(line_count)] for i in range(line_count): for j in range(line_count): matrix[i][j] = False if i == j else connection(word_list[i].word, word_list[j].word) matrix[j][i] = matrix[i][j] return matrix
def body_iq_test_granularity_setting(device): device.disconnect() print("---------------------------------------") print("- SET NEW GRANULARITY TEST -") print("---------------------------------------") device = util.connection(["\x49\x42\x41\x53\x00"]) activitySettings = ActivitySettings() activitySettings.activity_report_granularity = 50 device.itm_topic_req("\x49\x42\x41\x53\x00", activitySettings.SerializeToString()) print("") print("TESTS PASSED") return device
def main(): """ - Update mobile number in google contacts to correct format - """ # Connect to GContacts by Google People API connections, service = util.connection() # Blank name list blank_lst = [] # Get every GContacts users one by one for person in connections: # Get etag and resourceName by person - needed for proceed to the update etag = person.get('etag') resource_name = person.get('resourceName') # Get the name by person names = person.get('names', []) name = "" if names: name = names[0].get('displayName') # Get the phone number by person phones = person.get('phoneNumbers', []) if phones: phone_value = phones[0].get('value') # Format the number and return it formatted_number = util.format_numbers(phone_value) # if there is a formatted number, update it in GContacts if formatted_number != "": # Show the difference print(name + " : " + str(phone_value) + " -> " + str(formatted_number)) # Update the phone number in Google Contacts util.update_formatted_number(service, resource_name, etag, formatted_number) # Add the number in a list if the name is blank if name == "": blank_lst.append(formatted_number) # Add the list of blank name in a CSV file util.blank_name_to_csv(blank_lst)
def body_iq_test_device_connect_after_activity(device): print("--------------------------------------") print("- DEVICE CONNECT AFTER ACTIVITY TEST -") print("--------------------------------------") device.disconnect() print("") print("Start an activity") print("") time.sleep(10) print("Stop your activity") print("") time.sleep(15) device = util.connection(["\x49\x42\x41\x00"]) rl = device.itm_subscribe_req("\x49\x42\x41\x00\x00") pub = device.itm_poll(expect="publish", timeout=30) assert pub != None DecodedActivity = Activity() DecodedActivity.ParseFromString(pub['data']) step_count = 0 if DecodedActivity.HasField('walking_activity'): step_count = DecodedActivity.walking_activity.step_count elif DecodedActivity.HasField('running_activity'): step_count = DecodedActivity.running_activity.step_count print("Activity " + activity[DecodedActivity.type] + "\n" + " begin " + str(DecodedActivity.timestamp_begin) + " end " + str(DecodedActivity.timestamp_end) + " step count " + str(step_count) + "\n" + " status " + status[DecodedActivity.activity_status]) # Verify that an activity finished report has been received assert status[DecodedActivity.activity_status] == 'FINISHED' print("") print("TESTS PASSED") return device
def body_iq_test_flash_storage_activity(device): print("-------------------------------") print("- FLASH STORAGE ACTIVITY TEST -") print("-------------------------------") device.disconnect() print("") print("Do 2 activities (6 steps by activity is enough)") print("") time.sleep(45) device = util.connection(["\x49\x42\x41\x00"]) rl = device.itm_subscribe_req("\x49\x42\x41\x00\x00") nb_publish = 0 while (nb_publish < 2): pub = device.itm_poll(expect="publish", timeout=30) assert pub != None DecodedActivity = Activity() DecodedActivity.ParseFromString(pub['data']) step_count = 0 if DecodedActivity.HasField('walking_activity'): step_count = DecodedActivity.walking_activity.step_count elif DecodedActivity.HasField('running_activity'): step_count = DecodedActivity.running_activity.step_count print("Activity " + activity[DecodedActivity.type] + "\n" + " begin " + str(DecodedActivity.timestamp_begin) + " end " + str(DecodedActivity.timestamp_end) + " step count " + str(step_count) + "\n" + " status " + status[DecodedActivity.activity_status]) nb_publish = nb_publish + 1 # Verify that the 3 first activities finished reports has been received assert status[DecodedActivity.activity_status] == 'FINISHED' time.sleep(10) print("") print("TESTS PASSED") return device
if len(notif.data) < data_max_size: break fd.close() print "Time to perform " + str(i) + " transfers and flash " + str(file_len) + " bytes : " + str(time.time() - time_before).split('.')[0] + "s" #Wait ota reboot print "Waiting OTA reboot....(110 s)" time.sleep(110) # connect to device device = util.connection([], "fota") quark_id_new = device.disfwrev.read() print "New quark id: " + quark_id_new + " --- Old quark id: " + quark_id if quark_id_new == quark_id: print "Same firmware id --- binary file was ignored by bootloader" else: print "Firmware id different --- binary file was accepted by bootloader" return device if __name__ == "__main__": # connect to device device = util.connection([], "fota") first_req_cancel(device, sys.argv[2]) device.disconnect()
import util import body_iq_tests import devicename_iq_tests import notif_iq_tests import userevents_iq_tests import datetime_iq_tests import factoryreset_iq_tests import fota_iq_tests import systemevents_iq_tests if __name__ == "__main__": import sys #special case for fota which need two parameters device_0 = util.connection([], "fota") device_1 = fota_iq_tests.fota_iq_automatic_test(device_0, sys.argv[2]) device_1.disconnect() # Remove arg 2 from parameter and connect again for other test sys.argv.pop() device_2 = util.connection(["\x49\x42\x41\x00","\x49\x43\x44\x44\x00","\x49\x43\x44\x46\x00","\x49\x43\x44\x4E\x00","\x49\x43\x4E\x00"]) systemevents_iq_tests.system_event_iq_automatic_test(device_2) devicename_iq_tests.devicename_iq_automatic_test(device_2) notif_iq_tests.notif_iq_automatic_test(device_2) userevents_iq_tests.userevents_iq_automatic_test(device_2) datetime_iq_tests.datetime_iq_automatic_test(device_2) body_iq_tests.body_iq_automatic_test(device_2) factoryreset_iq_tests.factoryreset_iq_automatic_test(device_2)
def cancel_req_during_flashing(device, firmware_path): #get firmware id quark_id = device.disfwrev.read() print "QUARK ID : %s"%quark_id # Set binary file, the binary test file shall contain only at least QUARK firmware firmware_path = sys.argv[2] try: print "Firmware file: " + firmware_path stat = os.stat(firmware_path) file_len = stat.st_size except: print '\nERROR: file - ' + firmware_path + '- not found' exit() try: # Search the pattern ATP1LAK000 in the binary file fd = open(firmware_path, "rb") s = fd.read(file_len) fd.close() firmware_id_to_flash = re.search('ATP1LAK000-[0-9A-Fa-f]{9}', s).group() except: print '\nERROR: binary test file: ' + firmware_path + ' does not contain QUARK firmware' exit() # Instantiate a Firmware Update START request notif = FirmwareUpdate() notif.firmware_total_length = file_len #Perform a state request before starting print ("----------------------------") print ("------ CHECK DEVICE ------") print ("-----------------------------") # Publish to intel/core/FirmwareUpdate/State and Wait response pub = device.itm_topic_req("\x49\x43\x46\x53\x00", "\x00") if pub == None: print("No topic_rsp received") else: print("topic_rsp: req_id %s status %s"%(str(pub['req_id']), str(pub['status']))) decodedResp = FirmwareUpdateState() decodedResp.ParseFromString(pub['data']) print("response value = " + str(decodedResp.firmware_update_state)) assert pub['status'] == 0 if decodedResp.firmware_update_state != FirmwareUpdateState.NONE: #Perform a cancel request print ("--------------------------------------------------") print ("------ DEVICE NOT READY => CANCEL REQUEST ------") print ("--------------------------------------------------") # Prepare a Firmware Update CANCEL request notif.firmware_update_cmd = FirmwareUpdate.CANCEL # Publish to intel/core/Firmware and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") else: print("topic_rsp: status %s"%(str(pub['status']))) assert pub['status'] == 0 else: print ("---------------------------------------------") print ("------ DEVICE READY => START REQUEST ------") print ("---------------------------------------------") # BLE max message size is 132 bytes, the BLE message contain header + topic + req_id + protobuf serialization # protobuf serialization contain : command (start, cancel continue) + firmware size + data + size # After some test max data size allowed is 114 data_max_size = 114 notif.offset = 0 notif.firmware_update_cmd = FirmwareUpdate.START print "Firmware size: %d"%file_len # Publish to intel/core/FirmwareUpdate and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") else: print("topic_rsp: status %s"%(str(pub['status']))) assert pub['status'] == 0 #Wait recovery reboot print 'Waiting RECOVERY reboot.....' time.sleep(20) # connect to device device = util.connection([], "fota") print ("-------------------------------------") print ("------ STATE REQUEST: ------") print ("------ STARTED RESP EXPECTED ------") print ("-------------------------------------") # Publish to intel/core/FirmwareUpdate/State and Wait response pub = device.itm_topic_req("\x49\x43\x46\x53\x00", "\x00") if pub == None: print("No topic_rsp received") else: print("topic_rsp: req_id %s status %s"%(str(pub['req_id']), str(pub['status']))) decodedResp = FirmwareUpdateState() decodedResp.ParseFromString(pub['data']) print("Response value = %d (expected: %d)"%(decodedResp.firmware_update_state, FirmwareUpdateState.STARTED)) assert pub['status'] == 0 assert decodedResp.firmware_update_state == FirmwareUpdateState.STARTED print ("--------------------------------") print ("------ CONTINUE REQUEST ------") print ("--------------------------------") # Prepare a Firmware Update CONTINUE request notif.firmware_update_cmd = FirmwareUpdate.CONTINUE fd = open(firmware_path, "rb") time_before = time.time() i = 0 while 1: i = i + 1 if i%10 == 0: print str(i) + ' requests executed' notif.data = fd.read(data_max_size) # Publish to intel/core/Firmware and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") print("topic_rsp: status %d"%(pub['status'])) else: assert pub['status'] == 0 notif.offset += len(notif.data) if i==15: print ("----------------------------------------------") print ("------ CANCEL REQUEST DURING FLASHING ------") print ("----------------------------------------------") notif.firmware_update_cmd = FirmwareUpdate.CANCEL # Publish to intel/core/FirmwareUpdate and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") else: print("topic_rsp: status %s"%(str(pub['status']))) assert pub['status'] == 0 fd.close() break print ("----------------------------------") print ("------ STATE REQUEST: ------") print ("------ NONE RESP EXPECTED ------") print ("----------------------------------") # Publish to intel/core/FirmwareUpdate/State and Wait response pub = device.itm_topic_req("\x49\x43\x46\x53\x00", "\x00") if pub == None: print("No topic_rsp received") else: print("topic_rsp: req_id %s status %s"%(str(pub['req_id']), str(pub['status']))) decodedResp = FirmwareUpdateState() decodedResp.ParseFromString(pub['data']) print("Response value = %d (expected: %d)"%(decodedResp.firmware_update_state, FirmwareUpdateState.NONE)) assert pub['status'] == 0 assert decodedResp.firmware_update_state == FirmwareUpdateState.NONE print ("-----------------------------------") print ("------ START REQUEST AGAIN ------") print ("-----------------------------------") notif.firmware_update_cmd = FirmwareUpdate.START print "Firmware size: %d"%file_len # Publish to intel/core/FirmwareUpdate and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") else: print("topic_rsp: status %s"%(str(pub['status']))) assert pub['status'] == 0 #Wait recovery reboot print 'Waiting RECOVERY reboot.....' time.sleep(20) # connect to device device = util.connection([], "fota") print ("-------------------------------------") print ("------ STATE REQUEST: ------") print ("------ STARTED RESP EXPECTED ------") print ("-------------------------------------") # Publish to intel/core/FirmwareUpdate/State and Wait response pub = device.itm_topic_req("\x49\x43\x46\x53\x00", "\x00") if pub == None: print("No topic_rsp received") else: print("topic_rsp: req_id %s status %s"%(str(pub['req_id']), str(pub['status']))) decodedResp = FirmwareUpdateState() decodedResp.ParseFromString(pub['data']) print("Response value = %d (expected: %d)"%(decodedResp.firmware_update_state, FirmwareUpdateState.STARTED)) assert pub['status'] == 0 assert decodedResp.firmware_update_state == FirmwareUpdateState.STARTED print ("--------------------------------") print ("------ CONTINUE REQUEST ------") print ("--------------------------------") # Prepare a Firmware Update CONTINUE request notif.firmware_update_cmd = FirmwareUpdate.CONTINUE notif.offset = 0 fd = open(firmware_path, "rb") time_before = time.time() i = 0 while 1: i = i + 1 if i%10 == 0: print str(i) + ' requests executed' notif.data = fd.read(data_max_size) # Publish to intel/core/Firmware and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") print("topic_rsp: status %d"%(pub['status'])) else: assert pub['status'] == 0 notif.offset += len(notif.data) if len(notif.data) < data_max_size: break fd.close() print "Time to perform " + str(i) + " transfers and flash " + str(file_len) + " bytes : " + str(time.time() - time_before).split('.')[0] + "s" #Wait ota reboot print "Waiting OTA reboot....(110 s)" time.sleep(110) # connect to device device = util.connection([], "fota") quark_id_new = device.disfwrev.read() print "New quark id: " + quark_id_new + " --- Old quark id: " + quark_id if quark_id_new == quark_id: print "Same firmware id --- binary file was ignored by bootloader" else: print "Firmware id different --- binary file was accepted by bootloader" return device
break fd.close() print "Time to perform " + str(i) + " transfers and flash " + str(file_len) + " bytes : " + str(time.time() - time_before).split('.')[0] + "s" #Wait ota reboot print "Waiting OTA reboot....(110 s)" time.sleep(110) # connect to device device = util.connection([], "fota") quark_id_new = device.disfwrev.read() print "New quark id: " + quark_id_new + " --- Old quark id: " + quark_id if quark_id_new == quark_id: print "Same firmware id --- binary file was ignored by bootloader" else: print "Firmware id different --- binary file was accepted by bootloader" return device if __name__ == "__main__": device = util.connection([], "fota") cancel_req_during_flashing(device, sys.argv[2]) device.disconnect()
print("- Double Tap, expected type: 0") print("- Triple Tap, expected type: 1") pub = device.itm_poll(expect="publish", timeout = 30) if pub == None: print("No publish received") else: print("Publish on topic " + binascii.hexlify(pub['topic'])) userevent = UserEvent() userevent.ParseFromString(pub['data']) if userevent.HasField('button_event'): print ("Button Event Type: " + str(userevent.button_event.type)) elif userevent.HasField('tapping_event'): print ("Tapping Event Type: " + str(userevent.tapping_event.type)) else: print ("No Button or Tapping event") def userevents_iq_test_run_all_tests(device): print("---------------------------") print("- USER EVENT IQ TEST -") print("---------------------------") device.itm_subscribe_req("\x49\x43\x45\x55\x00\x00") userevents_iq_test(device) if __name__ == "__main__": device = util.connection(None) userevents_iq_test_run_all_tests(device) device.disconnect()
print("- 4 Short Double Click 80% ") print("- 5 Transition Click 2 80% -") print("-------------------------------------") print("") print("") data = data_parameter(notif_has_vibr = True, vibr_pattern_type = Notification.VIBRA_SPECIAL_EFFECTS ) notif_iq_test(device, data) print("--------------step 13----------------") print("- TEST SQUARE VIBRA -") print("- + BLINK_X2 LED -") print("- 1 repetitions (run 2 times) -") print("-------------------------------------") print("") print("") data = data_parameter(notif_has_vibr = True, vibr_repetition_count = 1, notif_has_led = True, led_rgb_count = 2, led_repetition_count = 1) notif_iq_test(device, data) if __name__ == "__main__": device = util.connection(["\x49\x43\x4E\x00"]) notif_iq_test_run_all_tests(device) device.disconnect()
rl = device.itm_subscribe_req("\x49\x42\x41\x00\x00") #run manual test body_iq_test_activity_start_report_request_and_stop(device) body_iq_test_activity_start_activity_reports_and_stop(device) device_2 = body_iq_test_device_connect_after_activity(device) device_3 = body_iq_test_granularity_setting(device_2) device_4 = body_iq_test_device_connect_during_activity(device_3) device_5 = body_iq_test_flash_storage_activity(device_4) device_6 = body_iq_test_activity_classification(device_5) device_7 = body_iq_test_clear_activities(device_6) device_8 = body_iq_test_date_change_during_activity(device_7) return device_8 if __name__ == "__main__": device = util.connection(["\x49\x42\x41\x00"]) print "Cleaning all stored activities...." notif = ActivitySettings() notif.activity_discard_stored_data = 1 # Publish to intel/body/activity/setting and Wait response pub = device.itm_topic_req("\x49\x42\x41\x53\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") else: print("topic_rsp: status %s"%(str(pub['status']))) assert pub['status'] == 0 device_3 = body_iq_test_run_all_tests(device) device_3.disconnect()
def searchEpisodes(): quality = util.getQuality() conn = util.connection() cursor = conn.cursor() cursor.execute('select * from shows') shows = cursor.fetchall() cursor.close() conn.close() for show in shows: name = show[0] currentEpisode = [int(show[2]), int(show[3])] newEpisodes = [] processedEpisodes = [] params = {"SearchString": show[1]} query = urllib.urlencode(params) url = str(web) + "/search/" tvShow = urllib.urlopen(url, query) episodes = tvShow.read() tvShow.close() episodes = util.extractAll( episodes, '<tr name="hover" class="forum_header_border">', '</tr>') for episode in episodes: info = util.extractAll(episode, '<td class="forum_thread_post">', '</td>') info = info[0].strip() info = util.extractAll(info, 'class="epinfo">', '</a>') if (re.search('720p', info[0], re.I)): info = re.findall(r'(\d{1,2})(?:e|x|episode)(\d{1,2})', info[0], re.I) info = [int(info[0][0]), int(info[0][1]), "720p"] else: info = re.findall(r'(\d{1,2})(?:e|x|episode)(\d{1,2})', info[0], re.I) info = [int(info[0][0]), int(info[0][1]), "hdtv"] urls = util.extractAll( episode, '<td align="center" class="forum_thread_post">', '</td>') linkNumber = re.findall('class="download_', urls[0], re.IGNORECASE) linkNumber = len(linkNumber) links = [] for link in (util.extractAll(urls[0], '</a><a href=\"', '"')): links.append(link.strip()) if currentEpisode >= [info[0], info[1]]: break else: if quality.__contains__("|"): prefer = quality.split("|") if len(newEpisodes) > 0: for newEpisode in newEpisodes: if newEpisode.__contains__( info) or newEpisode.__contains__( [info[0], info[1], prefer[0]]): print "Episode already in download queue or preferred quality already found for " + str( name) + "!" break elif info == [info[0], info[1], prefer[0] ] and newEpisode.__contains__( [info[0], info[1], prefer[1]]): print "Preferred Quality found, removing other qualities for " + str( name) + "!" newEpisodes.append([info, links]) newEpisodes.remove(newEpisode) else: print "Newer Episode found for " + str( name) + "!" newEpisodes.append([info, links]) else: util.sendNotification( "Found new Episode for " + str(name) + "!", 3000) print "Found new Episode for " + str(name) + "!" newEpisodes.append([info, links]) else: if info[2] == quality or quality == "first": newEpisodes.append([info, links]) break if len(newEpisodes) > 0: for newEpisode in newEpisodes: try: valid = False for link in newEpisode[1]: url = urllib.urlopen(link) if url.getcode() == 200: util.download(link) print "Downloading " + str(link) valid = True break if valid == False: print "No working link for " + str( name) + " Season: " + str( info[0]) + " Episode: " + str(info[1]) except: print "Unable to download: " + str(link) else: util.sendNotification("No new episodes for " + str(name), 3000) print "No new episodes for " + str(name)
import util import body_iq_tests import devicename_iq_tests import notif_iq_tests import userevents_iq_tests import datetime_iq_tests import factoryreset_iq_tests import fota_iq_tests import systemevents_iq_tests if __name__ == "__main__": import sys #special case for fota which need two parameters device_0 = util.connection([], "fota") device_1 = fota_iq_tests.fota_iq_automatic_test(device_0, sys.argv[2]) device_1.disconnect() # Remove arg 2 from parameter and connect again for other test sys.argv.pop() device_2 = util.connection([ "\x49\x42\x41\x00", "\x49\x43\x44\x44\x00", "\x49\x43\x44\x46\x00", "\x49\x43\x44\x4E\x00", "\x49\x43\x4E\x00" ]) systemevents_iq_tests.system_event_iq_automatic_test(device_2) devicename_iq_tests.devicename_iq_automatic_test(device_2) notif_iq_tests.notif_iq_automatic_test(device_2) userevents_iq_tests.userevents_iq_automatic_test(device_2) datetime_iq_tests.datetime_iq_automatic_test(device_2)
print("- Triple Tap, expected type: 1") pub = device.itm_poll(expect="publish", timeout=30) if pub == None: print("No publish received") else: print("Publish on topic " + binascii.hexlify(pub['topic'])) userevent = UserEvent() userevent.ParseFromString(pub['data']) if userevent.HasField('button_event'): print("Button Event Type: " + str(userevent.button_event.type)) elif userevent.HasField('tapping_event'): print("Tapping Event Type: " + str(userevent.tapping_event.type)) else: print("No Button or Tapping event") def userevents_iq_test_run_all_tests(device): print("---------------------------") print("- USER EVENT IQ TEST -") print("---------------------------") device.itm_subscribe_req("\x49\x43\x45\x55\x00\x00") userevents_iq_test(device) if __name__ == "__main__": device = util.connection(None) userevents_iq_test_run_all_tests(device) device.disconnect()
def body_iq_test_date_change_during_activity(device): print("------------------------------------------") print("- DATE CHANGE DURING ACTIVITY TEST -") print("------------------------------------------") print("") print("Start an activity") print("") pub = device.itm_poll(expect="publish", timeout=30) assert pub != None DecodedActivity = Activity() DecodedActivity.ParseFromString(pub['data']) step_count = 0 if DecodedActivity.HasField('walking_activity'): step_count = DecodedActivity.walking_activity.step_count elif DecodedActivity.HasField('running_activity'): step_count = DecodedActivity.running_activity.step_count print("Activity " + activity[DecodedActivity.type] + "\n" + " begin " + str(DecodedActivity.timestamp_begin) + " end " + str(DecodedActivity.timestamp_end) + " step count " + str(step_count) + "\n" + " status " + status[DecodedActivity.activity_status]) # Verify that the activity started report has been received assert status[DecodedActivity.activity_status] == 'STARTED' # Instantiate a datetime publish date = DateTime() date.datetime = 1000 # Publish to intel/core/ # Publish Date print("Set new date: 1000") device.itm_publish("\x49\x43\x44\x44\x00", date.SerializeToString()) time.sleep(10) # Send request (NULL data) pub = device.itm_topic_req("\x49\x42\x41\x00", "\x00") assert pub != None print("Report request sended") print("topic_rsp: req_id %d status %d data %s" %(pub['req_id'], pub['status'], binascii.hexlify(pub['data']))) DecodedActivity = Activity() DecodedActivity.ParseFromString(pub['data']) step_count = 0 if DecodedActivity.HasField('walking_activity'): step_count = DecodedActivity.walking_activity.step_count elif DecodedActivity.HasField('running_activity'): step_count = DecodedActivity.running_activity.step_count print("Activity " + activity[DecodedActivity.type] + "\n" + " begin " + str(DecodedActivity.timestamp_begin) + " end " + str(DecodedActivity.timestamp_end) + " step count " + str(step_count) + "\n" + " status " + status[DecodedActivity.activity_status]) # Verify that the activity is an ongoing one assert status[DecodedActivity.activity_status] == 'ONGOING' # Verify that the dates are consistent assert str(DecodedActivity.timestamp_end) > str(DecodedActivity.timestamp_begin) print("") print("Stop your activity") print("") time.sleep(15) pub = device.itm_poll(expect="publish", timeout=30) assert pub != None DecodedActivity = Activity() DecodedActivity.ParseFromString(pub['data']) step_count = 0 if DecodedActivity.HasField('walking_activity'): step_count = DecodedActivity.walking_activity.step_count elif DecodedActivity.HasField('running_activity'): step_count = DecodedActivity.running_activity.step_count print("Activity " + activity[DecodedActivity.type] + "\n" + " begin " + str(DecodedActivity.timestamp_begin) + " end " + str(DecodedActivity.timestamp_end) + " step count " + str(step_count) + "\n" + " status " + status[DecodedActivity.activity_status]) # Verify that the activity started report has been received assert status[DecodedActivity.activity_status] == 'FINISHED' # Verify that the dates are consistent assert str(DecodedActivity.timestamp_end) > str(DecodedActivity.timestamp_begin) device.disconnect() print("") print("Start an activity") print("") time.sleep(10) device = util.connection(["\x49\x42\x41\x00"]) # Instantiate a datetime publish date2 = DateTime() date2.datetime = 500 # Publish to intel/core/ # Publish Date print("Set new date: 500") device.itm_publish("\x49\x43\x44\x44\x00", date2.SerializeToString()) time.sleep(10) print("Stop your activity") print("") time.sleep(25) rl = device.itm_subscribe_req("\x49\x42\x41\x00\x00") pub = device.itm_poll(expect="publish", timeout=30) assert pub != None DecodedActivity = Activity() DecodedActivity.ParseFromString(pub['data']) step_count = 0 if DecodedActivity.HasField('walking_activity'): step_count = DecodedActivity.walking_activity.step_count elif DecodedActivity.HasField('running_activity'): step_count = DecodedActivity.running_activity.step_count print("Activity " + activity[DecodedActivity.type] + "\n" + " begin " + str(DecodedActivity.timestamp_begin) + " end " + str(DecodedActivity.timestamp_end) + " step count " + str(step_count) + "\n" + " status " + status[DecodedActivity.activity_status]) # Verify that an activity finished report has been received assert status[DecodedActivity.activity_status] == 'FINISHED' # Verify that the dates are consistent assert str(DecodedActivity.timestamp_end) > str(DecodedActivity.timestamp_begin) print("") print("TESTS PASSED") return device
def searchEpisodes(): quality = util.getQuality() conn = util.connection() cursor = conn.cursor() cursor.execute('select * from shows') shows = cursor.fetchall() cursor.close() conn.close() for show in shows: name = show[0] currentEpisode = [int(show[2]), int(show[3])] newEpisodes = [] processedEpisodes = [] params = {"SearchString": show[1]} query = urllib.urlencode(params) url = str(web) + "/search/" tvShow = urllib.urlopen(url, query) episodes = tvShow.read() tvShow.close() episodes = util.extractAll(episodes, '<tr name="hover" class="forum_header_border">', '</tr>') for episode in episodes: info = util.extractAll(episode, '<td class="forum_thread_post">', '</td>') info = info[0].strip() info = util.extractAll(info, 'class="epinfo">', '</a>') if (re.search('720p', info[0], re.I)): info = re.findall(r'(\d{1,2})(?:e|x|episode)(\d{1,2})', info[0], re.I) info = [int(info[0][0]), int(info[0][1]), "720p"] else: info = re.findall(r'(\d{1,2})(?:e|x|episode)(\d{1,2})', info[0], re.I) info = [int(info[0][0]), int(info[0][1]), "hdtv"] urls = util.extractAll(episode, '<td align="center" class="forum_thread_post">', '</td>') linkNumber = re.findall('class="download_', urls[0], re.IGNORECASE) linkNumber = len(linkNumber) links = [] for link in (util.extractAll(urls[0], '</a><a href=\"', '"')): links.append(link.strip()) if currentEpisode >= [info[0], info[1]]: break else: if quality.__contains__("|"): prefer = quality.split("|") if len(newEpisodes) > 0: for newEpisode in newEpisodes: if newEpisode.__contains__(info) or newEpisode.__contains__([info[0], info[1], prefer[0]]): print "Episode already in download queue or preferred quality already found for " + str(name) + "!" break elif info == [info[0], info[1], prefer[0]] and newEpisode.__contains__([info[0], info[1], prefer[1]]): print "Preferred Quality found, removing other qualities for " + str(name) + "!" newEpisodes.append([info, links]) newEpisodes.remove(newEpisode) else: print "Newer Episode found for " + str(name) + "!" newEpisodes.append([info, links]) else: util.sendNotification("Found new Episode for " + str(name) + "!", 3000) print "Found new Episode for " + str(name) + "!" newEpisodes.append([info, links]) else: if info[2] == quality or quality == "first": newEpisodes.append([info, links]) break if len(newEpisodes) > 0: for newEpisode in newEpisodes: try: valid = False for link in newEpisode[1]: url = urllib.urlopen(link) if url.getcode() == 200: util.download(link) print "Downloading " + str(link) valid = True break if valid == False: print "No working link for " + str(name) + " Season: " + str(info[0]) + " Episode: " + str(info[1]) except: print "Unable to download: " + str(link) else: util.sendNotification("No new episodes for " + str(name), 3000) print "No new episodes for " + str(name)
def body_iq_test_activity_classification(device): device.disconnect() print("---------------------------------------") print("- ACTIVITY CLASSIFICATION TEST -") print("---------------------------------------") device = util.connection(["\x49\x42\x41\x00","\x49\x42\x41\x53\x00"]) rl = device.itm_subscribe_req("\x49\x42\x41\x00\x00") activitySettings = ActivitySettings(); # Disable activity classification activitySettings.activity_classification_enable_disable = False device.itm_topic_req("\x49\x42\x41\x53\x00", activitySettings.SerializeToString()) print("") print("Start an activity") print("") pub = device.itm_poll(expect="publish", timeout=30) assert pub == None print("") print("Stop your activity") print("") pub = device.itm_poll(expect="publish", timeout=30) assert pub == None print("") print("Do activity(ies) during periodic reports time (set by default at 5 minutes)") print("") pub = device.itm_poll(expect="publish", timeout=350) assert pub == None # Enable activity classification activitySettings.activity_classification_enable_disable = True device.itm_topic_req("\x49\x42\x41\x53\x00", activitySettings.SerializeToString()) print("") print("Start an activity") print("") pub = device.itm_poll(expect="publish", timeout=30) assert pub != None DecodedActivity = Activity() DecodedActivity.ParseFromString(pub['data']) step_count = 0 if DecodedActivity.HasField('walking_activity'): step_count = DecodedActivity.walking_activity.step_count elif DecodedActivity.HasField('running_activity'): step_count = DecodedActivity.running_activity.step_count print("Activity " + activity[DecodedActivity.type] + "\n" + " begin " + str(DecodedActivity.timestamp_begin) + " end " + str(DecodedActivity.timestamp_end) + " step count " + str(step_count) + "\n" + " status " + status[DecodedActivity.activity_status]) # Verify that the activity started report has been received assert status[DecodedActivity.activity_status] == 'STARTED' print("") print("Stop your activity") print("") time.sleep(10) print("") print("TESTS PASSED") return device
def first_req_cancel(device, firmware_path): #get firmware id quark_id = device.disfwrev.read() print "QUARK ID : %s"%quark_id # Set binary file, the binary test file shall contain only at least QUARK firmware firmware_path = sys.argv[2] try: print "Firmware file: " + firmware_path stat = os.stat(firmware_path) file_len = stat.st_size except: print '\nERROR: file - ' + firmware_path + '- not found' exit() try: # Search the pattern ATP1LAK000 in the binary file fd = open(firmware_path, "rb") s = fd.read(file_len) fd.close() firmware_id_to_flash = re.search('ATP1LAK000-[0-9A-Fa-f]{9}', s).group() except: print '\nERROR: binary test file: ' + firmware_path + ' does not contain QUARK firmware' exit() #Perform a state request before starting print ("----------------------------") print ("------ CHECK DEVICE ------") print ("-----------------------------") # Publish to intel/core/FirmwareUpdate/State and Wait response pub = device.itm_topic_req("\x49\x43\x46\x53\x00", "\x00") if pub == None: print("No topic_rsp received") else: print("topic_rsp: req_id %s status %s"%(str(pub['req_id']), str(pub['status']))) decodedResp = FirmwareUpdateState() decodedResp.ParseFromString(pub['data']) print("response value = " + str(decodedResp.firmware_update_state)) assert pub['status'] == 0 if decodedResp.firmware_update_state != FirmwareUpdateState.NONE: #Perform a cancel request print ("--------------------------------------------------") print ("------ DEVICE NOT READY => CANCEL REQUEST ------") print ("--------------------------------------------------") # Prepare a Firmware Update CANCEL request notif.firmware_update_cmd = FirmwareUpdate.CANCEL # Publish to intel/core/Firmware and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") else: print("topic_rsp: status %s"%(str(pub['status']))) assert pub['status'] == 0 else: print ("---------------------------------------------") print ("------ DEVICE READY => START REQUEST ------") print ("---------------------------------------------") # Instantiate a Firmware Update request notif = FirmwareUpdate() notif.firmware_total_length = file_len # BLE max message size is 132 bytes, the BLE message contain header + topic + req_id + protobuf serialization # protobuf serialization contain : command (start, cancel continue) + firmware size + data + size # After some test max data size allowed is 114 data_max_size = 114 notif.offset = 0 #Perform a cancel request as a 1st req print ("------------------------------------") print ("------ 1st RESQUEST: CANCEL ------") print ("------------------------------------") # Prepare a CANCEL request notif.firmware_update_cmd = FirmwareUpdate.CANCEL # Publish to intel/core/Firmware and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") else: print("topic_rsp: status %s"%(str(pub['status']))) assert pub['status'] == 3 print ("-----------------------------------") print ("------ CHECK DEVICE: ------") print ("------ NONE STATE EXPECTED ------") print ("-----------------------------------") # Publish to intel/core/FirmwareUpdate/State and Wait response pub = device.itm_topic_req("\x49\x43\x46\x53\x00", "\x00") if pub == None: print("No topic_rsp received") else: print("topic_rsp: req_id %s status %s"%(str(pub['req_id']), str(pub['status']))) decodedResp = FirmwareUpdateState() decodedResp.ParseFromString(pub['data']) print("Response value = %d (expected: %d)"%(decodedResp.firmware_update_state, FirmwareUpdateState.NONE)) assert pub['status'] == 0 assert decodedResp.firmware_update_state == FirmwareUpdateState.NONE print ("-----------------------------") print ("------ START REQUEST ------") print ("-----------------------------") notif.firmware_update_cmd = FirmwareUpdate.START print "Firmware size: %d"%file_len # Publish to intel/core/FirmwareUpdate and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") else: print("topic_rsp: status %s"%(str(pub['status']))) assert pub['status'] == 0 #Wait recovery reboot print 'Waiting RECOVERY reboot.....' time.sleep(20) # connect to device device = util.connection([], "fota") print ("-------------------------------------") print ("------ STATE REQUEST: ------") print ("------ STARTED RESP EXPECTED ------") print ("-------------------------------------") # Publish to intel/core/FirmwareUpdate/State and Wait response pub = device.itm_topic_req("\x49\x43\x46\x53\x00", "\x00") if pub == None: print("No topic_rsp received") else: print("topic_rsp: req_id %s status %s"%(str(pub['req_id']), str(pub['status']))) decodedResp = FirmwareUpdateState() decodedResp.ParseFromString(pub['data']) print("Response value = %d (expected: %d)"%(decodedResp.firmware_update_state, FirmwareUpdateState.STARTED)) assert pub['status'] == 0 assert decodedResp.firmware_update_state == FirmwareUpdateState.STARTED print ("-------------------------------------") print ("------ CONTINUE REQUEST ------") print ("-------------------------------------") # Prepare a Firmware Update CONTINUE request notif.firmware_update_cmd = FirmwareUpdate.CONTINUE fd = open(firmware_path, "rb") time_before = time.time() i = 0 while 1: i = i + 1 if i%50 == 0: print str(i) + ' requests executed' notif.data = fd.read(data_max_size) # Publish to intel/core/Firmware and Wait response pub = device.itm_topic_req("\x49\x43\x46\x00", notif.SerializeToString()) if pub == None: print("No topic_rsp received") print("topic_rsp: status %d"%(pub['status'])) else: assert pub['status'] == 0 notif.offset += len(notif.data) if len(notif.data) < data_max_size: break fd.close() print "Time to perform " + str(i) + " transfers and flash " + str(file_len) + " bytes : " + str(time.time() - time_before).split('.')[0] + "s" #Wait ota reboot print "Waiting OTA reboot....(110 s)" time.sleep(110) # connect to device device = util.connection([], "fota") quark_id_new = device.disfwrev.read() print "New quark id: " + quark_id_new + " --- Old quark id: " + quark_id if quark_id_new == quark_id: print "Same firmware id --- binary file was ignored by bootloader" else: print "Firmware id different --- binary file was accepted by bootloader" return device
print("Timestamp: " + str(sysevent.timestamp.datetime)) assert sysevent.shutdown_event.shutdown_type == 0 else: print("No Shutdown event") def system_event_iq_automatic_test(device): print("----------------------------------------") print("- SYSTEM EVENT IQ AUTOMATIC TEST -") print("----------------------------------------") print("") print("SYSTEM EVENT IQ CAN'T BE AUTOMATICALLY TESTED") print("") print("TEST PASSED") def system_event_iq_run_all_test(device): print("------------------------------") print("- SYSTEM EVENT IQ TEST -") print("------------------------------") print("") system_event_iq_test(device) if __name__ == "__main__": device = util.connection(["\x49\x43\x45\x53\x00\x00"]) system_event_iq_test(device) device.disconnect()
assert sysevent.shutdown_event.shutdown_type == 0 else: print("No Shutdown event") def system_event_iq_automatic_test(device): print("----------------------------------------") print("- SYSTEM EVENT IQ AUTOMATIC TEST -") print("----------------------------------------") print("") print("SYSTEM EVENT IQ CAN'T BE AUTOMATICALLY TESTED") print("") print("TEST PASSED") def system_event_iq_run_all_test(device): print("------------------------------") print("- SYSTEM EVENT IQ TEST -") print("------------------------------") print("") system_event_iq_test(device) if __name__ == "__main__": device = util.connection(["\x49\x43\x45\x53\x00\x00"]) system_event_iq_test(device) device.disconnect()