Пример #1
0
 def test_twelve(self):
     order = {'apple': 15, 'banana': 15, 'cherry': 15}
     warehouses = [
         Warehouse('w1', {
             'apple': 100,
             'banana': 14,
             'duck': 4
         }),
         Warehouse('w2', {
             'banana': 100,
             'cherry': 100
         })
     ]
     expected_value = [
         Warehouse('w1', {
             'apple': 15,
             'banana': 14
         }),
         Warehouse('w2', {
             'banana': 1,
             'cherry': 15
         })
     ]
     result = InventoryAllocator(order, warehouses).complete_order()
     self.assertEqual(expected_value, result)
Пример #2
0
 def test_eighteen(self):
     order = {'apple': 100, 'banana': 200, 'cherry': 300}
     warehouses = [
         Warehouse('w1', {
             'apple': 50,
             'banana': 50,
             'cherry': 50
         }),
         Warehouse('w2', {
             'apple': 300,
             'banana': 300,
             'cherry': 300
         }),
         Warehouse('w2', {
             'apple': 50,
             'banana': 50,
             'cherry': 50
         })
     ]
     expected_value = [
         Warehouse('w1', {
             'apple': 50,
             'banana': 50,
             'cherry': 50
         }),
         Warehouse('w2', {
             'apple': 50,
             'banana': 150,
             'cherry': 250
         })
     ]
     result = InventoryAllocator(order, warehouses).complete_order()
     self.assertEqual(expected_value, result)
Пример #3
0
 def test_private_not_enough_inventory(self):
     order = {"chair": 100, "couch": 50, "bed": 30}
     warehouses = []
     warehouses.append(Warehouse("w1", {"chair": 30, "couch": 30}))
     warehouses.append(Warehouse("w2", {"chair": 30, "bed": 30}))
     warehouses.append(Warehouse("w3", {"chair": 30, "couch": 20}))
     ia = InventoryAllocator(order, warehouses)
     expected_output = []  # not enough chairs to complete order
     self.assertEqual(ia.generate_shipment(), expected_output)
Пример #4
0
 def __init__(self):
     self.warehouses = [[]] * 5
     self.warehouses[0] = Warehouse("1", 5, 10)
     self.warehouses[1] = Warehouse("2", 5, 10)
     self.warehouses[2] = Warehouse("3", 5, 10)
     self.warehouses[3] = Warehouse("4", 7, 5)
     self.warehouses[4] = Warehouse("5", 20, 20)
     self.belt = Belt()
     self.robot = Robot()
     self.input = InputCommand(self)
Пример #5
0
 def test_five(self):
     order = {'apple': 10}
     warehouses = [
         Warehouse('owd', {'apple': 8}),
         Warehouse('dm', {'apple': 5})
     ]
     expected_value = [
         Warehouse('owd', {'apple': 8}),
         Warehouse('dm', {'apple': 2})
     ]
     result = InventoryAllocator(order, warehouses).complete_order()
     self.assertEqual(expected_value, result)
Пример #6
0
 def test_eleven(self):
     order = {'apple': 15, 'cherry': 15}
     warehouses = [
         Warehouse('w1', {
             'apple': 15,
             'banana': 15,
             'cherry': 15
         })
     ]
     expected_value = [Warehouse('w1', {'apple': 15, 'cherry': 15})]
     result = InventoryAllocator(order, warehouses).complete_order()
     self.assertEqual(expected_value, result)
Пример #7
0
 def test_public_2(self):
     order = {"apple": 10}
     warehouses = [
         Warehouse("owd", {"apple": 5}),
         Warehouse("dm", {"apple": 5})
     ]
     ia = InventoryAllocator(order, warehouses)
     expected_output = [
         Warehouse("owd", {"apple": 5}),
         Warehouse("dm", {"apple": 5})
     ]
     self.assertEqual(ia.generate_shipment(), expected_output)
Пример #8
0
 def test_private_base(self):
     order = {"playstation": 1000}
     warehouses = []
     for i in range(600):
         warehouses.append(
             Warehouse(f"w-{i}", {
                 "playstation": 2,
                 "xbox": 1
             }))
     ia = InventoryAllocator(order, warehouses)
     expected_output = []
     for i in range(500):
         expected_output.append(Warehouse(f"w-{i}", {"playstation": 2}))
     self.assertEqual(ia.generate_shipment(), expected_output)
