Exemplo n.º 1
0
from flask import jsonify, render_template, session
from ironworks import serverTools
from ironworks.updater import checkGithub, Update
import ironworks

app = serverTools.getApp()
logger = serverTools.getLogger()
COMMITS_BEHIND = serverTools.getCommitsBehind()
COMMITS_COMPARE_URL = serverTools.getCommitsCompareURL()


@app.route('/xhr/update_bar')
def xhr_update_bar():
    if 'username' in session:
        if ironworks.COMMITS_BEHIND != 0:
            return render_template('includes/update_bar.html',
                commits=ironworks.COMMITS_BEHIND,
                compare_url=ironworks.COMMITS_COMPARE_URL,
            )
        else:
            return jsonify(up_to_date=True)
    else:
        return


@app.route('/xhr/updater/check')
def xhr_update_check():
    if 'username' in session:
        check = checkGithub()
        return jsonify(update=check)
    else:
Exemplo n.º 2
0
from flask import jsonify, render_template, session
import jsonrpclib
from ironworks import serverTools
from ironworks.noneditable import *
from ironworks.tools import *

app = serverTools.getApp()
logger = serverTools.getLogger()


@app.route('/xhr/currently_playing')
def xhr_currently_playing():
    if 'username' in session:
        try:
            api_address = server_api_address()

            if not api_address:
                raise Exception

            xbmc = jsonrpclib.Server(api_address)
            active_player = xbmc.Player.GetActivePlayers()
            playerid = active_player[0]['playerid']
            player_info = xbmc.Player.GetProperties(playerid=playerid,
                                                    properties=[
                                                        'time', 'totaltime',
                                                        'position',
                                                        'percentage', 'repeat',
                                                        'shuffled'
                                                    ])
            volume = xbmc.Application.GetProperties(
                properties=['volume'])['volume']