syslog.LOG_WARNING

Here are the examples of the python api syslog.LOG_WARNING taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

23 Examples 7

Example 1

Project: yum
Source File: yum-updatesd.py
View license
    def refreshUpdates(self):
        """Retrieve information about what updates are available."""

        self.doLock()
        try:
            self.doRepoSetup()
            self.doSackSetup()
            self.updateCheckSetup()
        except Exception, e:
            syslog.syslog(syslog.LOG_WARNING,
                          "error getting update info: %s" %(e,))
            self.emitCheckFailed("%s" %(e,))
            self.doUnlock()
            return False
        return True

Example 2

Project: runbook
Source File: __init__.py
View license
def action(**kwargs):
    try:
        return __action(**kwargs)
    except Exception, e:
        redata = kwargs['redata']
        syslog.syslog(
            syslog.LOG_WARNING,
            'http: Reaction {id} failed: {message}'.format(
                id=redata['id'], message=e.message))
        return False

Example 3

Project: backintime
Source File: logger.py
View license
def warning(msg , parent = None, traceDepth = 0):
    if DEBUG:
        msg = '%s %s' %(_debugHeader(parent, traceDepth), msg)
    print('%sWARNING%s: %s' %(bcolors.WARNING, bcolors.ENDC, msg), file=sys.stderr)
    for line in tools.wrapLine(msg):
        syslog.syslog(syslog.LOG_WARNING, 'WARNING: ' + line)

Example 4

Project: cve-portal
Source File: user.py
View license
@user_blueprint.route('/confirm')
@login_required
def resend_confirmation():
    token = current_user.generate_confirmation_token()
    send_email(current_user.email,
               'CVE-PORTAL -- Account Confirmation',
               '/emails/confirm',
               user=current_user,
               token=token)
    syslog.syslog(syslog.LOG_WARNING, "User Resend a Confirmation Email to: " + current_user.email)
    flash('A new confirmation email has been sent to you by email.', 'info')
    return redirect(url_for('main.index'))

Example 5

Project: FuzzLabs
Source File: webserver.py
View license
def api_authenticated(f):
    @wraps(f)
    def decorated_view(*args, **kwargs):
        if app.login_manager._login_disabled:
            return f(*args, **kwargs)
        elif not current_user.is_authenticated:
            syslog.syslog(syslog.LOG_WARNING,
                          "unauthenticated access from: %s" %\
                          request.remote_addr)
            return Response("error", "authenticate")
        return f(*args, **kwargs)
    return decorated_view

Example 6

Project: simplemonitor
Source File: syslogger.py
View license
    def send_alert(self, name, monitor):
        type = self.should_alert(monitor)
        if type == "failure":
            syslog.syslog(
                syslog.LOG_WARNING | syslog.LOG_USER,
                "Monitor %s failed %d times with message: %s" % (
                    name,
                    monitor.virtual_fail_count(),
                    monitor.get_result()
                )
            )

Example 7

Project: FuzzLabs
Source File: webserver.py
View license
def validate(f):
    @wraps(f)
    def validate_input(**kwargs):
        global whitelist
        url_vars = []
        for p in kwargs: url_vars.append(p)
        for key in url_vars:
            if whitelist.get(key):
                if not do_validate(key, kwargs[key]):
                    syslog.syslog(syslog.LOG_WARNING,
                                  "parameter %s failed validation from: %s" %\
                                  (key, request.remote_addr))
                    return redirect(url_for("root"))
        url_params = request.args.items()
        if len(url_params) > 0:
            for key, value in url_params:
                if key not in whitelist: continue
                if not do_validate(key, value):
                    syslog.syslog(syslog.LOG_WARNING,
                                  "parameter %s failed validation from: %s" %\
                                  (key, request.remote_addr))
                    return redirect(url_for("root"))
        if request.method == "POST":
            for key, value in request.form.iteritems():
                if not do_validate(key.encode('ascii', 'ignore'), 
                                   value.encode('ascii', 'ignore')):
                    syslog.syslog(syslog.LOG_WARNING,
                                  "parameter %s failed validation from: %s" %\
                                  (key, request.remote_addr))
                    return redirect(url_for("root"))
        return f(**kwargs)
    return validate_input

Example 8

