Python logging.error() Examples

The following are 30 code examples for showing how to use logging.error(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module logging , or try the search function .

Example 1
Project: indras_net   Author: gcallah   File: height.py    License: GNU General Public License v3.0 6 votes vote down vote up
def get_agent_from_json(agent_json):
        new_agent = None
        if agent_json["ntype"] == HeightAgent.__name__:
            new_agent = HeightAgent(name=agent_json["name"],
                                    height=agent_json["height"],
                                    parent_height=agent_json["parent_height"])

        elif agent_json["ntype"] in HeightAgentEng.__name__:
            new_agent = HeightAgentEng(name=agent_json["name"],
                                       height=agent_json["height"],
                                       parent_height=agent_json["parent_height"])

        else:
            logging.error("agent found whose NTYPE is neither "
                          "{} nor {}, but rather {}".format(HeightAgent.__name__,
                                                            HeightAgentEng.__name__,
                                                            agent_json["ntype"]))
        return new_agent 
Example 2
Project: indras_net   Author: gcallah   File: fashion.py    License: GNU General Public License v3.0 6 votes vote down vote up
def restore_agent(self, agent_json):
        """
        Restore agent.
        """
        new_agent = None
        if agent_json["ntype"] == Hipster.__name__:
            new_agent = Hipster(name=agent_json["name"],
                                goal=agent_json["goal"],
                                max_move=agent_json["max_move"],
                                variability=agent_json["variability"])

        elif agent_json["ntype"] == Follower.__name__:
            new_agent = Follower(name=agent_json["name"],
                                 goal=agent_json["goal"],
                                 max_move=agent_json["max_move"],
                                 variability=agent_json["variability"])

        else:
            logging.error("agent found whose NTYPE is neither "
                          "{} nor {}, but {}".format(Hipster.__name__,
                                                     Follower.__name__,
                                                     agent_json["ntype"]))

        if new_agent:
            self.add_agent_from_json(new_agent, agent_json) 
Example 3
Project: svviz   Author: svviz   File: app.py    License: MIT License 6 votes vote down vote up
def checkRequirements(args):
    if not remap.check_swalign():
        print("ERROR: check that svviz is correctly installed -- the 'ssw' Smith-Waterman alignment module does not appear to be functional")
        sys.exit(1)
    if args.export:
        exportFormat = export.getExportFormat(args)
        converter = export.getExportConverter(args, exportFormat)
        if converter is None and exportFormat != "svg":
            if args.converter is not None:
                logging.error("ERROR: unable to run SVG converter '{}'. Please check that it is "
                    "installed correctly".format(args.converter))
            else:
                logging.error("ERROR: unable to export to PDF/PNG because at least one of the following "
                    "programs must be correctly installed: webkitToPDF, librsvg or inkscape")

            sys.exit(1) 
Example 4
Project: svviz   Author: svviz   File: web.py    License: MIT License 6 votes vote down vote up
def index():
    if not "last_format" in session:
        session["last_format"] = "svg"
        session.permanent = True

    try:
        variantDescription = str(dataHub.variant).replace("::", " ").replace("-", "–")
        return render_template('index.html',
            samples=list(dataHub.samples.keys()), 
            annotations=dataHub.annotationSets,
            results_table=dataHub.getCounts(),
            insertSizeDistributions=[sample.name for sample in dataHub if sample.insertSizePlot], 
            dotplots=dataHub.dotplots,
            variantDescription=variantDescription)
    except Exception as e:
        logging.error("ERROR:{}".format(e))
        raise 
Example 5
Project: svviz   Author: svviz   File: vcf.py    License: MIT License 6 votes vote down vote up
def parseVCFLine(line, dataHub):
    try:
        fields = line.strip().split()

        info = parseInfo(fields[7])

        record = VCFRecord(fields, info)

        if record.svtype == "INS":
            return parseInsertion(record, dataHub)
        elif record.svtype == "DEL":
            return parseDeletion(record, dataHub)
        elif record.svtype == "INV":
            return parseInversion(record, dataHub)
        elif record.svtype == "TRA":
            return parseTranslocation(record, dataHub)
        raise VCFParserError("Unsupported variant type:{}".format(record.svtype))
    except Exception as e:
        logging.error("\n== Failed to load variant: {} ==".format(e))
        logging.error(str(line.strip()))
        return None 
Example 6
Project: svviz   Author: svviz   File: export.py    License: MIT License 6 votes vote down vote up
def getExportConverter(args, exportFormat):
    if args.converter == "webkittopdf" and exportFormat=="png":
        logging.error("webkitToPDF does not support export to PNG; use librsvg or inkscape instead, or "
            "export to PDF")
        sys.exit(1)

    if exportFormat == "png" and args.converter is None:
        return "librsvg"

    if args.converter == "rsvg-convert":
        return "librsvg"

    if args.converter in [None, "webkittopdf"]:
        if checkWebkitToPDF():
            return "webkittopdf"

    if args.converter in [None, "librsvg"]:
        if checkRSVGConvert():
            return "librsvg"

    if args.converter in [None, "inkscape"]:
        if checkInkscape():
            return "inkscape"

    return None 
Example 7
Project: ALF   Author: blackberry   File: local.py    License: Apache License 2.0 6 votes vote down vote up
def load_project(project_name):
    # load project and check that it looks okay
    try:
        importlib.import_module(project_name)
    except ImportError as e:
        try:
            #TODO: relative module imports in a projects/Project will fail for some reason
            importlib.import_module("projects.%s" % project_name)
        except ImportError as e:
            log.error("Failed to import project %s", project_name, exc_info=1)
            sys.exit(1)
    if len(_registered) != 1:
        log.error("Project must register itself using alf.register(). "
                  "%d projects registered, expecting 1.", len(_registered))
        sys.exit(1)
    project_cls = _registered.pop()
    if not issubclass(project_cls, Fuzzer):
        raise TypeError("Expecting a Fuzzer, not '%s'" % type(project_cls))
    return project_cls 
Example 8
Project: vt-ida-plugin   Author: VirusTotal   File: plugin_loader.py    License: Apache License 2.0 6 votes vote down vote up
def read_config(self):
    """Read the user's configuration file."""

    logging.debug('[VT Plugin] Reading user config file: %s', self.vt_cfgfile)
    config_file = configparser.RawConfigParser()
    config_file.read(self.vt_cfgfile)

    try:
      if config_file.get('General', 'auto_upload') == 'True':
        self.auto_upload = True
      else:
        self.auto_upload = False
      return True
    except:
      logging.error('[VT Plugin] Error reading the user config file.')
      return False 
Example 9
Project: vt-ida-plugin   Author: VirusTotal   File: plugin_loader.py    License: Apache License 2.0 6 votes vote down vote up
def check_version(self):
    """Return True if there's an update available."""

    user_agent = 'IDA Pro VT Plugin checkversion - v' + VT_IDA_PLUGIN_VERSION
    headers = {
        'User-Agent': user_agent,
        'Accept': 'application/json'
    }
    url = 'https://raw.githubusercontent.com/VirusTotal/vt-ida-plugin/master/VERSION'

    try:
      response = requests.get(url, headers=headers)
    except:
      logging.error('[VT Plugin] Unable to check for updates.')
      return False

    if response.status_code == 200:
      version = response.text.rstrip('\n')
      if self.__compare_versions(VT_IDA_PLUGIN_VERSION, version):
        logging.debug('[VT Plugin] Version %s is available !', version)
        return True
    return False 
Example 10
def make_directory_writable(dirname):
  """Makes directory readable and writable by everybody.

  Args:
    dirname: name of the directory

  Returns:
    True if operation was successfull

  If you run something inside Docker container and it writes files, then
  these files will be written as root user with restricted permissions.
  So to be able to read/modify these files outside of Docker you have to change
  permissions to be world readable and writable.
  """
  retval = shell_call(['docker', 'run', '-v',
                       '{0}:/output_dir'.format(dirname),
                       'busybox:1.27.2',
                       'chmod', '-R', 'a+rwx', '/output_dir'])
  if not retval:
    logging.error('Failed to change permissions on directory: %s', dirname)
  return retval 
Example 11
def _verify_docker_image_size(self, image_name):
    """Verifies size of Docker image.

    Args:
      image_name: name of the Docker image.

    Returns:
      True if image size is withing the limits, False otherwise.
    """
    shell_call(['docker', 'pull', image_name])
    try:
      image_size = subprocess.check_output(
          ['docker', 'inspect', '--format={{.Size}}', image_name]).strip()
      image_size = int(image_size) if PY3 else long(image_size)
    except (ValueError, subprocess.CalledProcessError) as e:
      logging.error('Failed to determine docker image size: %s', e)
      return False
    logging.info('Size of docker image %s is %d', image_name, image_size)
    if image_size > MAX_DOCKER_IMAGE_SIZE:
      logging.error('Image size exceeds limit %d', MAX_DOCKER_IMAGE_SIZE)
    return image_size <= MAX_DOCKER_IMAGE_SIZE 
Example 12
def copy_submission_to_destination(self, src_filename, dst_subdir,
                                     submission_id):
    """Copies submission to target directory.

    Args:
      src_filename: source filename of the submission
      dst_subdir: subdirectory of the target directory where submission should
        be copied to
      submission_id: ID of the submission, will be used as a new
        submission filename (before extension)
    """

    extension = [e for e in ALLOWED_EXTENSIONS if src_filename.endswith(e)]
    if len(extension) != 1:
      logging.error('Invalid submission extension: %s', src_filename)
      return
    dst_filename = os.path.join(self.target_dir, dst_subdir,
                                submission_id + extension[0])
    cmd = ['gsutil', 'cp', src_filename, dst_filename]
    if subprocess.call(cmd) != 0:
      logging.error('Can\'t copy submission to destination')
    else:
      logging.info('Submission copied to: %s', dst_filename) 
Example 13
def save_id_to_path_mapping(self):
    """Saves mapping from submission IDs to original filenames.

    This mapping is saved as CSV file into target directory.
    """
    if not self.id_to_path_mapping:
      return
    with open(self.local_id_to_path_mapping_file, 'w') as f:
      writer = csv.writer(f)
      writer.writerow(['id', 'path'])
      for k, v in sorted(iteritems(self.id_to_path_mapping)):
        writer.writerow([k, v])
    cmd = ['gsutil', 'cp', self.local_id_to_path_mapping_file,
           os.path.join(self.target_dir, 'id_to_path_mapping.csv')]
    if subprocess.call(cmd) != 0:
      logging.error('Can\'t copy id_to_path_mapping.csv to target directory') 
Example 14
def make_directory_writable(dirname):
  """Makes directory readable and writable by everybody.

  Args:
    dirname: name of the directory

  Returns:
    True if operation was successfull

  If you run something inside Docker container and it writes files, then
  these files will be written as root user with restricted permissions.
  So to be able to read/modify these files outside of Docker you have to change
  permissions to be world readable and writable.
  """
  retval = shell_call(['docker', 'run', '-v',
                       '{0}:/output_dir'.format(dirname),
                       'busybox:1.27.2',
                       'chmod', '-R', 'a+rwx', '/output_dir'])
  if not retval:
    logging.error('Failed to change permissions on directory: %s', dirname)
  return retval 
Example 15
Project: neural-fingerprinting   Author: StephanZheng   File: cloud_client.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def rollback(self):
    """Rolls back pending mutations.

    Keep in mind that NoTransactionBatch splits all mutations into smaller
    batches and commit them as soon as mutation buffer reaches maximum length.
    That's why rollback method will only roll back pending mutations from the
    buffer, but won't be able to rollback already committed mutations.
    """
    try:
      if self._cur_batch:
        self._cur_batch.rollback()
    except ValueError:
      # ignore "Batch must be in progress to rollback" error
      pass
    self._cur_batch = None
    self._num_mutations = 0 
Example 16
Project: multibootusb   Author: mbusb   File: osdriver.py    License: GNU General Public License v2.0 6 votes vote down vote up
def log(message, info=True, error=False, debug=False, _print=True):
    """
    Dirty function to log messages to file and also print on screen.
    :param message:
    :param info:
    :param error:
    :param debug:
    :return:
    """
    if _print is True:
        print(message)

    # remove ANSI color codes from logs
    # message_clean = re.compile(r'\x1b[^m]*m').sub('', message)

    if info is True:
        logging.info(message)
    elif error is not False:
        logging.error(message)
    elif debug is not False:
        logging.debug(message) 
Example 17
Project: friendly-telegram   Author: friendly-telegram   File: heroku.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def get_app(clients, key, api_token=None, create_new=True, full_match=False):
    heroku = heroku3.from_key(key)
    app = None
    for poss_app in heroku.apps():
        config = poss_app.config()
        if "authorization_strings" not in config:
            continue
        if (api_token is None or (config["api_id"] == api_token.ID and config["api_hash"] == api_token.HASH)):
            if full_match and config["authorization_strings"] != os.environ["authorization_strings"]:
                continue
            app = poss_app
            break
    if app is None:
        if api_token is None or not create_new:
            logging.error("%r", {app: repr(app.config) for app in heroku.apps()})
            raise RuntimeError("Could not identify app!")
        app = heroku.create_app(stack_id_or_name="heroku-18", region_id_or_name="us")
        config = app.config()
    return app, config 
Example 18
Project: friendly-telegram   Author: friendly-telegram   File: utils.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def get_user(message):
    """Get user who sent message, searching if not found easily"""
    try:
        return await message.client.get_entity(message.from_id)
    except ValueError:  # Not in database. Lets go looking for them.
        logging.debug("user not in session cache. searching...")
    if isinstance(message.to_id, PeerUser):
        await message.client.get_dialogs()
        return await message.client.get_entity(message.from_id)
    if isinstance(message.to_id, (PeerChannel, PeerChat)):
        async for user in message.client.iter_participants(message.to_id, aggressive=True):
            if user.id == message.from_id:
                return user
        logging.error("WTF! user isn't in the group where they sent the message")
        return None
    logging.error("WTF! to_id is not a user, chat or channel")
    return None 
Example 19
Project: dynamic-training-with-apache-mxnet-on-aws   Author: awslabs   File: tensorrt.py    License: Apache License 2.0 6 votes vote down vote up
def get_optimized_symbol(executor):
    """
    Take an executor's underlying symbol graph and return its generated optimized version.

    Parameters
    ----------
    executor :
        An executor for which you want to see an optimized symbol. Getting an optimized symbol
        is useful to compare and verify the work TensorRT has done against a legacy behaviour.

    Returns
    -------
    symbol : nnvm::Symbol
        The nnvm symbol optimized.
    """
    handle = SymbolHandle()
    try:
        check_call(_LIB.MXExecutorGetOptimizedSymbol(executor.handle, ctypes.byref(handle)))
        result = sym.Symbol(handle=handle)
        return result
    except MXNetError:
        logging.error('Error while trying to fetch TRT optimized symbol for graph. Please ensure '
                      'build was compiled with MXNET_USE_TENSORRT enabled.')
        raise 
Example 20
def _test_notebook(notebook, override_epochs=True):
    """Run Jupyter notebook to catch any execution error.

    Args:
        notebook : string
            notebook name in folder/notebook format
        override_epochs : boolean
            whether or not to override the number of epochs to 1

    Returns:
        True if the notebook runs without warning or error.
    """
    # Some notebooks will fail to run without error if we do not override
    # relative paths to the data and image directories.
    _override_relative_paths(notebook)

    if override_epochs:
        _override_epochs(notebook)

    return run_notebook(notebook, NOTEBOOKS_DIR, kernel=KERNEL, temp_dir=NOTEBOOKS_DIR) 
Example 21
def _download_straight_dope_notebooks():
    """Downloads the Straight Dope Notebooks.

    Returns:
        True if it succeeds in downloading the notebooks without error.
    """
    logging.info('Cleaning and setting up notebooks directory "{}"'.format(NOTEBOOKS_DIR))
    shutil.rmtree(NOTEBOOKS_DIR, ignore_errors=True)

    cmd = [GIT_PATH,
           'clone',
           GIT_REPO,
           NOTEBOOKS_DIR]

    proc, msg = _run_command(cmd)

    if proc.returncode != 0:
        err_msg = 'Error downloading Straight Dope notebooks.\n'
        err_msg += msg
        logging.error(err_msg)
        return False
    return True 
Example 22
def build_save_containers(platforms, registry, load_cache) -> int:
    """
    Entry point to build and upload all built dockerimages in parallel
    :param platforms: List of platforms
    :param registry: Docker registry name
    :param load_cache: Load cache before building
    :return: 1 if error occurred, 0 otherwise
    """
    from joblib import Parallel, delayed
    if len(platforms) == 0:
        return 0

    platform_results = Parallel(n_jobs=len(platforms), backend="multiprocessing")(
        delayed(_build_save_container)(platform, registry, load_cache)
        for platform in platforms)

    is_error = False
    for platform_result in platform_results:
        if platform_result is not None:
            logging.error('Failed to generate %s', platform_result)
            is_error = True

    return 1 if is_error else 0 
Example 23
Project: SecPi   Author: SecPi   File: manager.py    License: GNU General Public License v3.0 6 votes vote down vote up
def got_config_request(self, ch, method, properties, body):
		ip_addresses = json.loads(body)
		logging.info("Got config request with following IP addresses: %s" % ip_addresses)

		pi_id = None
		worker = db.session.query(db.objects.Worker).filter(db.objects.Worker.address.in_(ip_addresses)).first()
		if worker:
			pi_id = worker.id
			logging.debug("Found worker id %s for IP address %s" % (pi_id, worker.address))
		else: # wasn't able to find worker with given ip address(es)
			logging.error("Wasn't able to find worker for given IP adress(es)")
			reply_properties = pika.BasicProperties(correlation_id=properties.correlation_id)
			self.channel.basic_publish(exchange=utils.EXCHANGE, properties=reply_properties, routing_key=properties.reply_to, body="")
			return
		
		config = self.prepare_config(pi_id)
		logging.info("Sending intial config to worker with id %s" % pi_id)
		reply_properties = pika.BasicProperties(correlation_id=properties.correlation_id, content_type='application/json')
		self.channel.basic_publish(exchange=utils.EXCHANGE, properties=reply_properties, routing_key=properties.reply_to, body=json.dumps(config))

	# callback method for when the manager recieves data after a worker executed its actions 
Example 24
Project: SecPi   Author: SecPi   File: dropbox_dropper.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, id, params):
		super(Dropbox_Dropper, self).__init__(id, params)
		try:
			self.access_token = params["access_token"]
		except KeyError as k: # if config parameters are missing
			logging.error("Dropxbox: Error while trying to initialize notifier, it seems there is a config parameter missing: %s" % k)
			self.corrupted = True
			return

		try:
			self.dbx = dropbox.Dropbox(self.access_token)
		except Exception as e:
			logging.error("Dropbox: Error while connecting to Dropbox service: %s" % e)
			self.corrupted = True
			return

		self.data_dir = "/var/tmp/secpi/alarms/" #change this maybe?

		logging.info("Dropbox initialized") 
