コード例 #1
0
def add_student_validation(name, group):
    if name == "":
        raise ex.InputError("Nothing writen")
    if number_int(group) == False:
        raise ex.InputError("The number is not int")
    if group < 911 or group > 917:
        raise ex.Not_in_range("Group is not between 911 and 917")
コード例 #2
0
def update_student_validation(id, name, group, choice2):
    choice2 = int(choice2)
    if choice2 < 1 or choice2 > 3:
        raise ex.Not_in_range("Not in range")
    if number_int(id) == False:
        raise ex.InputError("The id is not int")
    if group == None:
        return
    if number_int(group) == False:
        raise ex.InputError("The number is not int")
    group = int(group)
    if group < 911 or group > 917:
        raise ex.Not_in_range("Not in range ")
コード例 #3
0
 def get_market_price(self, exchange_abbr_in, market_in, logger=None):
     #print exchange_abbr_in.lower(), self.exchange_abbr.lower(), market_in.lower() , self.market.lower()
     if exchange_abbr_in.lower() != self.exchange_abbr.lower(
     ) or market_in.lower() != self.market.lower():
         raise exceptions.InputError(
             'exchange_abbr_in or market_in is incorrect')
     return self._curr_price
コード例 #4
0
def add_assignment_validation(description, deadline):
    deadline = int(deadline)
    if deadline > 12 or deadline < 1:
        raise ex.Not_in_range("Not in range")
    if number_int(deadline) == False:
        raise ex.InputError("The number is not int")
    if deadline > 12 or deadline < 1:
        raise ex.Not_in_range("Not in range")
コード例 #5
0
	def __init__(self, arraylike):
		# flattened matrix
		numbers = [];
        
        # check if input is existing c array
        
		
		# normalize input to list of numbers from 0d, 1d, or 2d array
		if isinstance(arraylike, numtypes.Number):
			# handle scalar
			numbers = [arraylike];
			self.shape = ();
		else:
			row_dim = len(arraylike);
			col_dim = None;
			
			# inspect second dimension
			for row in arraylike:
				# check for scalar vs. list
				if isinstance(row, numtypes.Number):
					# validate column vector dimensions
					if col_dim is None:
						col_dim = 0;
					elif col_dim > 0:
						raise exceptions.InputError("Matrix dimensions don't match.", arraylike);
					# store scalar entry
					numbers.append(row);
				else:
					# validate matrix dimensions
					if col_dim is None:
						col_dim = len(row);
					elif col_dim != len(row):
						raise exceptions.InputError("Matrix dimensions don't match.", arraylike);
					# store row entries
					numbers += row;
			
			# define shape
			if col_dim: self.shape = (row_dim, col_dim);
			else:	    self.shape = (row_dim,);
			
		# allocate host memory for matrix
		self.csize = len(numbers);
		self.cptr = (ctypes.c_double * self.csize)(*numbers);
コード例 #6
0
def remove_student_validation(group, choice2):
    choice2 = int(choice2)
    if choice2 < 1 or choice2 > 3:
        raise ex.Not_in_range("Not in range")
    if group == None:
        return
    if number_int(group) == False:
        raise ex.InputError("The number is not int")
    if group < 911 or group > 917:
        raise ex.Not_in_range("Group is not between 911 and 917")
コード例 #7
0
def parse_arguments() -> dict:
    """

    Returns:

    """

    parser = ArgumentParser()
    parser.add_argument("--number", dest="n", help="Number of vertices")
    parser.add_argument("--path",
                        dest="path",
                        help="Path(s) to the file(s) with tests")
    parser.add_argument(
        "--times",
        dest="times",
        help=
        'How many tests to run (run that number of tests from "path" argument if it passed)'
    )
    parser.add_argument("--timeout",
                        dest="timeout",
                        help="Runtime threshold for one test (in minutes)")
    parser.add_argument("--global-timeout",
                        dest="global_timeout",
                        help="Runtime threshold for all tests (in minutes)")
    parser.add_argument(
        "--method",
        dest="method",
        help=
        "Method(s) to run. By default runs all methods. 0 - Simple path for directed cycles; 1 - Simple path "
        "for undirected cycles; 2 - Chain edge fixing for directed cycles; 3 - Chain edge fixing for "
        "undirected cycles",
        default='0,1,2,3')

    args = parser.parse_args()

    try:
        if not args.n and not args.path:
            raise exceptions.InputError(
                'Set one of required parameter "--number" or "--path"! Run "main.py -h" to see the help.'
            )
    except exceptions.InputError as e:
        print(e.message)
        exit()
    else:
        arguments = {'methods': list(map(int, args.method.split(',')))}

        for key, value in [('n', args.n.split(',') if args.n else None),
                           ('paths',
                            args.path.split(',') if args.path else None),
                           ('times', args.times), ('timeout', args.timeout),
                           ('global_timeout', args.global_timeout)]:
            if value:
                arguments[key] = value

        return arguments
