syslog.LOG_NOTICE

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

11 Examples 7

Example 1

Project: b2bua Source File: SipLogger.py
Function: do_write
    def do_write(self, obuf):
        try:
            syslog.syslog(syslog.LOG_NOTICE, obuf)
        except Exception, e:
            print e
            pass

Example 2

Project: mythbox Source File: test_syslog.py
    def test_emitCustomPriorityOverridesError(self):
        """
        L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} key if
        it is specified even if the event dictionary represents an error.
        """
        self.observer.emit({
                'message': ('hello, world',), 'isError': True, 'system': '-',
                'syslogPriority': stdsyslog.LOG_NOTICE,
                'failure': Failure(Exception("bar"))})
        self.assertEqual(
            self.events,
            [(stdsyslog.LOG_NOTICE, '[-] hello, world')])

Example 3

Project: subscription-manager Source File: rhsm_d.py
def main():

    log.info("rhsmd started")
    parser = OptionParser(usage=USAGE,
                          formatter=WrappedIndentedHelpFormatter())
    parser.add_option("-d", "--debug", dest="debug",
            help="Display debug messages", action="store_true", default=False)
    parser.add_option("-k", "--keep-alive", dest="keep_alive",
            help="Stay running (don't shut down after the first dbus call)",
            action="store_true", default=False)
    parser.add_option("-s", "--syslog", dest="syslog",
            help="Run standalone and log result to syslog",
            action="store_true", default=False)
    parser.add_option("-f", "--force-signal", dest="force_signal",
            help="Force firing of a signal " +
            "(valid, expired, warning, partial, classic or registration_required)")
    parser.add_option("-i", "--immediate", dest="immediate",
            action="store_true", default=False,
            help="Fire forced signal immediately (requires --force-signal)")

    options, args = parser.parse_args()

    force_signal = parse_force_signal(options.force_signal)

    if options.immediate and force_signal is None:
        print_error("--immediate must be used with --force-signal")
        sys.exit(-2)

    global enable_debug
    enable_debug = options.debug

    # short-circuit dbus initialization
    if options.syslog:
        log.info("logging subscription status to syslog")
        status = check_status(force_signal)
        if status == RHSM_EXPIRED:
            log_syslog(syslog.LOG_NOTICE,
                       "This system is missing one or more subscriptions. " +
                        "Please run subscription-manager for more information.")
        elif status == RHSM_PARTIALLY_VALID:
            log_syslog(syslog.LOG_NOTICE,
                       "This system is missing one or more subscriptions " +
                       "to fully cover its products. " +
                       "Please run subscription-manager for more information.")
        elif status == RHSM_WARNING:
            log_syslog(syslog.LOG_NOTICE,
                       "This system's subscriptions are about to expire. " +
                       "Please run subscription-manager for more information.")
        elif status == RHN_CLASSIC:
            log_syslog(syslog.LOG_INFO,
                       get_branding().RHSMD_REGISTERED_TO_OTHER)
        elif status == RHSM_REGISTRATION_REQUIRED:
            log_syslog(syslog.LOG_NOTICE,
                       "In order for Subscription Manager to provide your " +
                       "system with updates, your system must be registered " +
                       "with the Customer Portal. Please enter your Red Hat " +
                       "login to ensure your system is up-to-date.")

        # Return an exit code for the program. having valid entitlements is
        # good, so it gets an exit status of 0.
        return status

    # we are not running from cron here, so unset the excepthook
    # though, we may be running from cli, or as a dbus activation. For
    # cli, we should traceback. For dbus, we should try to log it and
    # raise dbus exception?
    sys.excepthook = sys.__excepthook__

    system_bus = dbus.SystemBus()
    loop = ga_GObject.MainLoop()
    checker = StatusChecker(system_bus, options.keep_alive, force_signal, loop)

    if options.immediate:
        checker.entitlement_status_changed(force_signal)

    loop.run()

Example 4

