Exemplo n.º 1
0
Arquivo: menu.py Projeto: Turante/posy
    def __init__(self, menu=[]):
        if not menu:
            base = self.base
            make_controller = self.make_controller

            def make_item(make_controller, base, name, display_name,
                    item_class=MenuItem):
                return name, item_class(make_controller, base, name,
                        display_name)

            menu = [ make_item(make_controller, base, name, value.display_name)
                     for name, value in sorted(posy_services()) ]

            menu.append(make_item(make_controller, base, 'general',
                lazy_ugettext('General'),
                GeneralSettingsItem))

        super(Menu, self).__init__(menu)
Exemplo n.º 2
0
Arquivo: root.py Projeto: TimmGit/posy
    def update_task(self, session, content, **kw):
        # Setup emailing
        email = session['settings'].get('general', {}).get('email')
        email_messages = []

        logging.debug('update_task: session: %s', session)
        logging.debug('update_task: kw: %s', kw)

        email_messages.append('content: %s' % content)
        email_messages.append('settings: %s' % session['settings'])

        for name, service in posy_services():
            if name not in session['settings']:
                message = 'No settings for service %r. Skipping.' % name
                email_messages.append(message)
                continue

            settings = session['settings'][name]

            if not settings.get('enable'):
                message = 'Service %r not enabled. Skipping.' % name
                email_messages.append(message)
                continue

            username = settings.get('username')
            if not username:
                message = 'Username for %r is not set. Skipping.' % name
                email_messages.append(message)
                continue

            password = settings.get('password')
            if not password:
                message = 'Password for %r is not set. Skipping.' % name
                email_messages.append(message)
                continue

            try:
                service(username, password or '').update(content, **kw)
            except Exception, e:
                message = 'Error updating %r: %s\n: %s' % (name, type(e), e)
                email_messages.append(message)
                logging.error(message)
Exemplo n.º 3
0
    def update_task(self, session, content, **kw):
        # Setup emailing
        email = session['settings'].get('general', {}).get('email')
        email_messages = []

        logging.debug('update_task: session: %s', session)
        logging.debug('update_task: kw: %s', kw)

        email_messages.append('content: %s' % content)
        email_messages.append('settings: %s' % session['settings'])

        for name, service in posy_services():
            if name not in session['settings']:
                message = 'No settings for service %r. Skipping.' % name
                email_messages.append(message)
                continue

            settings = session['settings'][name]

            if not settings.get('enable'):
                message = 'Service %r not enabled. Skipping.' % name
                email_messages.append(message)
                continue

            username = settings.get('username')
            if not username:
                message = 'Username for %r is not set. Skipping.' % name
                email_messages.append(message)
                continue

            password = settings.get('password')
            if not password:
                message = 'Password for %r is not set. Skipping.' % name
                email_messages.append(message)
                continue

            try:
                service(username, password or '').update(content, **kw)
            except Exception, e:
                message = 'Error updating %r: %s\n: %s' % (name, type(e), e)
                email_messages.append(message)
                logging.error(message)