Beispiel #1
0
 def create_board(self):
     """
     Creates a list of rows containing lists of objects in columns of these rows.
     """
     board = []
     for row in range(0, self.rows):
         n_row = []
         for col in range(0, self.cols):
             if (row, col) in self.RED_BASE:
                 checker = Checker(row, col, RED, self.RED_BASE.copy(),
                                   self.BLUE_BASE.copy(), self.SQUARE_SIZE)
                 self.player1.add_checker(checker)
                 n_row.append(checker)
             elif (row, col) in self.BLUE_BASE:
                 checker = Checker(row, col, BLUE, self.BLUE_BASE.copy(),
                                   self.RED_BASE.copy(), self.SQUARE_SIZE)
                 self.player2.add_checker(checker)
                 n_row.append(checker)
             elif (row, col) in self.GREEN_BASE and self.player3:
                 checker = Checker(row, col, GREEN, self.GREEN_BASE.copy(),
                                   self.YELLOW_BASE.copy(),
                                   self.SQUARE_SIZE)
                 self.player3.add_checker(checker)
                 n_row.append(checker)
             elif (row, col) in self.YELLOW_BASE and self.player4:
                 checker = Checker(row, col, YELLOW,
                                   self.YELLOW_BASE.copy(),
                                   self.GREEN_BASE.copy(), self.SQUARE_SIZE)
                 self.player4.add_checker(checker)
                 n_row.append(checker)
             else:
                 n_row.append(0)
         board.append(n_row)
     self.board = board
Beispiel #2
0
def main():
    checker = Checker()
    checker.addTest(checkingScript, [add, add, ""], "abcabc", "+= 'abc', += 'abc'")
    checker.addTest(checkingScript, [add, reverse, "xyz"], "zyxabc", "+= 'abc', reverse(x)")
    checker.addTest(checkingScript, [reverse, add, "xyz"], "cbazyx", "reverse(x), += 'abc'")
    checker.addTest(checkingScript, [reverse, reverse, "xyz"], "xyz", "reverse(x), reverse(x)")
    checker.doTesting(solution.collapse)
Beispiel #3
0
def checkSpam():
    try:
        checker = Checker()
        result = checker.run()
        print(result)
    except Exception:
        pass
Beispiel #4
0
 def set_checkers(self):
     """Creates all checkers and places them in their initial positions"""
     for index, (y, x) in enumerate(CHECKER_POSITIONS):
         point_low = arcade.get_sprites_at_point((x, y), self.point_list)[0]
         point_low.checker_color = CHECKER_COLORS[index]
         point_top = arcade.get_sprites_at_point((x, SCREEN_HEIGHT - y),
                                                 self.point_list)[0]
         point_top.checker_color = 1 - CHECKER_COLORS[index]
         for checker_count in range(CHECKER_PILES[index]):
             checker = Checker(CHECKER_COLORS[index], 1)
             checker.position = x, y + checker_count * CHECKER_PILE_OFFSET[
                 CHECKER_PILES[index]]
             checker.point = point_low
             if CHECKER_PILES[index] == checker_count + 1:
                 checker.is_selectable = True
             point_low.checker_pile.append(checker)
             self.checker_list.append(checker)
             checker = Checker(1 - CHECKER_COLORS[index], 1)
             checker.position = x, SCREEN_HEIGHT - y - checker_count * CHECKER_PILE_OFFSET[
                 CHECKER_PILES[index]]
             checker.point = point_top
             if CHECKER_PILES[index] == checker_count + 1:
                 checker.is_selectable = True
             point_top.checker_pile.append(checker)
             self.checker_list.append(checker)
