Пример #1
0
def get_default_book_status():
    """Returns the default book status"""

    status_list = config.get_configuration('CHAPTER_STATUS_LIST')
    default_status = config.get_configuration('CHAPTER_STATUS_DEFAULT',
                                              status_list[0]['name'])
    return default_status
Пример #2
0
def is_book_limit_reached():
    """
    Checks if maximum number of books is reaced.

    @rtype text: C{book}
    @param: Returns True if maximum number of books is reached
    """

    max_books = config.get_configuration('BOOKTYPE_MAX_BOOKS')

    if not isinstance(max_books, int):
        # We should show some kind of warning here
        return False

    # 0 means unlimited and that is the default value
    if max_books == 0:
        return False

    # get list of all active books
    num_books = models.Book.objects.all().count()

    if num_books >= max_books:
        return True

    return False
Пример #3
0
    async def on_ready(self):
        for guild in self.guilds:

            await log(self, guild, "Je viens de redémarrer.")

            config = get_configuration(guild.id)

            if config["RUN_SYNC_ON_STARTUP"]:
                for member in guild.members:
                    if config["NEWUSER_ROLE_NAME"] in [
                            role.name for role in member.roles
                    ]:
                        h = (datetime.now() -
                             member.joined_at).total_seconds() / 60 / 60
                        if h >= 72:
                            await member.kick(
                                reason="Pas de signes de vie depuis " +
                                str(int(h / 24)) + " jours")
                            await log(self, member.guild,
                                      "J'expulse " + member.mention)
                        else:
                            asyncio.ensure_future(
                                set_user_region(self,
                                                member,
                                                rappel=int(h / 24),
                                                just_wait=True))

                await refresh_geoloc_list(self, guild)
Пример #4
0
async def contact_modos(self, guild, message):
    config = get_configuration(guild.id)

    admin = self.get_user(config["ADMIN_ID"])
    modo_channel = discord.utils.find(
        lambda c: c.name == config["MODO_CHANNEL"], guild.channels)
    modo_role = discord.utils.find(lambda r: r.name == config["MODO_ROLE"],
                                   guild.roles)

    if not modo_channel:
        await admin.send(
            "\N{WARNING SIGN} Le salon '" + config["MODO_CHANNEL"] +
            "' n'existe pas, je ne peux plus contacter les modérateurs alors je m'adresse à toi."
        )
    elif not guild.me.permissions_in(modo_channel).send_messages:
        modo_channel = None
        await admin.send(
            "\N{WARNING SIGN} Je n'ai plus le droit d'écrire dans #" +
            config["MODO_CHANNEL"] + " du serveur " + guild.name +
            " donc je ne peux plus contacter les modérateurs donc je m'adresse à toi."
        )

    if modo_channel:
        if modo_role:
            await modo_channel.send(modo_role.mention + ", " + message)
        else:
            await modo_channel.send(
                "Erreur : je ne peux pas mentionner les modérateurs car le rôle @"
                + config["MODO_ROLE"] + " a disparu.")
            await modo_channel.send(message)
    else:
        await admin.send(message)
Пример #5
0
def is_book_limit_reached():
    """
    Checks if maximum number of books is reaced.

    @rtype text: C{book}
    @param: Returns True if maximum number of books is reached
    """

    max_books = config.get_configuration('BOOKTYPE_MAX_BOOKS')

    if not isinstance(max_books, int):
        # We should show some kind of warning here
        return False

    # 0 means unlimited and that is the default value
    if max_books == 0:
        return False

    # get list of all active books
    num_books = models.Book.objects.all().count()

    if num_books >= max_books:
        return True

    return False