Пример #9
0
 def test_eight(self):
     order = {'apple': 10, 'banana': 10}
     warehouses = [
         Warehouse('owd', {
             'apple': 9,
             'banana': 8
         }),
         Warehouse('dm', {
             'apple': 3,
             'banana': 1
         })
     ]
     expected_value = []
     result = InventoryAllocator(order, warehouses).complete_order()
     self.assertEqual(expected_value, result)
Пример #10
0
def parse(file):
    file = open(file)
    lines = [line.rstrip('\r\n') for line in file.readlines()]

    variables = lines[0].split(' ')
    r, c, drones, deadline, max_load = variables

    products_count = int(lines[1])

    products = [
        Product(index, int(lines[2].split(' ')[index]))
        for index in range(len(lines[2].split(' ')))
    ]

    warehouse_count = int(lines[3])

    # this used to have for warehouse_no in range(warehouse_count*2-1)
    # - what was the *2-1 for? It makes us 19 warehouses rather than 10
    warehouses = [
        Warehouse(convert_coord(lines[warehouse_no + 4]),
                  convert_products(lines[warehouse_no + 5], products),
                  warehouse_no) for warehouse_no in range(warehouse_count)
    ]

    orders_offset = 4 + warehouse_count * 2

    orders_count = int(lines[orders_offset])

    orders = [
        Order(convert_coord(lines[order_no + orders_offset]),
              lines[order_no + orders_offset + 2], order_no)
        for order_no in range(orders_count * 3 - 1)
    ]

    return {'orders': orders, 'warehouses': warehouses, 'variables': variables}
Пример #11
0
 def test_private_inv_left_over_2(self):
     order = {"a": 5, "b": 6}
     warehouses = [
         Warehouse("w1", {
             "a": 6,
             "b": 2
         }), Warehouse("w2", {"b": 4})
     ]
     ia = InventoryAllocator(order, warehouses)
     expected_output = [
         Warehouse("w1", {
             "a": 5,
             "b": 2
         }), Warehouse("w2", {"b": 4})
     ]
     self.assertEqual(ia.generate_shipment(), expected_output)
    def __init__(self, order: Dict[str, int], warehouses: List[Dict[str,
                                                                    Any]]):
        self._order = order
        self._warehouses = []

        #Fill the _warehouses attribute with Warehouse objects
        for warehouse_dict in warehouses:
            self._warehouses.append(Warehouse(warehouse_dict))
Пример #13
0
 def __init__(self, filename):
     self.eventRouter = EventRouter()
     emit_method = self.eventRouter.get_emitter()
     super().__init__()
     self.player = Player(emit_method)
     self.zoo = Zoo(filename, self.player.char, emit_method)
     self.commandHandler = CommandHandler(self.zoo, self.player, Warehouse(self.zoo.in_warehouse, self.player),
                                          emit_method)
     self.eventRouter.add_listener(self.player, Event.AffecteesType.PLAYER)
     self.eventRouter.add_listener(self.zoo, Event.AffecteesType.ZOO)
     self.eventRouter.add_listener(self, Event.AffecteesType.PLAYER)
     self.eventRouter.add_listener(self, Event.AffecteesType.NONE)
Пример #14
0
 def test_private_extra_warehouse(self):
     order = {"a": 15}
     warehouses = [
         Warehouse("w1", {
             "a": 5,
             "b": 2,
             "c": 1
         }),
         Warehouse("w2", {
             "a": 10,
             "b": 4
         }),
         Warehouse("w3", {
             "a": 4,
             "c": 3
         })
     ]
     ia = InventoryAllocator(order, warehouses)
     expected_output = [
         Warehouse("w1", {"a": 5}),
         Warehouse("w2", {"a": 10})
     ]
     self.assertEqual(ia.generate_shipment(), expected_output)