def main(argc, argv):
    if argc != 2:
        print 'Usage: nqueens <n>'
        return 1

    n = int(argv[1], 10)
    t1 = time()
    try:
        q = nqueens_constraint_programming_opti(n)
        #q = nqueens(n)
    except:
        print('Threw after %f seconds' % (time() - t1))
        raise

    t2 = time()

    matrix = [[0] * n for i in xrange(n)]

    for x, y in q:
        matrix[x][y] = 1

    checker = Checker(matrix=matrix)
    if checker.test_all(False) == False:
        checker.print_error_matrix()
    else:
        display_solutions(q)
        print('# calculated in %f seconds' % (t2 - t1))
        print("print '%s'" % n)
        print("print '%s'" % ' '.join(str(column + 1) for row, column in q))

    return 0
def main(argc, argv):
    if argc != 2:
        print 'Usage: nqueens <n>'
        return 1

    n = int(argv[1], 10)

    t1 = time()
    try:
        q = propositional_nqueens(n)
    except:
        print('Threw after %f seconds' % (time()-t1))
        raise

    t2 = time()

    matrix = [[0] * n for i in xrange(n)]

    for x,y in q:
        matrix[x][y] = 1

    checker = Checker(matrix=matrix)
    if checker.test_all(False) == False:
        checker.print_error_matrix()
    else:
        display_solutions(q)
        print('# calculated in %f seconds' % (t2 - t1))
        print("print '%s'" % n)
        print("print '%s'" % ' '.join(str(column + 1) for row, column in q))

    return 0
Beispiel #7
0
def main(args):
    with codecs.open(args.props, 'r', encoding='utf-8') as f:
        meta = json.loads(f.read())

    logging.info('Creating dataset instance')
    ds = Dataset(meta['database'])

    logging.info('Creating scrapper instance')
    spr1 = SiteScrapper(meta['scrapper'], phantomjs='phantomjs1')
    spr2 = SiteScrapper(meta['scrapper'], phantomjs='phantomjs2')

    logging.info('Creating manager instance')
    mgr1 = Manager(ds, spr1, meta['conf'])
    mgr2 = Manager(ds, spr2, meta['conf'])

    threads = []
    crawler = Crawler(mgr1)
    crawler.daemon = True
    crawler.start()
    threads.append(crawler)

    checker = Checker(mgr2)
    checker.daemon = True
    checker.start()
    threads.append(checker)

    # for th in threads:
    #     th.join()
    while True:
        pass
Beispiel #8
0
def test_checker_move():
    checker = Checker(4, 11, BLUE, BLUE_BASE, RED_BASE, 50)
    assert checker.x == 575
    assert checker.y == 225
    checker.move(5, 1)
    assert checker.x == 75
    assert checker.y == 275
Beispiel #9
0
 def __init__(self,parent=None,*arg,**kwargs):
     super().__init__(parent,*arg,**kwargs)
     # self.setAttribute( Qt.WA_SetWindowIcon )
     self.setAttribute(Qt.WA_StyleSheet)
     self.setupUi(self)
     self.chk =Checker()
     self.setup()
     self.input_ln.setFocus()
def main():
  ch = Checker()

  while True:
    n = ch.readInt()
    if n == 0:
      break
    ch.checkRange(n, N_MIN, N_MAX, 'N')
Beispiel #11
0
def test_make_player_with_checkers():
    checker1 = Checker(4, 11, BLUE, BLUE_BASE, RED_BASE, 50)
    checker2 = Checker(15, 15, BLUE, BLUE_BASE, RED_BASE, 50)
    checkers = [checker1, checker2]
    player = Player('Zygfryd', GREEN, checkers)
    assert player.name == 'Zygfryd'
    assert player.colour == GREEN
    assert len(player.checkers) == 2
Beispiel #12
0
    def check(self):
        log_file = ['/var/log/syslog']

        # start check log sensitive data
        check = Checker(log_file, 'LOG')
        check.start()
        data.log_file_results = check.results
        Utils.printy_result('Log Check.', 1)
def main():
    ch = Checker()

    while True:
        n = ch.readInt()
        if n == 0:
            break
        ch.checkRange(n, N_MIN, N_MAX, 'N')
