Exemple #1
0
    def __init__(self, name, addon_id, filepath):
        self._name = name
        self._filepath = filepath
        self._addon_id = addon_id
        self._routes = []
        self._view_functions = {}
        self._addon = xbmcaddon.Addon(id=self._addon_id)

        # Keeps track of the added list items
        self._current_items = []

        # Gets initialized when self.run() is called
        self._request = None

        # A flag to keep track of a call to xbmcplugin.endOfDirectory()
        self._end_of_directory = False

        # The plugin's named logger
        self._log = setup_log(addon_id)

        # The path to the cache directory for the addon
        self._cache_path = xbmc.translatePath(
            'special://profile/addon_data/%s/.cache/' % self._addon_id)

        # If we are runing in CLI, we need to load the strings.xml manually
        # TODO: a better way to do this. Perhaps allow a user provided filepath
        if xbmcswift2.CLI_MODE:
            from xbmcswift2.mockxbmc import utils
            utils.load_addon_strings(self._addon,
                os.path.join(os.path.dirname(self._filepath), 'resources',
                             'language', 'English', 'strings.xml'))
    def __init__(self, name=None, addon_id=None, filepath=None, info_type=None):
        self._name = name
        self._routes = []
        self._view_functions = {}

        # addon_id is no longer required as it can be parsed from addon.xml
        if addon_id:
            self._addon = xbmcaddon.Addon(id=addon_id)
        else:
            self._addon = xbmcaddon.Addon()

        self._addon_id = addon_id or self._addon.getAddonInfo('id')
        self._name = name or self._addon.getAddonInfo('name')

        self._info_type = info_type
        if not self._info_type:
            types = {
                'video': 'video',
                'audio': 'music',
                'image': 'pictures',
            }
            self._info_type = types.get(self._addon_id.split('.')[1], 'video')

        # Keeps track of the added list items
        self._current_items = []

        # Gets initialized when self.run() is called
        self._request = None

        # A flag to keep track of a call to xbmcplugin.endOfDirectory()
        self._end_of_directory = False

        # Keep track of the update_listing flag passed to
        # xbmcplugin.endOfDirectory()
        self._update_listing = False

        # The plugin's named logger
        self._log = setup_log(self._addon_id)

        # The path to the storage directory for the addon
        self._storage_path = self.addon_data_path(".storage/")
        from xbmcswift2.common import direxists
        if not direxists(self._storage_path):
            xbmcvfs.mkdirs(self._storage_path)

        # If we are runing in CLI, we need to load the strings.xml manually
        # Since xbmcswift2 currently relies on execution from an addon's root
        # directly, we can rely on cwd for now...
        if xbmcswift2.CLI_MODE:
            from xbmcswift2.mockxbmc import utils

            if filepath:
                addon_dir = os.path.dirname(filepath)
            else:
                addon_dir = os.getcwd()
            strings_fn = os.path.join(addon_dir, 'resources', 'language',
                                      'English', 'strings.xml')
            utils.load_addon_strings(self._addon, strings_fn)
Exemple #3
0
    def __init__(self, name=None, addon_id=None, filepath=None, info_type=None):
        self._name = name
        self._routes = []
        self._view_functions = {}

        # addon_id is no longer required as it can be parsed from addon.xml
        if addon_id:
            self._addon = xbmcaddon.Addon(id=addon_id)
        else:
            self._addon = xbmcaddon.Addon()

        self._addon_id = addon_id or self._addon.getAddonInfo('id')
        self._name = name or self._addon.getAddonInfo('name')

        self._info_type = info_type
        if not self._info_type:
            types = {
                'video': 'video',
                'audio': 'music',
                'image': 'pictures',
            }
            self._info_type = types.get(self._addon_id.split('.')[1], 'video')

        # Keeps track of the added list items
        self._current_items = []

        # Gets initialized when self.run() is called
        self._request = None

        # A flag to keep track of a call to xbmcplugin.endOfDirectory()
        self._end_of_directory = False

        # Keep track of the update_listing flag passed to
        # xbmcplugin.endOfDirectory()
        self._update_listing = False

        # The plugin's named logger
        self._log = setup_log(self._addon_id)

        # The path to the storage directory for the addon
        self._storage_path = xbmc.translatePath(
            'special://profile/addon_data/%s/.storage/' % self._addon_id)
        if not os.path.isdir(self._storage_path):
            os.makedirs(self._storage_path)

        # If we are runing in CLI, we need to load the strings.xml manually
        # Since xbmcswift2 currently relies on execution from an addon's root
        # directly, we can rely on cwd for now...
        if xbmcswift2.CLI_MODE:
            from xbmcswift2.mockxbmc import utils
            if filepath:
                addon_dir = os.path.dirname(filepath)
            else:
                addon_dir = os.getcwd()
            strings_fn = os.path.join(addon_dir, 'resources', 'language',
                                      'English', 'strings.xml')
            utils.load_addon_strings(self._addon, strings_fn)
