How to use the cherrypy.log.error function in CherryPy

To help you get started, we’ve selected a few CherryPy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gvb / filelocker2 / src / controller / AccountController.py View on Github external
    @cherrypy.expose
    @cherrypy.tools.requires_login(permission="admin")
    def delete_attributes(self, attributeIds, format="json", **kwargs):
        user, sMessages, fMessages = (cherrypy.session.get("user"), [], [])
        try:
            attributeIdList = split_list_sanitized(attributeIds)
            for attributeId in attributeIdList:
                try:
                    delAttribute = session.query(Attribute).filter(Attribute.id==attributeId).one()
                    session.delete(delAttribute)
                    sMessages.append("Successfully deleted attribute: %s" % attributeId)
                except sqlalchemy.orm.exc.NoResultFound:
                    fMessages.append("Attribute with ID: %s does not exist" % str(attributeId))
            session.commit()
        except Exception, e:
            cherrypy.log.error("[%s] [delete_attributes] [Could not delete attributes: %s]" % (user.id, str(e)))
            fMessages.append("Unable to delete attribute: %s" % str(e))
        return fl_response(sMessages, fMessages, format)
github sandialabs / slycat / packages / slycat / web / server / handlers.py View on Github external
def validate_table_sort(sort):
    if sort is not None:
        try:
            sort = [spec.split(":") for spec in sort.split(",")]
            sort = [(column, order) for column, order in sort]
        except:
            cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                    "cherrypy.HTTPError 400 malformed order argument must be a comma separated collection of column:order tuples.")
            raise cherrypy.HTTPError(
                "400 Malformed order argument must be a comma separated collection of column:order tuples.")

        try:
            sort = [(int(column), order) for column, order in sort]
        except:
            cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                    "cherrypy.HTTPError 400 sort column must be an integer.")
            raise cherrypy.HTTPError("400 Sort column must be an integer.")

        for column, order in sort:
            if column < 0:
                cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                        "cherrypy.HTTPError 400 sort column must be non-negative.")
                raise cherrypy.HTTPError("400 Sort column must be non-negative.")
            if order not in ["ascending", "descending"]:
                cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                        "cherrypy.HTTPError 400 sort-order must be 'ascending' or 'descending'")
                raise cherrypy.HTTPError("400 Sort-order must be 'ascending' or 'descending'.")

        if len(sort) != 1:
            cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                    "cherrypy.HTTPError 400 currently, only one column can be sorted.")
github sandialabs / slycat / packages / slycat / web / server / handlers.py View on Github external
def validate_table_sort(sort):
    if sort is not None:
        try:
            sort = [spec.split(":") for spec in sort.split(",")]
            sort = [(column, order) for column, order in sort]
        except:
            cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                    "cherrypy.HTTPError 400 malformed order argument must be a comma separated collection of column:order tuples.")
            raise cherrypy.HTTPError(
                "400 Malformed order argument must be a comma separated collection of column:order tuples.")

        try:
            sort = [(int(column), order) for column, order in sort]
        except:
            cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                    "cherrypy.HTTPError 400 sort column must be an integer.")
            raise cherrypy.HTTPError("400 Sort column must be an integer.")

        for column, order in sort:
            if column < 0:
                cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                        "cherrypy.HTTPError 400 sort column must be non-negative.")
                raise cherrypy.HTTPError("400 Sort column must be non-negative.")
github sandialabs / slycat / packages / slycat / web / server / handlers.py View on Github external
def require_boolean_json_parameter(name):
    value = require_json_parameter(name)
    if value is not True and value is not False:
        cherrypy.log.error("slycat.web.server.handlers.py require_boolean_json_parameter",
                                "cherrypy.HTTPError 400 '%s' parameter must be true or false." % name)
        raise cherrypy.HTTPError("400 '%s' parameter must be true or false." % name)
    return value
github sandialabs / slycat / packages / slycat / web / server / handlers.py View on Github external
cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                    "cherrypy.HTTPError 400 sort column must be an integer.")
            raise cherrypy.HTTPError("400 Sort column must be an integer.")

        for column, order in sort:
            if column < 0:
                cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                        "cherrypy.HTTPError 400 sort column must be non-negative.")
                raise cherrypy.HTTPError("400 Sort column must be non-negative.")
            if order not in ["ascending", "descending"]:
                cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                        "cherrypy.HTTPError 400 sort-order must be 'ascending' or 'descending'")
                raise cherrypy.HTTPError("400 Sort-order must be 'ascending' or 'descending'.")

        if len(sort) != 1:
            cherrypy.log.error("slycat.web.server.handlers.py validate_table_sort",
                                    "cherrypy.HTTPError 400 currently, only one column can be sorted.")
            raise cherrypy.HTTPError("400 Currently, only one column can be sorted.")

    return sort