Пример #15
0
 def complete_order(self):
     """
     Calculates best method of shipping items in order.
     Function searches through each Warehouse in warehouses (which are in cost order),
     determines if any items from the order are in that Warehouse, and if they are, adds
     that Warehouse to the list of Warehouses being returned with the items and quantities it
     should ship.
     :return: List of Warehouses ret containing items they need to ship based on the order
     """
     ret = []
     # Loops through each Warehouse in warehouses
     for w in self.warehouses:
         shared_items = []
         # Loops through each item in the order
         for item in self.order.keys():
             # If there is an item in both the Warehouse and the order of a quantity greater than 0 for each
             # then it is added to the list of shared items
             if self.order[item] > 0 and item in w.inventory.keys(
             ) and w.inventory[item] > 0:
                 shared_items.append(item)
         # If there are any shared items between the order and the Warehouse
         if len(shared_items) > 0:
             # This is the Warehouse with shared items, however, it is undetermined how much of which items this
             # Warehouse will ship
             ret_w = Warehouse(w.name, {})
             # Loops over each shared item
             for item in shared_items:
                 # If there is more of this item (or an equal amount) in the Warehouse than in the order,
                 # the Warehouse should ship the amount remaining in the order
                 # and this item is removed from the order
                 if self.order[item] <= w.inventory[item]:
                     ret_w.inventory[item] = self.order[item]
                     self.order.pop(item)
                 # If there is more of this item in the order than in the Warehouse,
                 # the Warehouse should ship the entirety of its stock of this item
                 # and the quantity of this item in the order is decreased by the quantity possessed by the Warehouse
                 else:
                     ret_w.inventory[item] = w.inventory[item]
                     self.order[item] = self.order[item] - w.inventory[item]
             # Add Warehouse to the list of Warehouses being returned
             ret.append(ret_w)
     # Checks whether order was complete and returns empty list if it was not
     if len(self.order.keys()) > 0:
         return []
     # Returns list of Warehouses
     return ret
Пример #16
0
 def test_private_each_warehouse(self):
     order = {"a": 5, "b": 5, "c": 5}
     warehouses = []
     warehouses.append(Warehouse("w1", {"a": 5, "d": 1}))
     warehouses.append(Warehouse("w2", {"b": 5, "d": 2}))
     warehouses.append(Warehouse("w3", {"c": 5, "d": 2}))
     ia = InventoryAllocator(order, warehouses)
     expected_output = []
     expected_output.append(Warehouse("w1", {"a": 5}))
     expected_output.append(Warehouse("w2", {"b": 5}))
     expected_output.append(Warehouse("w3", {"c": 5}))
     self.assertEqual(ia.generate_shipment(), expected_output)
Пример #17
0
    def __init__(self, params, solver):
        self.cols = params['y']
        self.rows = params['x']
        self.nbTurns = params['turns']
        self.weights = params['weights']
        self.warehouses = []
        for place, invent_dict in params['warehouses']:
            self.warehouses.append(Warehouse(place, invent_dict))
        self.orders = []
        for place, invent_dict in params['orders']:
            self.orders.append(Order(place, invent_dict))
        self.drones = []
        for e in params['nb_drones']:
            self.drones.append(
                Drone(params['payload'], self.warehouses[0].location,
                      self.weights))

        self.score = 0.0
        self.solver = solver
Пример #18
0
    def add_warehouses(self):
        """
        Aim: Processes the warehouses given in a raw format

        Input:
            self - instance of the Main driver class. 

        Output:
            List[Warehouse] - a list of warehouses (instances of the Warehouse class)
        """
        warehouses = []
        for index in range(len(self.raw_warehouses)):
            warehouse = self.raw_warehouses[index]

            # Instance of a Warehouse is created with index + 1 as its cost.
            new_warehouse = Warehouse(warehouse['name'],
                                      warehouse['inventory'], index + 1)
            warehouses.append(new_warehouse)
        return warehouses
    def load_parameters(self):
        # Settings and number of products
        self.inputfile.readline()
        self.inputfile.readline()

        productweights = self.inputfile.readline()
        products = dict(enumerate([int(i) for i in productweights.split(' ')]))

        # Warehouses
        wareamount = int(self.inputfile.readline())
        warehouses = []
        for i in range(wareamount):
            # Warehouse coordinates
            coords = [int(i) for i in self.inputfile.readline().split(' ')]
            # Warehouse contains (dictionary)
            contents = dict(
                enumerate(
                    [int(i) for i in self.inputfile.readline().split(' ')]))
            thiswarehouse = Warehouse(contents, coords)
            warehouses.append(thiswarehouse)

        # Orders
        orderamount = int(self.inputfile.readline())
        orders = []
        for i in range(orderamount):
            # Customer coordinates
            coords = [int(i) for i in self.inputfile.readline().split(' ')]
            # Order item amount
            self.inputfile.readline()
            # Item product ids
            items = {}
            for i in self.inputfile.readline().split(' '):
                if not int(i) in items:
                    items[int(i)] = 1
                else:
                    items[int(i)] += 1
            thisorder = Order(coords, items)
            orders.append(thisorder)

        return (products, warehouses, orders)
