def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output)
def error_stuff(): #print "LOOP" e.print_all i = 0 for error in e.errors: edrive = error["Drive"] print error if (error["Problem"] == "Unknown_drive"): print "\n New Drive detected: %s " % edrive vart = raw_input("Add drive to databse?") if (vart == "y"): state.add_drive_to_state(error["Drive"], state.old_state) state.current_state = state.current_state e.resolve(i) if (error["Problem"] == "No_state"): print "Open state.py, and set a new s_path" ans = raw_input("Would you like to set a new s_path now?") if (ans == "y"): state.s_path = raw_input("Where?") if (ans == "n"): pass q = (raw_input("You can save to the current s_path. y/n")) if (q == "y"): confirm = raw_input("Are you sure, this will overwrite the old state?") if (confirm == "y"): print "ok" current_state = state.make_state() state.save_entire_state(current_state) if (confirm == "n"): print "ok" if (error["Problem"] =="size_mismatch"): cdrive = error ans = raw_input("Use current drive data?") if (ans == "y"): print "Adding drive %s to state" % cdrive state.add_drive_to_state(cdrive, state.old_state) #state.print_pretty(state.current_state) state.save_entire_state(state.current_state) state.open_state() print "state.errors" print state.errors del state.errors[cdrive] main_ui()