Project: totp-cgi Source File: command.py
Function: unenroll
def unenroll(backends):
    token = sys.argv[2]
    user = os.environ['GL_USER']
    remote_ip = os.environ['SSH_CONNECTION'].split()[0]

    ga = totpcgi.GoogleAuthenticator(backends)

    try:
        status = ga.verify_user_token(user, token)
    except Exception, ex:
        if ALLOW_BYPASS_OVERRIDE and token == 'override':
            status = "%s uses 'override'. It's super effective!" % user
            syslog.syslog(
                syslog.LOG_NOTICE, 'OVERRIDE USED: user=%s, host=%s'
            )
        else:
            logger.critical('Failed to validate token.')
            print('If using a phone app, please wait for token to change before trying again.')
            syslog.syslog(
                syslog.LOG_NOTICE,
                'Failure: user=%s, host=%s, message=%s' % (user, remote_ip, str(ex))
            )
            print_help_link()
            sys.exit(1)

    syslog.syslog(
        syslog.LOG_NOTICE,
        'Success: user=%s, host=%s, message=%s' % (user, remote_ip, status)
    )
    logger.info(status)

    # Okay, deleting
    logger.info('Removing the secrets file.')
    backends.secret_backend.delete_user_secret(user)
    # purge all old state, as it's now obsolete
    logger.info('Cleaning up state files.')
    backends.state_backend.delete_user_state(user)
    logger.info('Expiring all validations.')
    inval(expire_all=True)

    logger.info('You have been successfully unenrolled.')

Example 5

Project: totp-cgi Source File: command.py
Function: val
def val(backends, hours=24, authorize_ip=None):
    if len(sys.argv) <= 2:
        logger.critical('Missing tokencode.')
        print('You need to pass the token code as the last argument. E.g.:')
        print('    %s val [token]' % GL_2FA_COMMAND)
        print_help_link()
        sys.exit(1)

    token = sys.argv[2]
    user = os.environ['GL_USER']
    remote_ip = os.environ['SSH_CONNECTION'].split()[0]

    ga = totpcgi.GoogleAuthenticator(backends)

    try:
        status = ga.verify_user_token(user, token)
    except Exception, ex:
        if ALLOW_BYPASS_OVERRIDE and token == 'override':
            status = "%s uses 'override'. It's super effective!" % user
            syslog.syslog(
                syslog.LOG_NOTICE, 'OVERRIDE USED: user=%s, host=%s'
            )
        else:
            logger.critical('Failed to validate token.')
            print('If using a phone app, please wait for token to change before trying again.')
            syslog.syslog(
                syslog.LOG_NOTICE,
                'Failure: user=%s, host=%s, message=%s' % (user, remote_ip, str(ex))
            )
            print_help_link()
            sys.exit(1)

    syslog.syslog(
        syslog.LOG_NOTICE,
        'Success: user=%s, host=%s, message=%s' % (user, remote_ip, status)
    )
    logger.info(status)

    if authorize_ip is None:
        authorize_ip = remote_ip

    store_validation(authorize_ip, hours)

Example 6

Project: cve-portal Source File: user.py
@user_blueprint.route('/register', methods=['GET', 'POST'])
def register():
    if not current_user.is_anonymous:
        return redirect(url_for('main.index'))

    form = form_class.RegistrationForm()
    if form.validate_on_submit():
        ki = gpg.import_keys(form.pgp.data)
        if not ki.fingerprints:
            fingerp = "--- NO VALID PGP ---"
        else:
            fingerp = ki.fingerprints[0]
        user = models.User(email=escape(form.email.data),
                           name=escape(form.name.data),
                           affiliation=escape(form.affiliation.data),
                           pgp=escape(form.pgp.data),
                           password=form.password.data,
                           fingerprint=fingerp)
        models.db.session.add(user)
        models.db.session.commit()
        syslog.syslog(syslog.LOG_NOTICE, "New user registered: " + form.email.data)
        token = user.generate_confirmation_token()
        send_email(user.email,
                   'CVE-PORTAL -- Account Confirmation',
                   '/emails/confirm',
                   user=user,
                   token=token)
        flash('A confirmation email has been sent to you by email.', 'info')
        return redirect('/login')
    else:
        if form.email.data is not None:
            pass
            # syslog.syslog(syslog.LOG_ERR, "Registering Failed: Email: " + form.email.data + " Name: " + form.name.data + " Affiliation: " + form.affiliation.data)

    return render_template("auth/register.html", form=form)