Пример #20
0
n_rows = int(input())
n_cols = int(input())
n_drones = int(input())
deadline = int(input())
drone_maxload = int(input())
n_products = int(input())
products_weights = input().split(" ")
products_weights = [int(i) for i in products_weights]
n_warehouses = int(input())

warehouses = []
for i in range(n_warehouses):
    a, b = input().split(" ")
    products = input().split(" ")
    w = Warehouse(i, n_products, [int(j) for j in products], (int(a), int(b)))
    warehouses.append(w)

n_orders = int(input())
orders = []
for i in range(n_orders):
    a, b = input().split(" ")
    n_ordered = int(input())
    order_list = input().split(" ")
    order_list = [int(j) for j in order_list]
    o = Order(i, (int(a), int(b)), order_list, n_ordered, n_products)
    orders.append(o)

total_commands = 0

drones = []
Пример #21
0
 def test_three(self):
     order = {'apple': 1}
     warehouses = [Warehouse('owd', {'apple': 0})]
     expected_value = []
     result = InventoryAllocator(order, warehouses).complete_order()
     self.assertEqual(expected_value, result)
Пример #22
0
 def test_nineteen(self):
     order = {
         'apple': 1000,
         'banana': 1000,
         'cherry': 1000,
         'duck': 1000,
         'eggs': 10000
     }
     warehouses = [
         Warehouse('w1', {
             'car': 500,
             'apple': 100
         }),
         Warehouse('w2', {
             'banana': 1000,
             'duck': 500,
             'cherry': 800
         }),
         Warehouse('w3', {
             'apple': 900,
             'banana': 1999,
             'turkey': 100000,
             'eggs': 5000
         }),
         Warehouse('w4', {'cherry': 250}),
         Warehouse('w5', {
             'chicken': 5500,
             'duck': 1000,
             'apple': 14,
             'ketchup': 16
         }),
         Warehouse('w6', {
             'eggs': 5500,
             'banana': 5,
             'cherry': 100,
             'chicken': 8
         })
     ]
     expected_value = [
         Warehouse('w1', {'apple': 100}),
         Warehouse('w2', {
             'banana': 1000,
             'cherry': 800,
             'duck': 500
         }),
         Warehouse('w3', {
             'apple': 900,
             'eggs': 5000
         }),
         Warehouse('w4', {'cherry': 200}),
         Warehouse('w5', {'duck': 500}),
         Warehouse('w6', {'eggs': 5000})
     ]
     result = InventoryAllocator(order, warehouses).complete_order()
     self.assertEqual(expected_value, result)
Пример #23
0
 def test_private_extra_warehouse_item(self):
     order = {"a": 1}
     warehouses = [Warehouse("w1", {"a": 1, "b": 1})]
     ia = InventoryAllocator(order, warehouses)
     expected_output = [Warehouse("w1", {"a": 1})]
     self.assertEqual(ia.generate_shipment(), expected_output)
Пример #24
0
 def test_fifteen(self):
     order = {'apple': 0}
     warehouses = [Warehouse('w1', {'apple': 100, 'banana': 19})]
     expected_value = []
     result = InventoryAllocator(order, warehouses).complete_order()
     self.assertEqual(expected_value, result)
Пример #25
0
from DB import LoadFile, InputSneakersInfo
from Warehouse import Warehouse

warehouse = Warehouse()
data = LoadFile('products.txt')
warehouse.add(data)


def PrintMenuStartInfo():
    print(f'Добро пожаловать в систему учета для складских остатков\n'
          f'Введите один из вариантов в меню и нажмите Enter\n'
          f'1. Добавить товар\n'
          f'2. Загрузить товары с файла\n'
          f'3. Удалить товар\n'
          f'2. Список всех товаров\n'
          f'4. Статистика по категориям\n')