Beispiel #14
0
class TestParsingChecker(unittest.TestCase):
    def setUp(self):
        self.parsed = ModelFactory.get_parsed()
        self.ltl = ["U[1, {}]".format(DURATION), "T", "failure"]
        self.checker = Checker(self.parsed, ltl=self.ltl, duration=DURATION)

    def test_check(self):
        self.checker.run_checker()
Beispiel #15
0
class MainWindow(QtWidgets.QWidget):
	def __init__(self, parent=None):
		super(MainWindow, self).__init__()
		self.ui = mainWnd.Ui_MainForm()
		self.ui.setupUi(self)

		width = self.frameGeometry().width()
		height = self.frameGeometry().height()

		wid = QtWidgets.QDesktopWidget()
		screenWidth = wid.screen().width()
		screenHeight = wid.screen().height()
		self.setGeometry((screenWidth/2)-(width/2),(screenHeight/2)-(height/2),width,height)

		self.checker = Checker()
		self.checker.set_main_wnd(self)		
		
		self.ui.pbCheck.clicked.connect(self.on_check_clicked)

	def set_start_wnd(self, wnd):
		self.startWnd = wnd
		self.checker.set_start_wnd(wnd)

	def closeEvent(self, e):
		result = QtWidgets.QMessageBox.question(self, 'Закрытие', 'Вы действительно хотите завершить тест?', QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No)
		if result == QtWidgets.QMessageBox.Yes:
			self.hide()
			self.startWnd.show()
		else:
			e.ignore()

	def start_test(self):
		self.checker.gen_new_digit()
		self.checker.isFirst = False

	def on_check_clicked(self):
		digit = 0

		if self.ui.pbCheck.text() == "Ответить":
			try:
				count = int( self.ui.edCount.text() )
			except:
				QtWidgets.QMessageBox.warning(self, 'Error', 'Неверные символы в поле повторений! Необходимо число!', QtWidgets.QMessageBox.Yes)
				self.ui.edDiff.setText("0")
				return

			self.checker.add_digit( count )
			self.ui.pbCheck.setText("Далее")
			self.ui.pbCheck.setIcon(QtGui.QIcon("images/next_8028.ico"))			
			return
		else:
			if not self.checker.isError:
				self.checker.gen_new_digit()
			else:
				self.ui.lbRes.setText("")
				self.checker.isError = False
			self.ui.pbCheck.setIcon(QtGui.QIcon("images/apply_5183.ico"))
			self.ui.pbCheck.setText("Ответить")
Beispiel #16
0
def main():
    ch = Checker()

    while True:
        a, b = ch.readInts(2)
        if a == 0 and b == 0:
            break
        ch.checkRange(a, MIN, MAX, 'A')
        ch.checkRange(b, MIN, MAX, 'B')
Beispiel #17
0
def fst_check(name):
    with open(path + '/sets/' + name + '.json') as f_obj:
        set = json.load(f_obj)
        for dic in set:
            if dic['f'] == 0:
                comic = Checker(dic['url'], dic['txt'], dic['pos'])
                comic.check()
            else:
                failure_mode(name, dic['name'], dic['txt'])
Beispiel #18
0
def start_loop():
	check_robot = Checker()
	while True:
		line = raw_input("simpleChecker>")
		if line == "quit":
			break
		else:
			for response_text in check_robot.respond_to(line):
				print response_text 
def main():
  ch = Checker()

  while True:
    coefficients = ch.readInts(4)
    if coefficients == [0, 0, 0, 0]:
      break
    for i in xrange(len(coefficients)):
      ch.checkRange(coefficients[i], MIN, MAX, chr(ord('A') + i))
def main():
  ch = Checker()

  while True:
    a, b = ch.readInts(2)
    if a == 0 and b == 0:
      break
    ch.checkRange(a, MIN, MAX, 'A')
    ch.checkRange(b, MIN, MAX, 'B')