Пример #6
0
def main():
    (bag, nod_src, features_sink, start_time,
     window_duration) = get_configuration()
    camera_source_1, camera_source_2, camera_source_3 = nod_src[0], nod_src[
        1], nod_src[2]
    # check if context is a bag,
    #with conditional(bag, bag):
    with camera_source_1, camera_source_2, camera_source_3:
        # synchronize three camera sources
        sync = Synchronizer(
            [camera_source_1, camera_source_2, camera_source_3])

        # extract features from respective cameras independent of one another
        nod_feature_extractor_1 = Nod_Info_Extractor(camera_source_1,
                                                     start_time,
                                                     window_duration)
        nod_feature_extractor_2 = Nod_Info_Extractor(camera_source_2,
                                                     start_time,
                                                     window_duration)
        nod_feature_extractor_3 = Nod_Info_Extractor(camera_source_3,
                                                     start_time,
                                                     window_duration)

        # extract msgs one by one from the synchronized source
        for msg_1, msg_2, msg_3 in sync:
            nod_msg_1 = msg_1[0][0]
            nod_msg_2 = msg_2[0][0]
            nod_msg_3 = msg_3[0][0]
            nod_feature_extractor_1.extract_features_from_source(
                nod_msg_1.head_pose, nod_msg_1.header.stamp)
            nod_feature_extractor_2.extract_features_from_source(
                nod_msg_2.head_pose, nod_msg_2.header.stamp)
            nod_feature_extractor_3.extract_features_from_source(
                nod_msg_3.head_pose, nod_msg_3.header.stamp)
Пример #7
0
def is_user_limit_reached():
    """
    Checks if maximum number of user is reached.

    @rtype text: C{book}
    @param: Returns True if maximum number of users is reached
    """

    max_users = config.get_configuration('BOOKTYPE_MAX_USERS')

    if not isinstance(max_users, int):
        # We should show some kind of warning here
        return False

    # 0 means unlimited and that is the default value
    if max_users == 0:
        return False

    # get list of all active accounts
    num_users = User.objects.filter(is_active=True).count()

    if num_users >= max_users:
        return True

    return False
Пример #8
0
def main(arg):
    app = Flask(__name__)
    app.register_blueprint(REST_blueprint())
    app.config.update(get_configuration("config.json", "DEFAULT"))
    socketio = SocketIO(app)
    route_socketio(socketio)
    socketio.run(app, host=app.config["HOST"], port=app.config["PORT"])
Пример #9
0
def is_user_limit_reached():
    """
    Checks if maximum number of user is reached.

    @rtype text: C{book}
    @param: Returns True if maximum number of users is reached
    """

    max_users = config.get_configuration('BOOKTYPE_MAX_USERS')

    if not isinstance(max_users, int):
        # We should show some kind of warning here
        return False

    # 0 means unlimited and that is the default value
    if max_users == 0:
        return False

    # get list of all active accounts
    num_users = User.objects.filter(is_active=True).count()

    if num_users >= max_users:
        return True

    return False
Пример #10
0
def quit_flukebox():
    """ Quit FlukeBox """
    config = get_configuration()
    if "flukebox" not in config:
        return
    if "quit_url" not in config["flukebox"]:
        return
    subprocess.call(["curl", config["flukebox"]["quit_url"]])
Пример #11
0
    def execute(self, engine = ExecutionEngineFactory.get_best_engine()):
        config = get_configuration()
        log_setting = config.get("logging", None)
        if log_setting == "stderr":
            log_to_stderr()

        engine.set_graph(self.job_graph)
        return engine.execute()