Example 25
Project: SecPi   Author: SecPi   File: dropbox_dropper.py    License: GNU General Public License v3.0 6 votes vote down vote up
def notify(self, info):
		if not self.corrupted:
			#info_str = "Recieved alarm on sensor %s from worker %s: %s"%(info['sensor'], info['worker'], info['message'])
			latest_subdir = self.get_latest_subdir()

			dropbox_dir = "/%s" % latest_subdir.split("/")[-1] #pfui
			#self.dbx.files_create_folder(dropbox_dir) # shouldn't be necessary, automatically created 
			for file in os.listdir(latest_subdir):
				if os.path.isfile("%s/%s" % (latest_subdir, file)):
					f = open("%s/%s" % (latest_subdir, file), "rb")
					data = f.read()
					try:
						logging.info("Dropbox: Trying to upload file %s to %s" % (file, dropbox_dir))
						res = self.dbx.files_upload(data, "%s/%s" % (dropbox_dir, file))
						logging.info("Dropbox: Upload of file %s succeeded" % file)
					except dropbox.exceptions.ApiError as d:
						logging.error("Dropbox: API error: %s" % d)
					except Exception as e: # currently this catches wrong authorization, we should change this
						logging.error("Dropbox: Wasn't able to upload file: %s" % e)
					f.close()
		else:
			logging.error("Dropbox: Wasn't able to notify because there was an initialization error") 