Beispiel #21
0
def main():
    ch = Checker()

    while True:
        coefficients = ch.readInts(4)
        if coefficients == [0, 0, 0, 0]:
            break
        for i in xrange(len(coefficients)):
            ch.checkRange(coefficients[i], MIN, MAX, chr(ord('A') + i))
Beispiel #22
0
def test_game_is_not_over():
  board = Board()
  board._slots = [
    ['X', 'X', 'O'], 
    ['O', '5', 'X'], 
    ['X', 'O', ' ']
  ]
  checker = Checker(board)

  assert checker.get_result() == Game_Results.not_over
Beispiel #23
0
def test_get_symbols_indexes():
  board = Board()
  board._slots = [
    ['X', 'X', 'O'], 
    ['O', 'O', 'X'], 
    ['X', 'O', 'X']
  ]
  checker = Checker(board)

  assert checker._get_symbol_indexes('X') == {0, 1, 5, 6, 8}
Beispiel #24
0
def test_game_results_in_tie_on_full_board():
  board = Board()
  board._slots = [
    ['X', 'X', 'O'], 
    ['O', 'O', 'X'], 
    ['X', 'O', 'X']
  ]
  checker = Checker(board)

  assert checker.get_result() == Game_Results.cats_game
Beispiel #25
0
def test_game_results_in_px_win():
  board = Board()
  board._slots = [
    ['O', 'X', 'X'], 
    ['O', 'O', 'X'], 
    ['X', 'X', 'O']
  ]
  checker = Checker(board)

  assert checker.get_result() == Game_Results.player_o
    def get_new_condition(self):
        checker = Checker()
        dead_cells = checker.dead_iteration(self)
        alive_cells = checker.alive_iteration(self)
        for cell_address in dead_cells:
            self.matrix_fill(cell_address, self.DEAD_CELL)
        for cell_address in alive_cells:
            self.matrix_fill(cell_address, self.ALIVE_CELL)

        return self
Beispiel #27
0
def main():
    checker = Checker()
    checker.addTest(checkingScript, [add, add, ""], "abcabc", "+= 'abc', += 'abc'")
    checker.addTest(checkingScript, [add, reverse, "xyz"], "zyxabc", "+= 'abc', reverse(x)")
    checker.addTest(checkingScript, [reverse, add, "xyz"], "cbazyx", "reverse(x), += 'abc'")
    checker.addTest(checkingScript, [reverse, reverse, "xyz"], "xyz", "reverse(x), reverse(x)")
    checker.doTesting(solution.collapse)
Beispiel #28
0
def sql_check():
    files = get_files()
    if not files:
        Utils.printy("No SQL files found ", 2)
        return
    retrieved_files = Utils.get_dataprotection(files)
    data.local_file_protection.extend(retrieved_files)
    check = Checker(files, 'SQL')
    check.start()
    Utils.printy_result('Database Check.', 1)
    return check.results
Beispiel #29
0
def check_connectivity(G):
    checker = Checker(G)
    try:
        G, chains = chain_decomposition(G, checker)
        add_chains(G, chains, checker)
    except ConnEx as e:
        print type(e), e.args
        return False
    checker.verify()

    return True
def check_connectivity(G):
	checker = Checker(G)
	try:
		G, chains = chain_decomposition(G, checker)
		add_chains(G, chains, checker)
	except ConnEx as e:
	 	print type(e), e.args
	 	return False
	checker.verify()

	return True
Beispiel #31
0
 def do_check(self, cookies, site):
     params = {
         'url': site.check_url,
         'method': site.method,
         'headers': site.headers,
         'cookies': cookies.cookies,
         'check_key': site.check_key,
     }
     print('*****', params)
     ckr = Checker()
     return ckr.do_check(**params)