Пример #12
0
async def refresh_geoloc_list(self, guild):
    config = get_configuration(guild.id)

    display_channel = discord.utils.find(
        lambda m: m.name == config["GEOLOC_DISPLAY_CHANNEL"], guild.channels)

    if display_channel == None:
        await contact_modos(
            self, guild, "Erreur: je ne peux pas afficher la liste dans *" +
            config["GEOLOC_DISPLAY_CHANNEL"] + "* car le salon n'existe pas.")
        return
    elif not guild.me.permissions_in(display_channel).send_messages:
        await contact_modos(
            self, guild, "Erreur: je ne peux pas afficher la liste dans " +
            display_channel.mention +
            " car je n'ai pas les permission d'y écrire.")
        return

    async for message in display_channel.history(limit=len(departements) + 30,
                                                 oldest_first=True):
        if message.author.id != self.user.id:
            await message.delete()
            continue

        if message.content == "":  # embed
            try:
                departement_code = message.embeds[0].title.split(" ")[0]
            except AttributeError:
                await message.delete()
                continue

            role = discord.utils.find(
                lambda r: r.name.startswith(departement_code + " -"),
                guild.roles)
            if not role:
                await contact_modos(
                    self, guild, "le rôle **" + departement_code + " - " +
                    departements[departement_code]["name"] +
                    "** n'existe plus !!")
                return
            if len(role.members) == 0:
                txt = "Personne \N{DISAPPOINTED BUT RELIEVED FACE}"
            else:
                txt = " | ".join(sorted([str(user) for user in role.members]))
                if len(txt) > 2048:
                    txt = txt[:2042] + " [...]"

            if txt != message.embeds[0].description:
                await log(
                    self, guild, "Je modifie la liste **" + departement_code +
                    " - " + departements[departement_code]["name"] + "**")
                embed = discord.Embed(title=departement_code + " - " +
                                      departements[departement_code]["name"],
                                      description=txt,
                                      color=0x50bdfe)
                await message.edit(embed=embed)
Пример #13
0
 async def on_message(self, message):
     config = None
     if message.guild:
         config = get_configuration(message.guild.id)
     if config:
         geoloc_command = config["GEOLOC_COMMAND_NAME"]
         if message.content.startswith(geoloc_command):
             await set_user_region(self, message.author)
             if config["REMOVE_GEOLOCS_MESSAGES"]:
                 await message.delete()
Пример #14
0
 async def on_member_remove(member):
     config = get_configuration(member.guild.id)
     if config["GOODBYE_ANOUNCE"]:
         chan = discord.utils.get(member.guild.channels,
                                  name=config["GOODBYE_CHANNEL"])
         if chan:
             await chan.send("Au revoir " + member.mention)
         else:
             await contact_modos(
                 self, member.guild,
                 "Erreur: le salon **" + config["GOODBYE_CHANNEL"] +
                 "** n'existe pas pour dire au revoir.")
Пример #15
0
def get_external_metronome_helper(bpm: int) -> ExerciseHelper:
    """ Returns a metronome helper Exercise """
    config = get_configuration()
    if "metronome_app" not in config:
        return None
    command = config["metronome_app"]["path"].replace(" ", "\ ")  #pylint: disable=W1401
    command = "open " + command
    output = ExerciseHelper(ExerciseHelperType.OS_COMMAND, {
        "command": command,
        "clipboard": str(bpm)
    })
    return output
    def __init__(self, **kwargs):
        super(Metronome, self).__init__(**kwargs)

        self._config = get_configuration()
        self._bpm = self._config["default_bpm"]
        self._playing = False
        self._click = self._load_bpm_file()

        #self._metronome_label = Label()
        #self._metronome_label.text = "Metronome"

        self._btn_decrease = Button()
        self._btn_decrease.text = "-"
        self._btn_decrease.bind(on_press=self._btn_decrease_clicked)  # pylint: disable=E1101

        self._btn_decrease2 = Button()
        self._btn_decrease2.text = "--"
        self._btn_decrease2.bind(on_press=self._btn_decrease2_clicked)  # pylint: disable=E1101

        self._btn_decrease3 = Button()
        self._btn_decrease3.text = "<<"
        self._btn_decrease3.bind(on_press=self._btn_decrease3_clicked)  # pylint: disable=E1101

        self._bpm_label = Label()
        self._refresh_bpm_label()

        self._btn_play = Button()
        self._btn_play.text = "Play/Stop"
        self._btn_play.bind(on_press=self._btn_play_clicked)  # pylint: disable=E1101

        self._btn_increase = Button()
        self._btn_increase.text = "+"
        self._btn_increase.bind(on_press=self._btn_increase_clicked)  # pylint: disable=E1101

        self._btn_increase2 = Button()
        self._btn_increase2.text = "++"
        self._btn_increase2.bind(on_press=self._btn_increase2_clicked)  # pylint: disable=E1101

        self._btn_increase3 = Button()
        self._btn_increase3.text = ">>"
        self._btn_increase3.bind(on_press=self._btn_increase3_clicked)  # pylint: disable=E1101

        self.cols = 8
        #self.add_widget(self._metronome_label)
        self.add_widget(self._btn_decrease3)
        self.add_widget(self._btn_decrease2)
        self.add_widget(self._btn_decrease)
        self.add_widget(self._bpm_label)
        self.add_widget(self._btn_play)
        self.add_widget(self._btn_increase)
        self.add_widget(self._btn_increase2)
        self.add_widget(self._btn_increase3)
