Пример #1
0
def handle_update(message):
    with context() as channels:
        updated = channels.update()
    if len(updated) > 4:
        updated = ', '.join(updated)
    else:
        updated = len(updated)
    bot.reply_to(message, 'Updated files: {}.'.format(updated))
Пример #2
0
def handle_remain(message):
    stat = []
    with context() as channels:
        for channel in channels.channels:
            stat.append('\n'.join([
                '# {}'.format(channel.rule.alias),
                'queue: {}'.format(len(channel.state.queue)),
                'sended: {}'.format(len(channel.state.sended)),
                'failed: {}'.format(len(channel.state.failed)),
            ]))
    bot.reply_to(message, '\n\n'.join(stat))
Пример #3
0
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from flask import flash, g, redirect, request

from core import app, db, sessions, api, context, get, post, template
from models import User

with context('/account'):

    @get('/login', 'Login')
    @template('/login.html')
    def login_form(next=None):
        if next is None:
            next = request.referrer

        return {'next': next}

    @post('/login')
    def login():
        next = '/'
        if 'next' in request.form:
            next = request.form['next']
        else:
Пример #4
0
from sys import argv
from core import context

aliases = argv[1:]
with context() as channels:
    for channel in channels.channels:
        if not aliases or channel.rule.alias in aliases:
            channel.send()
Пример #5
0
def handle_send(message):
    with context() as channels:
        channels.send()
    bot.reply_to(message, 'Files sended in all channels')
Пример #6
0
def handle_flush(message):
    with context() as channels:
        channels.flush()
    bot.reply_to(message, 'States is flushed')
Пример #7
0
def handle_cron(message):
    with context() as channels:
        channels.create_cron_tasks()
    bot.reply_to(message, 'Cron tasks created.')
Пример #8
0
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from flask import abort, flash, g, redirect, request
from sqlalchemy.exc import IntegrityError

from core import app, authenticate, db, sessions, api, context, get, post, template
from models import Device

with context('/devices'):

    @api('', methods=['GET'])
    @authenticate
    def api_devices_list(method):
        """List all registered devices for the current user."""
        return Device.load_by_user(g.user.id)

    @api('/register', methods=['POST'])
    @authenticate
    def api_devices_register(method, payload):
        """Register a new device."""

        if 'name' in payload:
            try:
                device = Device(g.user, payload['name'])