github sandialabs / slycat / packages / slycat / web / server / remote.py View on Github external
def get_file(self, path, **kwargs):
        cache = kwargs.get("cache", None)
        project = kwargs.get("project", None)
        key = kwargs.get("key", None)

        # Sanity-check arguments.
        if cache not in [None, "project"]:
            cherrypy.log.error("slycat.web.server.remote.py get_file",
                                    "cherrypy.HTTPError 400 unknown cache type: %s." % cache)
            raise cherrypy.HTTPError("400 Unknown cache type: %s." % cache)
        if cache is not None:
            if project is None:
                cherrypy.log.error("slycat.web.server.remote.py get_file",
                                        "cherrypy.HTTPError 400 must specify project ID.")
                raise cherrypy.HTTPError("400 Must specify project id.")
            if key is None:
                cherrypy.log.error("slycat.web.server.remote.py get_file",
                                        "cherrypy.HTTPError 400 must specify cache key.")
                raise cherrypy.HTTPError("400 Must specify cache key.")

        # Use the agent to retrieve a file.
        if self._agent is not None:
            stdin, stdout, stderr = self._agent
            try:
                cherrypy.log.error(json.dumps({"action": "get-file", "path": path}))
                stdin.write("%s\n" % json.dumps({"action": "get-file", "path": path}))
                stdin.flush()
            except socket.error as e:
                delete_session(self._sid)
github sandialabs / slycat / packages / slycat / web / server / plugin.py View on Github external
slycat.email.send_error("slycat.web.server.plugin.py register_wizard", "Wizard '%s' has already been registered." % (type))
      raise Exception("Wizard '%s' has already been registered." % (type))
    if "action" not in require:
      slycat.email.send_error("slycat.web.server.plugin.py register_wizard", "Wizard '%s' must specify an action." % (type))
      raise Exception("Wizard '%s' must specify an action." % (type))
    if require["action"] not in ["create", "edit", "info", "delete"]:
      slycat.email.send_error("slycat.web.server.plugin.py register_wizard", "Wizard '%s' unknown action: %s." % (type, require["action"]))
      raise Exception("Wizard '%s' unknown action: %s." % (type, require["action"]))
    if "context" not in require:
      slycat.email.send_error("slycat.web.server.plugin.py register_wizard", "Wizard '%s' must specify a context." % (type))
      raise Exception("Wizard '%s' must specify a context." % (type))
    if require["context"] not in ["global", "project", "model"]:
      slycat.email.send_error("slycat.web.server.plugin.py register_wizard", "Wizard '%s' unknown context: %s." % (type, require["context"]))
      raise Exception("Wizard '%s' unknown context: %s." % (type, require["context"]))
    self.wizards[type] = {"label": label, "require": require}
    cherrypy.log.error("Registered wizard '%s'." % (type))
github sandialabs / slycat / packages / slycat / web / server / upload.py View on Github external
try:
      # adding this check for backwards compatibility 
      # new way self._aids[0] is the file name being added to the model and hdf5
      # self._aids[1] is the name of the file being pushed to the project_data data object
        if isinstance(self._aids[0], list):
          slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input,
                                                                          files, self._aids[0], **self._kwargs)
        else:
          slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input,
                                                                          files, self._aids, **self._kwargs)
        slycat.web.server.handlers.create_project_data(self._mid, self._aids, files)
      except Exception as e:
        cherrypy.log.error("Exception parsing posted files: %s" % e)
        import traceback
        cherrypy.log.error(traceback.format_exc())
      cherrypy.log.error("Upload parsing finished.")
github sandialabs / slycat / packages / slycat / web / server / cache.py View on Github external
"""
    Removes the cache item keyed by `key` from the file system.
    """
    # cherrypy.log.error("[CACHE] trying to remove %s from file system cache" % digest)
    # digest = self.digest_hash(key)
    path = os.path.join(self._fs_cache_path, digest)
    if os.path.exists(path):
      # cherrypy.log.error("[CACHE] removing %s from file system cache" % path)
      try:
        os.remove(path)
      except:
        msg = "[CACHE] No object for key `%s` stored." % str(path)
        cherrypy.log.error(msg)
    else:
      msg = "[CACHE] No object for key `%s` stored." % str(path)
      cherrypy.log.error(msg)
github kakwa / ldapcherry / ldapcherry / __init__.py View on Github external
def logout(self):
        """ logout page
        """
        sess = cherrypy.session
        username = sess.get(SESSION_KEY, None)
        sess[SESSION_KEY] = None
        if username:
            cherrypy.request.login = None

        cherrypy.log.error(
            msg="user '%(user)s' logout" % {'user': username},
            severity=logging.INFO
        )
        raise cherrypy.HTTPRedirect("/signin")