Пример #17
0
def get_flukebox_helper(playlist: str,
                        no_local: bool = False) -> ExerciseHelper:
    """ Returns a FlukeBox helper Exercise """
    config = get_configuration()
    if "flukebox" not in config:
        return None

    command = f"cd {config['flukebox']['path']} ;" \
              f" venv/bin/python3 main.py playlist={config['flukebox'][playlist]}" \
              f"{' no_local' if no_local else ''}"

    output = ExerciseHelper(ExerciseHelperType.OS_COMMAND,
                            {"command": command})
    return output
Пример #18
0
def has_book_limit(user):
    """
    Checks if user reached book limit.

    @rtype text: C{user}
    @param: Returns True if user reached book limit
    """
    if not user.is_authenticated():
        return True

    if user.is_superuser:
        return False

    book_limit = config.get_configuration(
        'BOOKTYPE_BOOKS_PER_USER')['limit_global']

    user_limit = filter(
        lambda item: item['username'] == user.username,
        config.get_configuration('BOOKTYPE_BOOKS_PER_USER')['limit_by_user'])

    if user_limit:
        book_limit = user_limit[0]['limit']

    return models.Book.objects.filter(owner=user).count() >= book_limit != -1
Пример #19
0
    async def on_member_join(self, member):
        config = get_configuration(member.guild.id)

        if config["ADD_NEWUSER_ROLE"]:
            role = discord.utils.get(member.guild.roles,
                                     name=config["NEWUSER_ROLE_NAME"])
            if role:
                if not role in member.roles:
                    await member.add_roles(role)
            else:
                await contact_modos(
                    self, member.guild,
                    "Ereur: le rôle " + config["NEWUSER_ROLE_NAME"] +
                    " n'existe plus ou a changé de nom.")

        await set_user_region(self, member, first_time=True)
Пример #20
0
def get_random_guitar() -> dict:
    """ Returns a random guitar """
    config = get_configuration()
    storage = get_storage()

    while True:
        random_number = random.randint(1, 100)
        for guitar in config["instruments"]:
            if guitar["from"] <= random_number and guitar[
                    "to"] >= random_number:
                if guitar["type"] != storage["last_instrument"]:
                    storage["last_instrument"] = guitar["type"]
                    save_storage(storage)
                    return guitar

    raise Exception("Couldn't select an instrument")
Пример #21
0
def main():

    cfg = config.get_configuration()
    params = config.get_training_parameters()
    env = simplePendulum.PendulumEnv()

    params.update({
        "default_action_index":
        np.where(env.get_discrete_action_space() == 0)[0][0]
    })

    # run_sarsa(env, cfg, params)
    run_sarsa_lambda(env, cfg, params)

    plot_policy(env, "sarsa_lambda", params)
    run_policy(env, "sarsa_lambda", params)
