def reboot(self, irc): display.myprint("Rebooting...", 1, irc) while True: self.rebootcombo(config.REBOOT_COMBO_WAIT) if self.is_mounted(): display.myprint("Having trouble resetting the iPod!", 0, irc) else: break
def try_address(nanotron, address, irc = None): global FREEZEPAYLOAD, CRASHPAYLOAD display.myprint ("Testing %8x..." % address, 0, irc) status1 = try_file(nanotron, FREEZEPAYLOAD, address, irc) if status1 == 0: display.print_status(address, irc, status1) return status2 = try_file(nanotron, CRASHPAYLOAD, address, irc) display.print_status(address, irc, status1, status2)
def try_file(nanotron, payload, address, irc = None): if not nanotron.is_mounted(): nanotron.disk_mode(irc) try: writeNote(payload, address, nanotron.IPODPATH) except IOError: display.myprint("FIXME: read-only mount, rebooting", 0, irc) nanotron.disk_mode(irc) time.sleep(config.NOTE_WAIT) nanotron.reboot(irc) time.sleep(config.BOOT_WAIT) nanotron.diskmodecombo(config.DISKMODE_COMBO_WAIT) return nanotron.get_status()
def __init__(self): #self.myprint = myprint try: self.sock = nxt.locator.find_one_brick() except nxt.locator.BrickNotFoundError: display.myprint("FATAL: No NXT was found") quit() self.brick = self.sock.connect() self.play_motor = Motor(self.brick, self.play_port) self.select_motor = Motor(self.brick, self.select_port) self.menu_motor = Motor(self.brick, self.menu_port) self.touch_sensor = TouchSensor(self.brick, self.touch_port) self.light_sensor = LightSensor(self.brick, self.light_port)
def diskmodecombo(self, seconds): display.myprint("Disk mode combo down", 2) self.press_select() self.press_play() display.myprint("waiting %u seconds for disk mode" % seconds, 2) time.sleep(seconds) self.reset() display.myprint("Disk mode combo up", 2)
def rebootcombo(self, seconds): display.myprint("Reboot combo down", 2) self.press_select() self.press_menu() #display.myprint("unmounting before reboot", 1) #if self.is_mounted(): os.system('umount /media/ipod') display.myprint("waiting %u seconds for reboot" % seconds, 2) time.sleep(seconds) self.reset() display.myprint("Reboot combo up", 2)
def get_status(self): if self.is_mounted(): display.myprint("WORKS", 1) return 1 #Works else: time.sleep(config.DISKMODE_WAIT) if self.is_mounted(): display.myprint("CRASH", 1) return 0 #Crash else: display.myprint("FREEZE", 1) return 2 #Freeze '''start = time.time() #FIXME: might be incompatible on windows
def disk_mode(self, irc): display.myprint("Trying to enter Disk mode...", 1, irc) while True: self.reboot(irc) time.sleep(.25) self.diskmodecombo(config.DISKMODE_COMBO_WAIT) time.sleep(config.DISKMODE_WAIT) if not self.is_mounted(): display.myprint("Having trouble putting the iPod into disk mode!", 0, irc) else: break '''start = time.time() #FIXME: might be incompatible on windows while not self.is_mounted(): if time.time() - start > config.DISKMODE_WAIT: display.myprint("Having trouble putting the iPod into disk mode!", 0, irc) break if self.is_mounted(): break''' display.myprint("entered disk mode...", 1, irc)