Beispiel #32
0
    def test_constr(self):
        """TODO: patch sys.path to known value"""
        path = copy.deepcopy(sys.path)
        path.append('.')
        path = os.pathsep.join(path)

        checker = Checker(False)
        self.assertEqual({'PYTHONPATH': path}, checker.env)

        checker = Checker(True)
        self.assertEqual({'PYTHONPATH': path, 'DEBUG': 'True'}, checker.env)
def checkproxys():
    from checker import Checker

    proxylist = open(proxyfile)
    proxylist = list(proxylist)
    checker = Checker()
    for item in proxylist:
        if checker.check(item):
            continue
        else:
            output = open(workingfile, 'a')
            output.write(item)
Beispiel #34
0
def main():
  ch = Checker()

  while True:
    l = ch.readInt()
    if l == 0:
      break
    ch.checkRange(l, L_MIN, L_MAX, 'L')

    s = ch.readString()
    ch.checkValidCharacter(s, '+-.')
    ch.checkRange(len(s), l, l, 'length of S')
Beispiel #35
0
    def test_getUrlStatus(self):
        print ">>> test_getUrlStatus"
        app = LinkCrawler()
        checker = Checker(app)
        configIsLoaded = app.loadConfigurationSite("unittest")

        if configIsLoaded is False:
            self.fail("load configuration failed")
        else:
            statusCode = checker.getStatusCode("http://www.google.de")

        print "<<< test_getUrlStatus [statusCode: %s]\n" % statusCode
        self.failUnless(statusCode)
    def test_getUrlStatus(self):
        print ">>> test_getUrlStatus"
        app     = LinkCrawler()
        checker = Checker(app)
        configIsLoaded = app.loadConfigurationSite("unittest")

        if configIsLoaded is False:
            self.fail("load configuration failed")
        else:
            statusCode = checker.getStatusCode("http://www.google.de")

        print "<<< test_getUrlStatus [statusCode: %s]\n" % statusCode
        self.failUnless(statusCode)
Beispiel #37
0
def test():
    model = Model("data.txt", max_size)
    model.load()
    checker = Checker()
    print(">", end='')
    while True:
        text = input()
        print("Input :", text)
        output = model.test(text)
        print("Output:", output)
        fixed = checker.correct(output[0])
        print("Fixed :", fixed)
        print(">", end='')
Beispiel #38
0
def main():
    ch = Checker()

    while True:
        n = ch.readInt()
        if n == 0:
            break
        ch.checkRange(n, MIN, N_MAX, 'N')

        for _ in xrange(n):
            s = ch.readString()
            ch.checkValidCharacter(s, string.ascii_uppercase)
            ch.checkLength(s, n, 'S', 'N')
def handle_column(expected: Column, field_structure, checker: Checker):
    actual_size = None
    if '(' in field_structure[1]:
        actual_size = field_structure[1].split('(')[1].split(')')[0]
        if ',' in actual_size:
            actual_size = set(
                actual_size.replace('\'', '').replace('"', '').split(','))

    if actual_size and expected.size_:
        if not isinstance(expected.size_, set):
            the_same = int(actual_size) == int(expected.size_)
        else:
            the_same = actual_size == expected.size_
        checker.run_check('field-size-mismatch', not the_same)
    unsigned_mismatch = \
        (expected.unsigned and ' unsigned' not in field_structure[1]) or \
        (expected.unsigned is False and ' unsigned' in field_structure[1])
    checker.run_check('field-unsigned-mismatch', unsigned_mismatch)
    actual_type = field_structure[1].split('(')[0].split(' ')[0]
    actual_type = actual_type.replace('double precision',
                                      'float').replace('double', 'float')
    checker.run_check('field-type-mismatch', actual_type != expected.type_)
    nullable_mismatch = \
        (field_structure[2] == 'no' and expected.not_null is not True) or \
        (field_structure[2] == 'yes' and expected.not_null is not False)
    checker.run_check('field-nullable-mismatch', nullable_mismatch)