def main():
    (bag, gaze_sources, features_sink, start_time,
     window_duration) = get_configuration()
    camera_source_1, camera_source_2, camera_source_3 = nod_src[0], nod_src[
        1], nod_src[2]
    jibo = Jibo([0, 0, 0])
    camera1 = Camera('camera1', [90, -254, 36], -20.0, 54.462)
    camera2 = Camera('camera2', [230, 4, 36], -20.0, 0)
    camera3 = Camera('camera3', [85, 247, 36], -20.0, 326.301)
    with camera_source_1, camera_source_2, camera_source_3, features_sink:
        sync = Synchronizer([camera1topic, camera2topic, camera3topic])
        for (face_info_1, face_info_2, face_info_3) in sync:
            poses = []
            for x in (face_info_1, face_info_2, face_info_3):
                msg = convert_ros_message_to_dictionary(x[0][0])
                if msg['detected'] == 1:
                    poses.append(msg['head_pose'])
            if len(poses) == 2:
                pose1, pose2 = poses[0], poses[1]
                p1 = Face(camera1, [pose1['x'], pose1['y'], pose1['z']],
                          pose1['rot_x'], pose1['rot_y'], pose1['rot_z'])
                p1.convertFaceFromLocalToWorldSpace()
                p2 = Face(camera2, [pose2['x'], pose2['y'], pose2['z']],
                          pose2['rot_x'], pose2['rot_y'], pose2['rot_z'])
                rospy.loginfo(p1.position)
                rospy.loginfo(p2.position)
            if len(poses) == 3:
                pose1, pose2, pose3 = poses[0], poses[1], poses[2]
                p1 = Face(camera1, [pose1['x'], pose1['y'], pose1['z']],
                          pose1['rot_x'], pose1['rot_y'], pose1['rot_z'])
                p2 = Face(camera2, [pose2['x'], pose2['y'], pose2['z']],
                          pose2['rot_x'], pose2['rot_y'], pose2['rot_z'])
                p3 = Face(camera3, [pose3['x'], pose3['y'], pose3['z']],
                          pose3['rot_x'], pose3['rot_y'], pose3['rot_z'])
                p1.convertFaceFromLocalToWorldSpace()
                p2.convertFaceFromLocalToWorldSpace()
                p3.convertFaceFromLocalToWorldSpace()
                # the following is how to access position of the face after converting from local to world space
                # you can test this out by checking two cameras at a time whether a face visible in both cameras is the same position
                rospy.loginfo(p1.position[0])
                rospy.loginfo(p2.position[0])
                rospy.loginfo(p3.position[0])
Пример #23
0
async def log(self, guild, message):
    config = get_configuration(guild.id)
    with open("logs.txt", "a") as f:
        f.write(
            time.strftime('[%d/%m/%Y %H:%M:%S] ', time.localtime()) +
            guild.name + " : " + message + "\n")

    if config["LOG_CHANNEL"]:
        channel = discord.utils.find(lambda c: c.name == config["LOG_CHANNEL"],
                                     guild.channels)
        if channel:
            if guild.me.permissions_in(channel).send_messages:
                await channel.send(
                    embed=discord.Embed(description=message, color=0x50bdfe))
            else:
                await contact_modos(
                    self, guild,
                    "Erreur: je n'ai pas la permission d'écrire dans " +
                    channel.mention)
        else:
            await contact_modos(
                self, guild, "Erreur: le salon **#" + config["LOG_CHANNEL"] +
                "** n'existe pas.")
Пример #24
0
    def next_step(self):
        """ Goes to the next step """
        prev_exercise_index = self._workout.get_exercise_index()
        try:
            next_exer, next_step = self._workout.get_next_step()
        except Exception:
            return

        if next_exer is None or next_step is None:
            self._buttons.set_next_enabled(False)
            self._exercise_main_label.text = ""
            self._exercise_sub_label.text = ""
            self._step_main_label.text = "Finished!"
            self._step_sub_label.text = "Now play freestyle for fun!"

            flukebox = get_flukebox_helper("final_playlist")
            if flukebox is not None:
                self._process_helpers([flukebox])

            fconfig = config.get_configuration()
            if "final_url" in fconfig and fconfig["final_url"] != "":
                webbrowser.open(fconfig["final_url"])

            sys.exit()

        else:
            if prev_exercise_index != self._workout.get_exercise_index():
                quit_flukebox()
                self._helper_buttons.reset_buttons()
                self._paint_exercise()
            self._paint_exercise_step()
            self._refresh_status_text()

        if self._open_guitar_apps:
            self._open_guitar_apps = False
            for app in self._guitar["apps"]:
                subprocess.call(["open", app])
Пример #25
0
import random
from config import get_configuration
from game import *

first_player, expansions = get_configuration()

number_of_non_random_cards = sum(expansion.number_of_cards
                                 for expansion in expansions)