Project: FuzzLabs
Source File: webserver.py
View license
@app.route("/api/engine", methods=['GET', 'POST'])
@api_headers
@validate
@api_authenticated
def api_engine():
    if request.method == "GET":
        engines_list = []
        engines = db.session.query(Engine)
        for engine in engines:
            if engine.owner == current_user.username:
                engine.owner = "You (" + current_user.username + ")"

            engines_list.append({
                "id": engine.id,
                "name": engine.name,
                "address": engine.address,
                "port": engine.port,
                "active": engine.active,
                "owner": engine.owner
            })

        r = Response("success", "engines", engines_list).get()
        return make_response(r, 200)

    if request.method == "POST":
        try:
            data = request.get_json()
        except Exception, ex:
            syslog.syslog(syslog.LOG_WARNING,
                          "invalid data from user %s: %s" %\
                          (current_user.username, request.remote_addr))
            r = Response("error", "Invalid data.").get()
            return make_response(r, 400)

    if not data:
        syslog.syslog(syslog.LOG_WARNING,
                      "invalid data from user %s: %s" %\
                      (current_user.username, request.remote_addr))
        r = Response("error", "Invalid data.").get()
        return make_response(r, 400)

    if not data.get('name') or not data.get('address'):
        syslog.syslog(syslog.LOG_WARNING,
                      "invalid data from user %s: %s" %\
                      (current_user.username, request.remote_addr))
        r = Response("error", "Invalid data.").get()
        return make_response(r, 400)

    port = 26000
    if data.get('port'):
        port = int(data.get('port'))
    if (port > 65535 or port < 1):
        syslog.syslog(syslog.LOG_WARNING,
                      "invalid data from user %s: %s" %\
                      (current_user.username, request.remote_addr))
        r = Response("error", "Invalid data.").get()
        return make_response(r, 400)

    if not do_validate("address", data.get('address')) or \
       not do_validate("name", data.get('name')):
        syslog.syslog(syslog.LOG_WARNING,
                      "invalid data from user %s: %s" %\
                      (current_user.username, request.remote_addr))
        r = Response("error", "Invalid data.").get()
        return make_response(r, 400)

    try:
        engine = Engine(name=data.get('name'),
                        address = data.get('address'),
                        port    = port,
                        secret  = data.get('password'),
                        active  = 1,
                        owner   = current_user.username)
        db.session.add(engine)
        db.session.commit()
    except Exception, ex:
        syslog.syslog(syslog.LOG_WARNING,
                      "failed to add engine, user %s: %s" %\
                      (current_user.username, request.remote_addr))
        r = Response("error", "Failed to add engine.").get()
        return make_response(r, 400)

    syslog.syslog(syslog.LOG_INFO,
                  "engine successfully registered by user %s: %s" %\
                  (current_user.username, request.remote_addr))
    r = Response("success", "Engine registeration successful.").get()
    return r

Example 9

Project: FuzzLabs
Source File: webserver.py
View license
@app.route("/login", methods=['GET', 'POST'])
@headers
@validate
def login():
    if request.method == "POST":
        username = request.form['username']
        password = request.form['password']

        user = db.session.query(User).filter_by(email=username).first()
        if not user:
            syslog.syslog(syslog.LOG_WARNING,
                          "invalid login request from %s" %\
                          request.remote_addr)
            return render_template('login.tpl')

        if user.is_correct_password(password):
            login_user(user)
            syslog.syslog(syslog.LOG_INFO,
                          "user %s successfully authenticated from %s" %\
                          (username, request.remote_addr))
            return redirect(url_for('root'))

        syslog.syslog(syslog.LOG_WARNING,
                      "authentication failed for user %s: %s" %\
                      (username, request.remote_addr))
        return redirect(url_for('login'))
    else:
        syslog.syslog(syslog.LOG_WARNING,
                      "invalid login request from %s" %\
                      request.remote_addr)
        return render_template('login.tpl')

Example 10

Project: amico
Source File: db_syslog.py
View license
def make_syslog_entry(cursor, dump_id):
    # Database query to get the relevant record
    cursor.execute("""
        SELECT timestamp, client, server, dst_port, host, url, referer,
            pe.sha1, pe.md5, file_size, trusted_av_labels, corrupt
        FROM pe_dumps as pe JOIN ped_vts_mapping as pvm USING(dump_id),
            virus_total_scans as vts
        WHERE dump_id = '%s'
        """ % (dump_id,))
    if cursor.rowcount == 0:
        return
    log_data = list(cursor.fetchone())
    log_data[4] = reorder_domain(log_data[4])

    cursor.execute("""
            SELECT score FROM amico_scores
            WHERE dump_id = %s """, (dump_id, ))
    report = "-"
    if cursor.rowcount > 0:
        score = cursor.fetchone()[0]
        if score is not None:
            if score > amico_threshold:
                report = "MALWARE"
            else:
                report = "BENIGN"
            report += "#%s#%s" % (score, amico_threshold)
    log_data.append(report)

    if log_data:
        #print log_data
        entry = ("PE file download -- timestamp: %s, client_ip: %s, server_ip:"
        " %s, server_port: %s, host: %s, url: %s, referrer: %s, sha1: %s, md5:"
        " %s, file_size: %s, av_labels: %s, corrupt: %s, amico_score: %s" %
            tuple(log_data))
        #     syslog.syslog(syslog.LOG_ALERT,q)
        syslog.syslog(syslog.LOG_WARNING | syslog.LOG_USER, entry)