Exemple #4
0
                        "keep off of Pi's SD card.")
    parser.add_argument('audio_dir',
                        type=str,
                        help="directory wth the mp3 songs in it")
    parser.add_argument('lightning_rpc',
                        type=str,
                        help="c-lightning daemon rpc file")
    parser.add_argument(
        'blockchain_device',
        type=str,
        help="device holding the blockchain for monitoring I/O")
    parser.add_argument('blockchain_dir',
                        type=str,
                        help="dir holding the blockchain for monitoring size")
    args = parser.parse_args()
    setup_log(args.console, args.log_file)

    assert os.path.exists(args.audio_dir), "audio dir doesn't exist?"
    assert os.path.isdir(args.audio_dir), "audio dir not a dir?"
    assert os.path.exists(args.lightning_rpc), "rpc file doesn't exist?"
    assert os.path.exists("/dev/" + args.blockchain_device), ("device doesn't "
                                                              "exist?")
    assert os.path.exists(args.blockchain_dir), "blockchain dir doesn't exist?"
    assert os.path.isdir(args.blockchain_dir), "blockchain dir not a dir?"
    log("hello")

    r = reactor
    # setup urwid screen output
    sui = ScreenUI(r, args.console)
    # listen on ZMQ for new blocks
    queue = NewBlockQueue(r, sui, AudioPlayer(),
Exemple #5
0
from utils import load_config
from logger import setup_log
from flask import Flask, request, render_template, session, redirect, url_for,Blueprint
from utils import mysql
import math
import json
from engine import RecommendationEngine
main = Blueprint('app', __name__)

config = load_config()
logger = setup_log(__name__)
# main = Flask(__name__)
nextbook = 1;
nextuser = 1;

mysql = mysql(config['mysql'])

@main.route("/")
def root():
    """
    主页
    :return: home.html
    """
    login, userid = False, ''
    if 'userid' in session:
        login, userid = True, session['userid']
    # 热门书籍
    hot_books = []
    # sql: SELECT BookID,sum(Rating) as score FROM Book.Bookrating group by BookID order by score desc limit 10;
    sql = "SELECT BookTitle, BookAuthor ,BookID, ImageM FROM Books where BookID = '" + \
          "' or BookID = '".join(config['bookid']) + "'"
Exemple #6
0
    cronjob_config = config_obj.cronjob

    return trello_config, notification_config, cronjob_config


def setup_trello_oath1(trello_config):
    trello_api_key = trello_config.apiKey
    trello_secret_key = trello_config.secretKey
    trello_oath = OAuth1(trello_api_key, client_secret=trello_secret_key)
    return trello_oath


if __name__ == "__main__":
    trello_config, notification_config, cronjob_config = parse_arguments()

    setup_log('incident-guard')

    trello_oath = setup_trello_oath1(trello_config)

    setup_proxies(trello_config, trello_oath)

    notifications = [
        create_notification(noti_config[0], noti_config[1])
        for noti_config in list(notification_config.items())
    ]
    setup_notifications(notifications)

    @sched.scheduled_job('cron',
                         day_of_week=cronjob_config.dayOfWeek,
                         timezone='asia/ho_chi_minh',
                         hour=cronjob_config.hour,
Exemple #7
0
def init_log(log_obj):
  global log
  setup_log(log_obj)
  log = get_logger()