if number_of_non_random_cards > 10:
    raise Exception("Too many cards defined")

print()
print("Creating game with random cards from:", end=" [")
print(", ".join(expansion.name for expansion in expansions) + "]")
print("Player", first_player, "goes first")
print()
for _ in range(10 - number_of_non_random_cards):
    random.choice(expansions).number_of_cards += 1

cards = []
for expansion in expansions:
    cards.append(expansion.draw())
Game("Random Cards", list(filter(lambda card: card, cards))).print()
"""
import json
import re
def p(name, first, second, first_cards, second_cards):
    first_cards = json.dumps("\", \"".join(re.compile("\t+").split(first_cards.strip()))).replace("\\", "")
    second_cards = json.dumps("\", \"".join(re.compile("\t+").split(second_cards.strip()))).replace("\\", "")
    print("    Game(\"" + name + "\",")
    print("         [ExpansionCards(name=" + first + ",")
 def __init__(self):
     super().__init__()
     self._select_guitar = True
     self.guitar = {}
     self._config = get_configuration()
Пример #27
0
params={}
current_cookie=''
current_cookie_decoded=''
new_request=1
server=''
server_set=False
data_pool=''
#login_url='http://localhost/openit/login.php'
#logout_url='http://localhost/openit/logout.php'
#login_url='http://localhost/scarf/login.php'
#logout_url='http://localhost/scarf/login.php?logout=1'
#login_url='http://localhost/users/login.php'
#logout_url='http://localhost/users/logout.php'
#login_field=' '
#login_pass_field=' '
login_url,logout_url,login_field,login_pass_field,num_roles=get_configuration()
s=[]
state_set=[]
transition_set=[]
authorized=False
role_set=[]
role_id=0
f=open("requests.txt",'w')
'''
This function unserializes and decodes the value inside a PHP session file
'''

         
        
def unserialize_session(val):
        if not val:
Пример #28
0
#!/usr/bin/python

import sys
import os
import argDec
import web
import datetime
import config

database_configuration = config.get_configuration('/'.join(
    os.path.realpath(__file__).split('/')[:-1]) + '/config/database.cfg')
db = web.database(**database_configuration)
# Todo: correct this
db.printing = False

current_job = -1


def get_logged_in():
    logged_in = 0
    global current_job
    last = list(db.query('SELECT * FROM work ORDER BY start DESC LIMIT 1'))
    if len(last) > 0:
        logged_in = last[0]['duration'] is None
    if logged_in:
        current_job = db.query(
            'SELECT jobs.* FROM work JOIN jobs ON work.job=jobs.id '
            'ORDER BY work.start DESC LIMIT 1')[0]
    return logged_in

Пример #29
0
# Commands for inserting personal details loaded from the config file
#
# Author: Tony Grosinger
#
# Licensed under LGPL

import aenea
import aenea.configuration
from aenea.lax import Function, Text
from aenea import Choice
import dragonfly
from config import get_configuration

vim_context = aenea.ProxyPlatformContext('linux')
generic_grammar = dragonfly.Grammar('generic', context=vim_context)
config = get_configuration()

commands = {}
if "full-name" in config:
    commands['my full name'] = Text("%s" % config["full-name"])
if "last-name" in config:
    commands['my last name'] = Text("%s" % config["last-name"])
if "first-name" in config:
    commands['my first name'] = Text("%s" % config["first-name"])
if "email-address" in config:
    commands['my email'] = Text("%s" % config["email-address"])
if "company-name" in config:
    commands['company name'] = Text("%s" % config["company-name"])


class Mapping(dragonfly.MappingRule):
Пример #30
0
 def __init__(self):
     config = get_configuration()
     self._modes = config["modes"]
Пример #31
0
def get_default_book_status():
    """Returns the default book status"""

    status_list = config.get_configuration('CHAPTER_STATUS_LIST')
    default_status = config.get_configuration('CHAPTER_STATUS_DEFAULT', status_list[0]['name'])
    return default_status
Пример #32
0
import aenea
import aenea.configuration
from config import get_configuration

# Window Managers
import cinnamon
import i3wm

context = aenea.ProxyPlatformContext('linux')
language_map = {
    "cinnamon":  cinnamon,
    "i3": i3wm
}
grammar = None

config = get_configuration()
if config is None or "window-manager" not in config:
    print("Could not find window manager configuration in config file")
    print("Aborting window manager load")
else:
    selected_language = language_map[config["window-manager"]]
    if selected_language is None:
        print("Selected window manager is invalid. Please consult the README")
    else:
        grammar = selected_language.get_grammar(context, config)
        if grammar is not None:
            grammar.load()


def unload():
    if grammar is not None:
Пример #33
0
""" Configuration handler """
import config

CONFIGURATION = config.get_configuration()


def get_global_option(option):
    """ Returns the value of the option

    :returns: str
    """
    return CONFIGURATION['global'][option]


def get_gsi_option(table_key, gsi_key, option):
    """ Returns the value of the option

    :type table_key: str
    :param table_key: Table key name
    :type gsi_key: str
    :param gsi_key: GSI key name
    :returns: str
    """
    try:
        return CONFIGURATION['tables'][table_key]['gsis'][gsi_key][option]
    except KeyError:
        return None

def get_logging_option(option):
    """ Returns the value of the option
