from PasswordTester import PasswordTester from Generator import Generator def passwordStartsWithZero(password): print password[0] if int(password[0]) == 0: return True return False tester = PasswordTester() student_number = 0 # student number goes here, e.g 209002958 l = Generator.generate(1234567890, 5) l = reversed(l) for password in l: print password if passwordStartsWithZero(password): continue tried = tester.checkIfPasswordTried(int(password), None) if tried: print "Password " + str(password) + " Already tried" else: found = tester.testPassword(student_number, password) if found: if tester.confirmPasswordWorked(student_number, password): tester.saveWorkedPassword(student_number, password) raw_input("Password Found as " + str(password) + " Enter anything exit") raw_input("Enter anything to exit")
input_file = args['<file>'] output_file = args['--output'] ast = None try: with open(input_file, 'r') as f: Parser.build("Program") source = f.read() ast = Parser.parse(source) except IOError: print('Error opening file %s. Please check the file or ' 'the directory.' % input_file) sys.exit(1) if ast is None: error_list = list(Parser.error_list.keys()) error_list.sort() for key in error_list: sys.stdout.write(Parser.error_list[key]) sys.stdout.flush() sys.exit(-1) ast = Optimizer.optimize(ast) try: with open(output_file, 'w') as f: f.write(Generator.generate(ast)) except IOError: print('Error writing to file %s. Please check the file or ' 'the directory.' % output_file) sys.exit(1)
output_file = args['--output'] ast = None try: with open(input_file, 'r') as f: Parser.build("Program") source = f.read() ast = Parser.parse(source) except IOError: print 'Error opening file %s. Please check the file or ' \ 'the directory.' % input_file sys.exit(1) if ast is None: error_list = list(Parser.error_list.keys()) error_list.sort() for key in error_list: sys.stdout.write(Parser.error_list[key]) sys.stdout.flush() sys.exit(-1) if args['-O']: ast = Optimizer.optimize(ast) try: with open(output_file, 'w') as f: f.write(Generator.generate(ast)) except IOError: print 'Error writing to file %s. Please check the file or ' \ 'the directory.' % output_file sys.exit(1)