Beispiel #40
0
    def __init__(self, session_name):
        self.session_name = session_name

        # Create the command checker
        self.checker = Checker()

        # Create the socket server
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        # Get the server address
        self.server_address = self._get_server_address()

        # Run the server
        self.run()
def main():
  ch = Checker()

  while True:
    l = ch.readInt()
    if l == 0:
      break
    ch.checkRange(l, L_MIN, L_MAX, 'L')

    s = ch.readString()
    ch.checkValidCharacter(s, '+-.')
    ch.checkRange(len(s), l, l, 'length of S')
def main():
  ch = Checker()

  while True:
    n = ch.readInt()
    if n == 0:
      break
    ch.checkRange(n, MIN, N_MAX, 'N')
    
    for _ in xrange(n):
      s = ch.readString()
      ch.checkValidCharacter(s, string.ascii_uppercase)
      ch.checkLength(s, n, 'S', 'N')
 def constraintCheck(self, queryGeom, epsg):
     
     # Prompt the user for a reference number
     refDlg = ReferenceNumberDialog()
     result = refDlg.exec_()
     if result == QDialog.Rejected:
         # User pressed cancel
         return
     
     refNumber = refDlg.getRefNumber()
     
     try:
         c = Checker(self.iface, refNumber)
         c.check(queryGeom, epsg)
         c.display()
     except:
         QMessageBox.critical(self.iface.mainWindow(), 'Query Failed', 'The query failed and the detailed error was:\n\n%s' % traceback.format_exc() )
def main():
  ch = Checker()

  while True:
    n = ch.readInt()
    if n == 0:
      break
    ch.checkRange(n, MIN, N_MAX, 'N')
    
    for _ in xrange(n):
      d, l = ch.matchRegex(r'(\w) (\d)')
      l = int(l)
      ch.checkValidCharacter(d, 'LR')
      ch.checkRange(l, MIN, L_MAX, 'L')
def main():
  ch = Checker()

  while True:
    n = int(ch.readLine())
    if n == 0:
      break
    ch.checkRange(n, 3, 50, 'n')
    ps = []
    for _ in range(n):
      x, y = [int(w) for w in ch.readLine().strip().split()]
      ch.check((x, y) not in ps, "no dup points: (%d, %d)" % (x, y))
      ch.checkRange(x, -500, 500, 'x')
      ch.checkRange(y, -500, 500, 'y')
      ps.append((x, y))
Beispiel #46
0
    def _create_checkers(self):
        """Genera todas las fichas de ambos jugadores"""
        # lista de fichas
        self.checkers = []
        # creo la matriz de 8 x 8 inicializado a None
        # TODO: verificar si se puede mejorar esto
        self.positions = []

        table = """
 x x x x
x x x x
 x x x

     -
  -   -
 X - - -
-   - -
"""

        for x in xrange(8):
            self.positions.append([None, None, None, None, None, None, None, None])

        for row, line in enumerate(table.split("\n")):
            row = row - 1

            for col, item in enumerate(line):

                if item in ["-", "x"]:

                    if item == "-":
                        checker = Checker(2, (row, col), self)
                    elif item == "x":
                        checker = Checker(1, (row, col), self)
                    elif item == "X":
                        checker = Checker(1, (row, col), self)

                    self.positions[row][col] = checker
                    self.checkers.append(checker)

                    if item == "X":
                        checker.convert_to_king((row, col))

        self.group.add(self.checkers)
def main():
  ch = Checker()

  while True:
    n = int(ch.readLine())
    if n == 0:
      break
    ch.checkRange(n, 1, 5, 'n')
    ps = set()
    ps.add((0, 0))
    for _ in range(n):
      x, y = [int(w) for w in ch.readLine().strip().split()]
      ch.check((x, y) not in ps, "no dup points")
      ch.checkRange(x, -50, 50, 'x')
      ch.checkRange(y, -50, 50, 'y')
      ps.add((x, y))