while True:
    PrintMenuStartInfo()
    option = int(input())
    if option == 1:
        sneakers = list()
        sneakers.append(InputSneakersInfo())
        warehouse.add(sneakers)
    elif option == 2:
        data = LoadFile('products.txt')
        warehouse.add(data)
    elif option == 3:
        warehouse.displayAllSneakers()
        sneakers = InputSneakersInfo()
Пример #26
0
 def test_private_empty_order(self):
     order = {}
     warehouses = [Warehouse("w1", {"a": 1})]
     ia = InventoryAllocator(order, warehouses)
     expected_output = []
     self.assertEqual(ia.generate_shipment(), expected_output)
Пример #27
0
def get_packages():
    with open('venv\Data\Packages1.csv', 'r', encoding='utf-8-sig') as csvfile:
        read_csv1 = csv.reader(csvfile, skipinitialspace=True, delimiter=',')

        warehouse_obj = Warehouse(read_csv1)
        return warehouse_obj
Пример #28
0
  def processPBSResults(self):
    # If batch file exists, check the contents for pending tests.
    if os.path.exists(self.options.pbs):
      # Build a list of launched jobs
      batch_file = open(self.options.pbs)
      batch_list = [y.split(':') for y in [x for x in batch_file.read().split('\n')]]
      batch_file.close()
      del batch_list[-1:]

      # Loop through launched jobs and match the TEST_NAME to determin correct stdout (Output_Path)
      for job in batch_list:
        file = '/'.join(job[2].split('/')[:-2]) + '/' + job[3]

        # Build a Warehouse to hold the MooseObjects
        warehouse = Warehouse()

        # Build a Parser to parse the objects
        parser = Parser(self.factory, warehouse)

        # Parse it
        parser.parse(file)

        # Retrieve the tests from the warehouse
        testers = warehouse.getAllObjects()
        for tester in testers:
          self.augmentParameters(file, tester)

        for tester in testers:
          # Build the requested Tester object
          if job[1] == tester.parameters()['test_name']:
            # Create Test Type
            # test = self.factory.create(tester.parameters()['type'], tester)

            # Get job status via qstat
            qstat = ['qstat', '-f', '-x', str(job[0])]
            qstat_command = subprocess.Popen(qstat, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            qstat_stdout = qstat_command.communicate()[0]
            if qstat_stdout != None:
              output_value = re.search(r'job_state = (\w+)', qstat_stdout).group(1)
            else:
              return ('QSTAT NOT FOUND', '')

            # Report the current status of JOB_ID
            if output_value == 'F':
              # F = Finished. Get the exit code reported by qstat
              exit_code = int(re.search(r'Exit_status = (-?\d+)', qstat_stdout).group(1))

              # Read the stdout file
              if os.path.exists(job[2]):
                output_file = open(job[2], 'r')
                # Not sure I am doing this right: I have to change the TEST_DIR to match the temporary cluster_launcher TEST_DIR location, thus violating the tester.specs...
                tester.parameters()['test_dir'] = '/'.join(job[2].split('/')[:-1])
                outfile = output_file.read()
                output_file.close()
                self.testOutputAndFinish(tester, exit_code, outfile)
              else:
                # I ran into this scenario when the cluster went down, but launched/completed my job :)
                self.handleTestResult(tester.specs, '', 'FAILED (NO STDOUT FILE)', 0, 0, True)

            elif output_value == 'R':
              # Job is currently running
              self.handleTestResult(tester.specs, '', 'RUNNING', 0, 0, True)
            elif output_value == 'E':
              # Job is exiting
              self.handleTestResult(tester.specs, '', 'EXITING', 0, 0, True)
            elif output_value == 'Q':
              # Job is currently queued
              self.handleTestResult(tester.specs, '', 'QUEUED', 0, 0, True)
    else:
      return ('BATCH FILE NOT FOUND', '')
Пример #29
0
  def __init__(self, argv, app_name, moose_dir):
    self.factory = Factory()

    # Build a Warehouse to hold the MooseObjects
    self.warehouse = Warehouse()

    # Get dependant applications and load dynamic tester plugins
    # If applications have new testers, we expect to find them in <app_dir>/scripts/TestHarness/testers
    dirs = [os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))]
    sys.path.append(os.path.join(moose_dir, 'framework', 'scripts'))   # For find_dep_apps.py

    # Use the find_dep_apps script to get the dependant applications for an app
    import find_dep_apps
    depend_app_dirs = find_dep_apps.findDepApps(app_name)
    dirs.extend([os.path.join(my_dir, 'scripts', 'TestHarness') for my_dir in depend_app_dirs.split('\n')])

    # Finally load the plugins!
    self.factory.loadPlugins(dirs, 'testers', Tester)

    self.test_table = []
    self.num_passed = 0
    self.num_failed = 0
    self.num_skipped = 0
    self.num_pending = 0
    self.host_name = gethostname()
    self.moose_dir = moose_dir
    self.base_dir = os.getcwd()
    self.run_tests_dir = os.path.abspath('.')
    self.code = '2d2d6769726c2d6d6f6465'
    self.error_code = 0x0
    # Assume libmesh is a peer directory to MOOSE if not defined
    if os.environ.has_key("LIBMESH_DIR"):
      self.libmesh_dir = os.environ['LIBMESH_DIR']
    else:
      self.libmesh_dir = os.path.join(self.moose_dir, 'libmesh', 'installed')
    self.file = None

    # Parse arguments
    self.parseCLArgs(argv)

    self.checks = {}
    self.checks['platform'] = getPlatforms()
    self.checks['submodules'] = getInitializedSubmodules(self.run_tests_dir)

    # The TestHarness doesn't strictly require the existence of libMesh in order to run. Here we allow the user
    # to select whether they want to probe for libMesh configuration options.
    if self.options.skip_config_checks:
      self.checks['compiler'] = set(['ALL'])
      self.checks['petsc_version'] = 'N/A'
      self.checks['library_mode'] = set(['ALL'])
      self.checks['mesh_mode'] = set(['ALL'])
      self.checks['dtk'] = set(['ALL'])
      self.checks['unique_ids'] = set(['ALL'])
      self.checks['vtk'] = set(['ALL'])
      self.checks['tecplot'] = set(['ALL'])
      self.checks['dof_id_bytes'] = set(['ALL'])
      self.checks['petsc_debug'] = set(['ALL'])
      self.checks['curl'] = set(['ALL'])
      self.checks['tbb'] = set(['ALL'])
      self.checks['superlu'] = set(['ALL'])
      self.checks['unique_id'] = set(['ALL'])
      self.checks['cxx11'] = set(['ALL'])
      self.checks['asio'] =  set(['ALL'])
    else:
      self.checks['compiler'] = getCompilers(self.libmesh_dir)
      self.checks['petsc_version'] = getPetscVersion(self.libmesh_dir)
      self.checks['library_mode'] = getSharedOption(self.libmesh_dir)
      self.checks['mesh_mode'] = getLibMeshConfigOption(self.libmesh_dir, 'mesh_mode')
      self.checks['dtk'] =  getLibMeshConfigOption(self.libmesh_dir, 'dtk')
      self.checks['unique_ids'] = getLibMeshConfigOption(self.libmesh_dir, 'unique_ids')
      self.checks['vtk'] =  getLibMeshConfigOption(self.libmesh_dir, 'vtk')
      self.checks['tecplot'] =  getLibMeshConfigOption(self.libmesh_dir, 'tecplot')
      self.checks['dof_id_bytes'] = getLibMeshConfigOption(self.libmesh_dir, 'dof_id_bytes')
      self.checks['petsc_debug'] = getLibMeshConfigOption(self.libmesh_dir, 'petsc_debug')
      self.checks['curl'] =  getLibMeshConfigOption(self.libmesh_dir, 'curl')
      self.checks['tbb'] =  getLibMeshConfigOption(self.libmesh_dir, 'tbb')
      self.checks['superlu'] =  getLibMeshConfigOption(self.libmesh_dir, 'superlu')
      self.checks['unique_id'] =  getLibMeshConfigOption(self.libmesh_dir, 'unique_id')
      self.checks['cxx11'] =  getLibMeshConfigOption(self.libmesh_dir, 'cxx11')
      self.checks['asio'] =  getIfAsioExists(self.moose_dir)

    # Override the MESH_MODE option if using the '--distributed-mesh'
    # or (deprecated) '--parallel-mesh' option.
    if (self.options.parallel_mesh == True or self.options.distributed_mesh == True) or \
          (self.options.cli_args != None and \
           (self.options.cli_args.find('--parallel-mesh') != -1 or self.options.cli_args.find('--distributed-mesh') != -1)):

      option_set = set(['ALL', 'PARALLEL'])
      self.checks['mesh_mode'] = option_set

    method = set(['ALL', self.options.method.upper()])
    self.checks['method'] = method

    self.initialize(argv, app_name)