Example 26
Project: SecPi   Author: SecPi   File: mailer.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, id, params):
		super(Mailer, self).__init__(id, params)
		
		try:
			# SMTP Server config + data dir
			self.data_dir = params.get("data_dir", "/var/tmp/secpi/alarms")
			self.smtp_address = params["smtp_address"]
			self.smtp_port = int(params["smtp_port"])
			self.smtp_user = params["smtp_user"]
			self.smtp_pass = params["smtp_pass"]
			self.smtp_security = params["smtp_security"]
		except KeyError as ke: # if config parameters are missing
			logging.error("Mailer: Wasn't able to initialize the notifier, it seems there is a config parameter missing: %s" % ke)
			self.corrupted = True
			return
		except ValueError as ve: # if one configuration parameter can't be parsed as int
			logging.error("Mailer: Wasn't able to initialize the notifier, please check your configuration: %s" % ve)
			self.corrupted = True
			return

		logging.info("Mailer: Notifier initialized") 
Example 27
Project: indras_net   Author: gcallah   File: grid_env.py    License: GNU General Public License v3.0 5 votes vote down vote up
def move_to_empty(self, agent, grid_view=None):
        """
        Moves agent to an empty cell, vacating agent's old cell.
        """
        empty_cell = self.find_empty(grid_view)
        if empty_cell is None:
            logging.error("Agent could not move because no cells are empty")
        else:
            self._move_item(agent, empty_cell)

    #Functions by JacEkko (John Knox)==================================================== 