Example 7

Project: pycopia Source File: logging.py
Function: notice
def notice(msg):
    syslog.syslog(syslog.LOG_NOTICE, _encode(msg))

Example 8

Project: pycopia Source File: logging.py
def loglevel_notice():
    loglevel(syslog.LOG_NOTICE)

Example 9

Project: ansible-modules-core Source File: _accelerate.py
Function: log
def log(msg, cap=0):
    global DEBUG_LEVEL
    if DEBUG_LEVEL >= cap:
        syslog.syslog(syslog.LOG_NOTICE|syslog.LOG_DAEMON, msg)

Example 10

Project: ansible-modules-core Source File: async_wrapper.py
Function: notice
def notice(msg):
    syslog.syslog(syslog.LOG_NOTICE, msg)

Example 11

Project: totp-cgi Source File: command.py
def generate_user_token(backends, mode):
    if mode == 'totp':
        gaus = totpcgi.utils.generate_secret(
            RATE_LIMIT, TOTP_WINDOW_SIZE, 5, bs=TOTP_KEY_LENGTH)

    else:
        gaus = totpcgi.utils.generate_secret(
            RATE_LIMIT, HOTP_WINDOW_SIZE, 5, bs=HOTP_KEY_LENGTH)
        gaus.set_hotp(0)

    user = os.environ['GL_USER']
    backends.secret_backend.save_user_secret(user, gaus, None)
    # purge all old state, as it's now obsolete
    backends.state_backend.delete_user_state(user)

    logger.info('New token generated for user %s' % user)
    remote_ip = os.environ['SSH_CONNECTION'].split()[0]
    syslog.syslog(
        syslog.LOG_NOTICE,
        'Enrolled: user=%s, host=%s, mode=%s' % (user, remote_ip, mode)
    )

    if mode == 'totp':
        # generate provisioning URI
        tpt = Template(TOTP_USER_MASK)
        totp_user = tpt.safe_substitute(username=user)
        qr_uri = gaus.otp.provisioning_uri(totp_user)
        import urllib
        print('')
        print('Please make sure "qrencode" is installed.')
        print('Run the following commands to display your QR code:')
        print('    unset HISTFILE')
        print('    qrencode -tANSI -m1 -o- "%s"' % qr_uri)
        print('')
        print('If that does not work or if you do not have access to')
        print('qrencode or a similar QR encoding tool, then you may')
        print('open an INCOGNITO/PRIVATE MODE window in your browser')
        print('and paste the following URL:')
        print(
            'https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=%s' %
            urllib.quote_plus(qr_uri))
        print('')
        print('Scan the resulting QR code with your TOTP app, such as')
        print('FreeOTP (recommended), Google Authenticator, Authy, or others.')

    else:
        import binascii
        import base64
        keyhex = binascii.hexlify(base64.b32decode(gaus.otp.secret))
        print('')
        print('Please make sure "ykpersonalize" has been installed.')
        print('Insert your yubikey and, as root, run the following command')
        print('to provision the secret into slot 1 (use -2 for slot 2):')
        print('    unset HISTFILE')
        print('    ykpersonalize -1 -ooath-hotp -oappend-cr -a%s' % keyhex)
        print('')

    if gaus.scratch_tokens:
        print('Please write down/print the following 8-digit scratch tokens.')
        print('If you lose your device or temporarily have no access to it, you')
        print('will be able to use these tokens for one-time bypass.')
        print('')
        print('Scratch tokens:')
        print('\n'.join(gaus.scratch_tokens))

    print

    print('Now run the following command to verify that all went well')

    if mode == 'totp':
        print('    %s val [token]' % GL_2FA_COMMAND)
    else:
        print('    %s val [yubkey button press]' % GL_2FA_COMMAND)

    print_help_link()