Пример #30
0
  def findAndRunTests(self):
    self.error_code = 0x0
    self.preRun()
    self.start_time = clock()

    # PBS STUFF
    if self.options.pbs and os.path.exists(self.options.pbs):
      self.options.processingPBS = True
      self.processPBSResults()
    else:
      self.options.processingPBS = False
      for dirpath, dirnames, filenames in os.walk(os.getcwd(), followlinks=True):
        # Prune submdule paths when searching for tests
        if '.git' in filenames:
          dirnames[:] = []

        # Look for test directories that aren't in contrib folders
        if (self.test_match.search(dirpath) and "contrib" not in os.path.relpath(dirpath, os.getcwd())):
          for file in filenames:
            # set cluster_handle to be None initially (happens for each test)
            self.options.cluster_handle = None
            # See if there were other arguments (test names) passed on the command line
            if file == self.options.input_file_name: #and self.test_match.search(file):
              saved_cwd = os.getcwd()
              sys.path.append(os.path.abspath(dirpath))
              os.chdir(dirpath)

              if self.prunePath(file):
                continue

              # Build a Warehouse to hold the MooseObjects
              warehouse = Warehouse()

              # Build a Parser to parse the objects
              parser = Parser(self.factory, warehouse)

              # Parse it
              self.error_code = self.error_code | parser.parse(file)

              # Retrieve the tests from the warehouse
              testers = warehouse.getAllObjects()

              # Augment the Testers with additional information directly from the TestHarness
              for tester in testers:
                self.augmentParameters(file, tester)

              if self.options.enable_recover:
                testers = self.appendRecoverableTests(testers)

              # Go through the Testers and run them
              for tester in testers:
                # Double the alloted time for tests when running with the valgrind option
                tester.setValgrindMode(self.options.valgrind_mode)

                # When running in valgrind mode, we end up with a ton of output for each failed
                # test.  Therefore, we limit the number of fails...
                if self.options.valgrind_mode and self.num_failed > self.options.valgrind_max_fails:
                  (should_run, reason) = (False, 'Max Fails Exceeded')
                elif self.num_failed > self.options.max_fails:
                  (should_run, reason) = (False, 'Max Fails Exceeded')
                else:
                  (should_run, reason) = tester.checkRunnableBase(self.options, self.checks)

                if should_run:
                  # Create the cluster launcher input file
                  if self.options.pbs and self.options.cluster_handle == None:
                    self.options.cluster_handle = open(dirpath + '/tests.cluster', 'a')
                    self.options.cluster_handle.write('[Jobs]\n')

                  command = tester.getCommand(self.options)
                  # This method spawns another process and allows this loop to continue looking for tests
                  # RunParallel will call self.testOutputAndFinish when the test has completed running
                  # This method will block when the maximum allowed parallel processes are running
                  self.runner.run(tester, command)
                else: # This job is skipped - notify the runner
                  if (reason != ''):
                    self.handleTestResult(tester.parameters(), '', reason)
                  self.runner.jobSkipped(tester.parameters()['test_name'])

                if self.options.cluster_handle != None:
                  self.options.cluster_handle.write('[]\n')
                  self.options.cluster_handle.close()
                  self.options.cluster_handle = None

              os.chdir(saved_cwd)
              sys.path.pop()

    self.runner.join()
    # Wait for all tests to finish
    if self.options.pbs and self.options.processingPBS == False:
      print '\n< checking batch status >\n'
      self.options.processingPBS = True
      self.processPBSResults()

    self.cleanup()

    if self.num_failed:
      self.error_code = self.error_code | 0x10

    sys.exit(self.error_code)