Пример #34
0
# -*- coding: utf-8 -*-
""" Configuration handler """
import config

CONFIGURATION = config.get_configuration()


def get_configured_tables():
    """ Returns a list of all configured tables

    :returns: list -- List of tables
    """
    try:
        return list(CONFIGURATION['tables'].keys())
    except KeyError:
        return []


def get_global_option(option):
    """ Returns the value of the option

    :returns: str or None
    """
    try:
        return CONFIGURATION['global'][option]
    except KeyError:
        return None


def get_gsi_option(table_key, gsi_key, option):
    """ Returns the value of the option
 def __init__(self):
     self._config = get_configuration()
Пример #36
0
def dump_problems(source):
    for p in v.get_problems():
        print p, p['component'], p['type']
        #, p.get_application().name, p['type']

class SourceObserver:
    def __init__(self):
        pass

    def problem_source_updated(self, source):
        print "--- Updated source start ----"
        dump_problems(source)
        print "--- Updated source end ----"


conf = config.get_configuration()
conf.add_option("all_problems", default_value=False)

observer = SourceObserver()
sources = { "DBus" : dbus_problems.DBusProblemSource(),
            "Directory" : directory_problems.DirectoryProblemSource(os.path.join(xdg.BaseDirectory.xdg_cache_home, "abrt/spool"))}


for k, v in sources.items():
    print "---- Source %s start ----" % (k)
    v.attach(observer)
    dump_problems(v)
    print "---- Source %s end ----" % (k)

conf['all_problems'] = True
Пример #37
0
 def __init__(self):
     config = get_configuration()
     self._degrees = config["degrees"]
Пример #38
0
import os

import mimetypes
mimetypes.add_type("application/javascript", ".mjs", True)

from flask import Flask, make_response, request, render_template
from flask_jwt_extended import JWTManager

app = Flask('gem',
            static_url_path='',
            static_folder='dist',
            template_folder='dist')
config_name = os.environ.get('FLASK_ENV') or 'development'
from config import get_configuration
app.config.from_object(get_configuration(config_name))
jwt = JWTManager(app)

from aaa import blueprint as aaa_blueprint
app.register_blueprint(aaa_blueprint)

CONTENT_SECURITY_POLICY = ';'.join([
    "default-src 'self' https://testlab-a.r37.co.uk:8000/*",
    #   "script-src 'self' https://testlab-a.r37.co.uk:8000/*",
    #   "script-src-attr 'self' https://testlab-a.r37.co.uk:8000/*",
    #   "script-src-elem 'self' https://testlab-a.r37.co.uk:8000/*",
])


@app.after_request
def after_request_callback(response):
    if request.base_url.endswith(('.js', '.mjs')):
 def __init__(self):
     config = get_configuration()
     self._techniques = config["right_hand_exercises"]