Example 11

Project: yum
Source File: yum-updatesd.py
View license
    def updatesCheck(self):
        """Check to see whether updates are available for any
        installed packages. If updates are available, install them,
        download them, or just emit a message, depending on what
        options are selected in the configuration file.
 
        :return: whether the daemon should continue looping
        """
        if not self.didSetup:
            try:
                self.doSetup()
            except Exception, e:
                syslog.syslog(syslog.LOG_WARNING,
                              "error initializing: %s" % e)

                if isinstance(e, yum.plugins.PluginYumExit):
                    self.emitSetupFailed(e.value, e.translation_domain)
                else:
                    # if we don't know where the string is from, then assume
                    # it's not marked for translation (versus sending 
                    # gettext.textdomain() and assuming it's from the default
                    # domain for this app)
                    self.emitSetupFailed(str(e))
                # Setup failed, let's restart and try again after the update
                # interval
                restart()
            else:
                self.didSetup = True

        try:
            if not self.refreshUpdates():
                return
        except yum.Errors.LockError:
            return True # just pass for now

        try:
            self.populateTsInfo()
            self.populateUpdates()

            if self.opts.do_update:
                uit = UpdateInstallThread(self)
                uit.start()
            elif self.opts.do_download:
                self.emitDownloading()
                dl = UpdateDownloadThread(self)
                dl.start()
            else:
                # just notify about things being available
                self.emitAvailable()
                self.releaseLocks()
        except Exception, e:
            self.emitCheckFailed("%s" %(e,))
            self.doUnlock()

        return True

Example 12

Project: backintime
Source File: logger.py
View license
def deprecated(parent = None):
    frame = sys._getframe(1)
    fdir, fname = os.path.split(frame.f_code.co_filename)
    fmodule = os.path.basename(fdir)
    line = frame.f_lineno
    if parent:
        fclass = '%s.' %parent.__class__.__name__
    else:
        fclass = ''
    func = frame.f_code.co_name

    frameCaller = sys._getframe(2)
    fdirCaller, fnameCaller = os.path.split(frameCaller.f_code.co_filename)
    fmoduleCaller = os.path.basename(fdirCaller)
    lineCaller = frameCaller.f_lineno

    msg = '%s/%s:%s %s%s called from ' %(fmodule, fname, line, fclass, func)
    msgCaller = '%s/%s:%s' %(fmoduleCaller, fnameCaller, lineCaller)

    print('%sDEPRECATED%s: %s%s%s%s' %(bcolors.WARNING, bcolors.ENDC, msg, bcolors.OKBLUE, msgCaller, bcolors.ENDC), file=sys.stderr)
    syslog.syslog(syslog.LOG_WARNING, 'DEPRECATED: %s%s' %(msg, msgCaller))

Example 13

Project: cve-portal
Source File: user.py
View license
@user_blueprint.route('/change_email', methods=['GET', 'POST'])
@login_required
def change_email_request():
    form = form_class.ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            new_email = escape(form.email.data)
            token = current_user.generate_email_change_token(new_email)
            send_email(new_email,
                       'CVE-PORTAL -- Confirm your email address',
                       '/emails/change_email',
                       user=current_user,
                       token=token)
            syslog.syslog(syslog.LOG_WARNING,
                          "User as requested an email change: Old:" + current_user.email + " New: " + form.email.data)
            flash('An email with instructions to confirm your new email address has been sent to you.', 'info')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid email or password.', 'danger')
    return render_template("auth/change_email.html", form=form)

Example 14

Project: FuzzLabs
Source File: webserver.py
View license
@app.route("/api/engine/<id>/delete", methods=['GET'])
@api_headers
@validate
@api_authenticated
def api_engine_delete(id):
    try:
        engine = db.session.query(Engine).filter_by(id=id).first()
        if engine:
            db.session.delete(engine)
            db.session.commit()
    except Exception, ex:
        syslog.syslog(syslog.LOG_WARNING,
                      "failed to remove engine, user %s: %s" %\
                      (current_user.username, request.remote_addr))
        r = Response("error", "Failed to remove engine.").get()
        return r

    # If engine removed, delete all related jobs from the database.
    job = db.session.query(Job).filter(
                        Job.engine_id == id
                        ).delete()
    db.session.commit()

    syslog.syslog(syslog.LOG_INFO,
                  "engine sucessfully removed by user %s: %s" %\
                  (current_user.username, request.remote_addr))
    r = Response("success", "Engine removed.").get()
    return r