def main():
  ch = Checker()

  while True:
    n = int(ch.readLine())
    if n == -1:
      break
    ch.checkRange(n, 0, 23, 'n')
    ps = set()
    ps.add((1, 1))
    ps.add((5, 5))
    for _ in range(n):
      x, y = [int(w) for w in ch.readLine().strip().split()]
      ch.check((x, y) not in ps, 'no dup points')
      ch.checkRange(x, 1, 5, 'x')
      ch.checkRange(y, 1, 5, 'y')
      ps.add((x, y))
def main(argc, argv):
    if not (1 < argc <= 3):
        print 'Usage: nqueens <n>'
        return 1

    n = int(argv[1], 10)

    if (len(argv) == 3):
        print_lines = True
    else:
        print_lines = False
    t1 = time()
    try:
        q = propositional_nqueens(n, print_lines=print_lines, solve_problem = not print_lines)
    except:
        print('Threw after %f seconds' % (time()-t1))
        raise

    t2 = time()

    if print_lines:
            print('; generated in %f seconds' % (t2 - t1))
    else:
        matrix = [[0] * n for i in xrange(n)]

        for x,y in q:
            matrix[x][y] = 1

        checker = Checker(matrix=matrix)
        if checker.test_all(False) == False:
            checker.print_error_matrix()
        else:
            display_solutions(q)
            print('# calculated in %f seconds' % (t2 - t1))
            print("print '%s'" % n)
            print("print '%s'" % ' '.join(str(column + 1) for row, column in q))

    return 0
def main():
  ch = Checker()

  while True:
    n = ch.readInt()
    if n == 0:
      break
    ch.checkRange(n, MIN, N_MAX, 'N')
    
    as_ = ch.readInts(n)
    for a in as_:
      ch.checkRange(a, MIN, A_MAX, 'A')
def main():
  ch = Checker()

  while True:
    n = ch.readInt()
    if n == 0:
      break
    ch.checkRange(n, N_MIN, N_MAX, 'N')
    
    ts_ = ch.readInts(n)
    for t in ts_:
      ch.checkRange(t, T_MIN, T_MAX, 'T')
def main():
  ch = Checker()

  while True:
    a = int(ch.readLine())
    if a == -1:
      break
    ch.checkRange(a, 0, 315, 'd')
    ch.check(a % 45 == 0, 'd is a multiple of 45')
def main():
  ch = Checker()

  while True:
    n, p = ch.readInts(2)
    if n == 0 and p == 0:
      break
    ch.checkRange(n, MIN, N_MAX, 'N')
    ch.checkRange(p, MIN, P_MAX, 'P')
    
    ts = ch.readInts(n)
    for t in ts:
      ch.checkRange(t, MIN, T_MAX, 'T')
Beispiel #54
0
	def __init__(self, parent=None):
		super(MainWindow, self).__init__()
		self.ui = mainWnd.Ui_MainForm()
		self.ui.setupUi(self)

		width = self.frameGeometry().width()
		height = self.frameGeometry().height()

		wid = QtWidgets.QDesktopWidget()
		screenWidth = wid.screen().width()
		screenHeight = wid.screen().height()
		self.setGeometry((screenWidth/2)-(width/2),(screenHeight/2)-(height/2),width,height)

		self.checker = Checker()
		self.checker.set_main_wnd(self)		
		
		self.ui.pbCheck.clicked.connect(self.on_check_clicked)
Beispiel #55
0
def main():
    checker = Checker()
    checker.addTest(checkingScript, 'abc', 'nop', "abc")
    checker.addTest(checkingScript, 'nop', 'abc', "nop")
    checker.addTest(checkingScript, 'xyz', 'klm', "xyz")
    checker.addTest(checkingScript, 'ala ma kota', 'nyn zn xbgn', "ala ma kota")
    checker.addTest(checkingScript, 'a, b, c!', 'n, o, p!', "a, b, c!")
    checker.doTesting(solution.rot13)
