Changeset - 4d92fdd67af4
[Not reviewed]
default
0 3 0
Dennis Fink - 10 years ago 2015-02-16 18:42:38
dennis.fink@c3l.lu
Updated gnupg code
3 files changed with 9 insertions and 5 deletions:
0 comments (0 inline, 0 general)
ennstatus/__init__.py
Show inline comments
 
@@ -38,21 +38,22 @@ def create_app():
 

	
 
    from .status.views import status_page
 
    app.register_blueprint(status_page, url_prefix='/status')
 

	
 
    from .stats.views import stats_page
 
    app.register_blueprint(stats_page, url_prefix='/stats')
 

	
 
    from .log import init_logging
 
    init_logging(app)
 

	
 
    if 'ENNSTATUS_GPG_HOME' in app.config:
 
        gpg = gnupg.GPG(gnupghome=app.config['ENNSTATUS_GPG_HOME'])
 
        gpg.encoding = 'utf-8'
 
        app.extensions['gnupg'] = gpg
 
    else:
 
        app.extensions['gnupg'] = False
 

	
 
    @app.errorhandler(404)
 
    def page_not_found(e):
 
        return render_template('errorpages/404.html')
 

	
 
    return app
ennstatus/root/functions.py
Show inline comments
 
@@ -16,28 +16,31 @@ def send_membership_mail(form):
 
                               username=form.username.data,
 
                               email=form.email.data,
 
                               membership=form.membership.data,
 
                               c3l=form.c3l.data,
 
                               firstname=form.firstname.data,
 
                               surname=form.surname.data,
 
                               street=form.street.data,
 
                               zip=form.zip.data,
 
                               city=form.city.data,
 
                               country=form.country.data,
 
                               gpg=form.gpg.data
 
                               )
 

	
 
        current_app.logger.debug('Before encryption')
 
        current_app.logger.debug(body)
 
        if current_app.extensions['gnupg']:
 
            body = current_app.extensions['gnupg'].encrypt(body, recipient,
 
                                                           always_trust=True)
 
            body = str(current_app.extensions['gnupg'].encrypt(body, recipient,
 
                                                               always_trust=True))
 
            current_app.logger.debug('After encryption')
 
            current_app.logger.debug(body)
 
        msg.body = body
 

	
 
        mail.send(msg)
 
        flash('Application successfully sended!', 'success')
 
    except KeyError:
 
        flash('Internal server error! Please get in touch with us at info@enn.lu!', 'error')
 
        current_app.logger.error('Membership admin not found!')
 
    except AssertionError:
 
        pass
 
    except Exception as e:
 
        flash('Internal server error! Please get in touch with us at info@enn.lu!', 'error')
 
        current_app.logger.error('Unexpected error: %s' % e,
ennstatus/status/functions.py
Show inline comments
 
@@ -18,26 +18,26 @@ def _send_mail(server_name, last_updated
 
    try:
 
        if subject is None:
 
            subject = '[Ennstatus] %s went offline'
 
        msg = Message(subject % server_name,
 
                      sender='ennstatus@enn.lu')
 
        recipient = current_app.config['SERVER_ADMINS'][server_name]
 
        msg.add_recipient(recipient)
 

	
 
        body = ('%s went offline. I received the last update at %s'
 
                % (server_name, last_updated))
 

	
 
        if current_app.extensions['gnupg']:
 
            body = current_app.extensions['gnupg'].encrypt(body, recipient,
 
                                                           always_trust=True)
 
            body = str(current_app.extensions['gnupg'].encrypt(body, recipient,
 
                                                           always_trust=True))
 
        msg.body = body
 

	
 
        mail.send(msg)
 
    except KeyError:
 
        current_app.logger.error('Admin for %s not found!' % server_name)
 
    except AssertionError:
 
        pass
 
    except Exception as e:
 
        current_app.logger.error('Unexpected error: %s' % e,
 
                                 exc_info=True)
 
    current_app.logger.info('Finished trying!')
 

	
0 comments (0 inline, 0 general)