Example 15

Project: FuzzLabs
Source File: webserver.py
View license
@app.route("/api/engine/<id>/activate", methods=['GET'])
@api_headers
@validate
@api_authenticated
def api_engine_activate(id):
    try:
        engine = db.session.query(Engine).filter_by(id=id).first()
        engine.active = 1
        db.session.add(engine)
        db.session.commit()
    except Exception, ex:
        syslog.syslog(syslog.LOG_WARNING,
                      "failed to activate engine, user %s: %s" %\
                      (current_user.username, request.remote_addr))
        r = Response("error", "Failed to activate engine.").get()
        return r
    syslog.syslog(syslog.LOG_INFO,
                  "engine activated by user %s: %s" %\
                  (current_user.username, request.remote_addr))
    r = Response("success", "Engine activated.").get()
    return r

Example 16

View license
def check_config(config):
    """ checks whether the config file is correct """
    if not config.has_key("username"):
        exit_with_error("No username specified in config.")
    if config["username"] not in get_osx_usernames():
        exit_with_error(
                "Username '{username}' unknown.\nPlease use your OSX username instead.\n" \
                "If you have trouble finding it, just enter the command 'whoami'\n" \
                "in your terminal.".format(
                        username=config["username"]))
    if not config.has_key("selfcontrol-path"):
        exit_with_error("The setting 'selfcontrol-path' is required and must point to the location of SelfControl.")
    if not os.path.exists(config["selfcontrol-path"]):
        exit_with_error(
                "The setting 'selfcontrol-path' does not point to the correct location of SelfControl. " \
                "Please make sure to use an absolute path and include the '.app' extension, " \
                "e.g. /Applications/SelfControl.app")
    if not config.has_key("block-schedules"):
        exit_with_error("The setting 'block-schedules' is required.")
    if len(config["block-schedules"]) == 0:
        exit_with_error("You need at least one schedule in 'block-schedules'.")
    if config.get("host-blacklist", None) is None:
        print("WARNING:")
        msg = "It is not recommended to directly use SelfControl's blacklist. Please use the 'host-blacklist' " \
              "setting instead."
        print(msg)
        syslog.syslog(syslog.LOG_WARNING, msg)

Example 17

View license
def check_config(config):
    """ checks whether the config file is correct """
    if not config.has_key("username"):
        exit_with_error("No username specified in config.")
    if config["username"] not in get_osx_usernames():
        exit_with_error(
                "Username '{username}' unknown.\nPlease use your OSX username instead.\n" \
                "If you have trouble finding it, just enter the command 'whoami'\n" \
                "in your terminal.".format(
                        username=config["username"]))
    if not config.has_key("selfcontrol-path"):
        exit_with_error("The setting 'selfcontrol-path' is required and must point to the location of SelfControl.")
    if not os.path.exists(config["selfcontrol-path"]):
        exit_with_error(
                "The setting 'selfcontrol-path' does not point to the correct location of SelfControl. " \
                "Please make sure to use an absolute path and include the '.app' extension, " \
                "e.g. /Applications/SelfControl.app")
    if not config.has_key("block-schedules"):
        exit_with_error("The setting 'block-schedules' is required.")
    if len(config["block-schedules"]) == 0:
        exit_with_error("You need at least one schedule in 'block-schedules'.")
    if config.get("host-blacklist", None) is None:
        print("WARNING:")
        msg = "It is not recommended to directly use SelfControl's blacklist. Please use the 'host-blacklist' " \
              "setting instead."
        print(msg)
        syslog.syslog(syslog.LOG_WARNING, msg)

Example 18

Project: pycopia
Source File: logging.py
View license
def warning(msg):
    syslog.syslog(syslog.LOG_WARNING, _encode(msg))

Example 19

Project: pycopia
Source File: logging.py
View license
def loglevel_warning():
    loglevel(syslog.LOG_WARNING)

Example 20

Project: pycopia
Source File: logging.py
View license
def warning(msg):
    syslog.syslog(syslog.LOG_WARNING, _encode(msg))

Example 21

Project: pycopia
Source File: logging.py
View license
def loglevel_warning():
    loglevel(syslog.LOG_WARNING)

Example 22

Project: masakari
Source File: libvirt_eventfilter.py
View license
def warn_log(msg):
    syslogout(msg, logLevel=syslog.LOG_WARNING)

Example 23

Project: masakari
Source File: libvirt_eventfilter.py
View license
def warn_log(msg):
    syslogout(msg, logLevel=syslog.LOG_WARNING)