Beispiel #56
0
def main():
    checker = Checker()
    checker.addTest(checkingScript, 0, [], "0")
    checker.addTest(checkingScript, 1, [0], "1")
    checker.addTest(checkingScript, 2, [0, 2], "2")
    checker.addTest(checkingScript, 5, [0, 2, 4, 6, 8], "5")
    checker.doTesting(solution.parzyste)
Beispiel #57
0
	def __init__( self ):
		logging.debug( 'Initialize' )
		
		for addr in conf.evil_ip_list:
			checker = Checker( addr )
			checker.start()
Beispiel #58
0
    def start_test(self, test):
        """
            Starts the execution of a given test. It generates the nodes and creates threads that 
            send tasks to the cluster's nodes and wait for the result.
            @type test: Test 
            @param test: a Test object containing the test's parameters (nodes, matrix, 
                        tasks etc)
        """
       
        self.safe_print("**************** Start Test %s *****************"%test.name)

        checker = Checker() 
        checker.add_banned_thread(current_thread())
        
        self.num_correct_results = 0
        
        num_nodes = test.num_nodes
        matrix_size = len(test.matrix1)
        block_size = test.get_stored_block_dim()
        
        nodes = []
        data_stores = [] 
        n = matrix_size / block_size

        for i in range(n):
            for j in range(n):

                # create data store and its blocks
                
                block1 = []
                block2 = []

                for k in range(block_size):
                    block1.append(test.matrix1[i*block_size+k][j*block_size:(j+1)*block_size])
                    block2.append(test.matrix2[i*block_size+k][j*block_size:(j+1)*block_size])

                data_store = DataStore(block1, block2, 5, 0, 0, checker)
                data_stores.append(data_store)
            
                # create nodes
                nodes.append(Node(  (i,j),      # node_ID
                                    block_size, 
                                    matrix_size, 
                                    data_store))

        # the nodes need to know about each other

        for node in nodes:
            node.set_nodes(nodes)

        # send tasks to nodes

        tasks = test.tasks
        threads = []
        for task in tasks:
            if len(task) != 5: 
                break
            index = task[0][0] * n + task[0][1]
            t = Thread(target=Tester.start_node, args=(self, nodes[index], task, test))
            checker.add_banned_thread(t)
            
            t.start()
            threads.append(t)
            
            
        for t in threads:
            t.join()

        for node in nodes:
            node.shutdown()
        
        errors = checker.status()
        for error in errors:
            self.print_error(error)

        if not len(errors) and self.num_correct_results == len(tasks):
            self.passed_tests += 1
            self.safe_print("Correct result")
        
        self.safe_print(("**************** End Test %s *******************\n" % test.name) + ("Remaining threads: %d" % active_count()))
Beispiel #59
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015 Kevin Laeufer <*****@*****.**>
#
# This file is part of Ostfriesentee.
#
# Ostfriesentee is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ostfriesentee is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Ostfriesentee.  If not, see <http://www.gnu.org/licenses/>.

import sys
sys.path.append('scripts')
from checker import Checker

if __name__ == "__main__":
	c = Checker()
	c.run(['architecture', 'infuser', 'lib', 'vm'])
	sys.exit(c.printreport())
Beispiel #60
0
def main():
    checker = Checker()
    checker.addTest(checkingScript, [0, 0], [], "0 x 0")
    checker.addTest(checkingScript, [1, 1], [[1]], "1 x 1")
    checker.addTest(checkingScript, [2, 2], [[1, 2], [2, 4]], "2 x 2")
    checker.addTest(checkingScript, [2, 4], [[1, 2, 3, 4], [2, 4, 6, 8]], "2 x 4")
    checker.addTest(checkingScript, [4, 4], [[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12], [4, 8, 12, 16]], "4 x 4")
    checker.doTesting(solution.mul_table)