Example 28
Project: indras_net   Author: gcallah   File: bigbox.py    License: GNU General Public License v3.0 5 votes vote down vote up
def restore_agent(self, agent_json):
        new_agent = None
        if agent_json["ntype"] == Consumer.__name__:
            new_agent = Consumer(name=agent_json["name"],
                                 goal=agent_json["goal"],
                                 init_state=agent_json["state"],
                                 allowance=agent_json["allowance"])

        elif agent_json["ntype"] in GOODS_MAP.values():
            new_agent = MomAndPop(name=agent_json["name"],
                                  goal=agent_json["goal"],
                                  endowment=agent_json["endowment"],
                                  expenses=agent_json["expenses"],
                                  adj=agent_json["adj"])

        elif agent_json["ntype"] == BigBox.__name__:
            new_agent = BigBox(name=agent_json["name"],
                               goal=agent_json["goal"],
                               endowment=agent_json["endowment"],
                               expenses=agent_json["expenses"])

        else:
            logging.error("agent found whose NTYPE is neither "
                          "{}, {}, nor {}, but rather {}".format(Consumer.__name__,
                                                                 Retailer.__name__,
                                                                 BigBox.__name__,
                                                                 agent_json["ntype"]))

        if new_agent:
            self.add_agent_from_json(new_agent, agent_json) 