コード例 #8
0
def remove_assignment_validation(choice2, id, deadline):
    choice2 = int(choice2)
    if deadline == None:
        return
    if choice2 < 1 or choice2 > 2:
        raise ex.Not_in_range("Not in range")
    if number_int(deadline) == False:
        raise ex.InputError("The number is not int")
    deadline = int(deadline)
    if deadline > 12 or deadline < 1:
        raise ex.Not_in_range("Not in range")
コード例 #9
0
def main():
    define_logger()
    info = []
    parser = argparse.ArgumentParser()
    parser.add_argument("-t",
                        "--test",
                        help="Launch default test.",
                        action="store_true")
    parser.add_argument("-i",
                        "--identifier",
                        type=str,
                        help="Analyze the given identifier. Choose a number"
                        "or address")
    parser.add_argument(
        "-r",
        "--range",
        nargs='+',
        type=int,
        help="Analyze the given input number range contracts (both included).")
    parser.add_argument(
        "-fn",
        "--from-number",
        type=int,
        help=
        "Analyze from given input number (included) contract until last one.")
    parser.add_argument("-d",
                        "--directory",
                        type=str,
                        help="Custom output directory.")
    parser.add_argument("-s",
                        "--select-tool",
                        nargs='+',
                        type=str,
                        help="Select one "
                        "specific tool. Available tools: solgraph, oyente, "
                        "smartcheck, solmet, osiris, vandal, ethir, mythril,"
                        "securify, slither, manticore, madmax")

    args = parser.parse_args()
    constants.DEFAULT_DIRECTORY = os.getcwd()

    logger.info('Execution begins')
    logger.info('Current working directory set to ' +
                constants.DEFAULT_DIRECTORY)

    app_engine.init()

    try:
        if args.select_tool:
            tools = []
            for i in range(0, len(args.select_tool)):
                if str.lower(args.select_tool[i]) in constants.TOOLS:
                    tools.append(str.lower(args.select_tool[i]))
                else:
                    logger.info(
                        "{} is not admitted, check whether is not bad written".
                        format(args.select_tool[i]))
            constants.DEFAULT_TOOL = tools
        if args.directory:
            logger.info('Own output directory selected -> ' + args.directory)
            dependencies_builder.create_output_dir(args.directory)
        if args.test and (args.identifier is None and args.range is None
                          and args.from_number is None):
            logger.info('Default test selected')
            test()
        elif args.identifier:
            is_address = dependencies_builder.is_address(args.identifier)
            if is_address:
                logger.info('Unique contract test selected. Address {}'.format(
                    args.identifier))
            else:
                logger.info(
                    'Unique contract test selected. Contract number {}'.format(
                        args.identifier))
            test_sigle_contract(args.identifier, is_address)
        elif args.range:
            if args.range[0] < 0 or args.range[1] < 0:
                raise exceptions.InputError(
                    'parser', 'The range can not be less than 0')
            elif (isinstance(args.range[0], int)
                  or isinstance(args.range[1], int)) is not True:
                raise exceptions.InputError('parser',
                                            'The range must be a number')
            else:
                logger.info('Range test selected. Range: {} - {}'.format(
                    args.range[0], args.range[1]))
                test_range(args.range[0], args.range[1])
        elif args.from_number:
            if args.from_number < 0 or isinstance(args.from_number,
                                                  int) is not True:
                raise exceptions.InputError(
                    'parser', 'The range must be a number and higher than 0')
            else:
                logger.info(
                    'Range from number selected. Range: {} - end'.format(
                        args.from_number))
                test_range(args.from_number)
        else:
            raise exceptions.InputError('You must select a value')
    except:
        logger.exception('Got exception parsing arguments')