Example 29
Project: indras_net   Author: gcallah   File: coop.py    License: GNU General Public License v3.0 5 votes vote down vote up
def restore_agent(self, agent_json):
        new_agent = None
        if agent_json["ntype"] == CoopAgent.__name__:
            new_agent = CoopAgent(name=agent_json["name"],
                                  coupons=agent_json["coupons"],
                                  min_holdings=agent_json["min_holdings"])

        else:
            logging.error("agent found whose NTYPE is not "
                          "{}, but is rather {}".format(CoopAgent.__name__,
                                                        agent_json["ntype"]))

        if new_agent:
            self.add_agent_from_json(new_agent, agent_json) 
Example 30
Project: indras_net   Author: gcallah   File: wolfsheep.py    License: GNU General Public License v3.0 5 votes vote down vote up
def restore_agent(self, agent_json):
        new_agent = None
        if agent_json["ntype"] == WOLF_NTYPE:
            new_agent = Wolf(name=agent_json["name"],
                             goal=agent_json["goal"],
                             repro_age=agent_json["repro_age"],
                             life_force=agent_json["life_force"],
                             max_detect=agent_json["max_detect"],
                             rand_age=agent_json["age"],
                             speed=agent_json["speed"])

        elif agent_json["ntype"] == SHEEP_NTYPE:
            new_agent = Sheep(name=agent_json["name"],
                              goal=agent_json["goal"],
                              repro_age=agent_json["repro_age"],
                              life_force=agent_json["life_force"],
                              max_detect=agent_json["max_detect"],
                              rand_age=agent_json["age"],
                              speed=agent_json["speed"])

        else:
            logging.error("agent found whose NTYPE is neither "
                          "{} nor {}, but rather {}".format(WOLF_NTYPE,
                                                            SHEEP_NTYPE,
                                                            agent_json["ntype"]))

        if new_agent:
            self.add_agent_to_grid(new_agent, agent_json)