def tradeCodeForToken(code):
  """Exchange authorization code to obtain a token.

  Args:
    code: str, authorization code
  Returns:
    OAuth2Token instance if successful, None if failed.
  """

  tokenUrl = OAUTH2_TOKEN_URL
  params = {'code': code,
            'client_id': settings.read('gmeconnector/CLIENT_ID'),
            'client_secret': settings.read('gmeconnector/CLIENT_SECRET'),
            'redirect_uri': OAUTH2_REDIRECT_URI,
            'grant_type': 'authorization_code'}
  # Make a POST request
  req = urllib2.Request(tokenUrl, urllib.urlencode(params))
  req.add_header('Content-Type', 'application/x-www-form-urlencoded')
  response = makeHttpRequest(req)
  if response:
    results = json.load(response)
    token = OAuth2Token(**results)
    return token
  else:
    return None
def tradeRefreshForToken(refresh_token):
  """Gets a new token using refresh token.

  Args:
    refresh_token: str, refresh token.
  Returns:
    OAuth2Token instance if successful, None if failed.
  """
  tokenUrl = OAUTH2_TOKEN_URL
  params = {'refresh_token': refresh_token,
            'client_id': settings.read('gmeconnector/CLIENT_ID'),
            'client_secret': settings.read('gmeconnector/CLIENT_SECRET'),
            'grant_type': 'refresh_token'}
  # Make a POST request
  req = urllib2.Request(tokenUrl, urllib.urlencode(params))
  req.add_header('Content-Type', 'application/x-www-form-urlencoded')
  response = makeHttpRequest(req)
  if response:
    results = json.load(response)
    token = OAuth2Token(**results)
    # Refresh requests do not come back with refresh_token.
    # Set it to the value of the current refresh_token.
    token.refresh_token = refresh_token
    return token
  else:
    return None
  def loadFormatForIndex(self, index):
    """Loads WMS overlay format for the given index.

    Args:
      index: int, index of the comboBoxCrs widget.
    """
    unused_layerId, dataType = self.comboBoxLayer.itemData(index)
    if dataType == 'image':
      # Raster overlay default format is JPEG.
      self.comboBoxFormat.setCurrentIndex(self.comboBoxFormat.findText('JPEG'))
      defaultFormat = settings.read('gmeconnector/WMS_RASTER_FORMAT')
      if defaultFormat:
        defaultIndex = self.comboBoxFormat.findText(defaultFormat)
        if defaultIndex != -1:
          self.comboBoxFormat.setCurrentIndex(defaultIndex)
    elif dataType == 'table':
      # Vector overlay default format is PNG.
      self.comboBoxFormat.setCurrentIndex(self.comboBoxFormat.findText('PNG'))
      defaultFormat = settings.read('gmeconnector/WMS_VECTOR_FORMAT')
      if defaultFormat:
        defaultIndex = self.comboBoxFormat.findText(defaultFormat)
        if defaultIndex != -1:
          self.comboBoxFormat.setCurrentIndex(defaultIndex)
    else:
      # Set default format as PNG.
      self.comboBoxFormat.setCurrentIndex(self.comboBoxFormat.findText('PNG'))
  def __init__(self, iface):
    """Constructor for the dialog.

    Args:
      iface: QgsInterface instance.
    """
    QDialog.__init__(self, iface.mainWindow())
    self.setupUi(self)

    # Settings Tab
    # Show the current value of client_id and client_secret
    client_id = settings.read('gmeconnector/CLIENT_ID')
    client_secret = settings.read('gmeconnector/CLIENT_SECRET')
    if client_id is None:
      client_id = ''
    if client_secret is None:
      client_secret = ''
    self.lineEdit1.setText(client_id)
    self.lineEdit2.setText(client_secret)

    # Other settings
    self.comboBoxProjects.setEnabled(False)
    self.checkBoxDefault.stateChanged.connect(self.comboBoxProjects.setEnabled)
    self.comboBoxFormat.addItem('JPEG', 'image/jpeg')
    self.comboBoxFormat.addItem('PNG', 'image/png')
    defaultFormat = settings.read('gmeconnector/WMS_IMAGE_FORMAT')

    if defaultFormat:
      defaultIndex = self.comboBoxFormat.findText(defaultFormat)
      if defaultIndex != -1:
        self.comboBoxFormat.setCurrentIndex(defaultIndex)
    self.comboBoxFormat.currentIndexChanged.connect(self.handleFormatChanged)

    # OAuth help
    oAuthPage = QWebPage()
    oAuthPage.setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
    self.webViewOAuth.setPage(oAuthPage)

    # Load the oauth_help file
    helpFile = QFile(':/plugins/googlemapsengineconnector/oauth_help.html')
    helpFile.open(QIODevice.ReadOnly | QIODevice.Text)
    helpStr = QTextStream(helpFile)
    helpText = helpStr.readAll()
    self.webViewOAuth.setHtml(helpText)
    self.webViewOAuth.linkClicked.connect(self.handleWebLink)

    # About Tab
    aboutPage = QWebPage()
    aboutPage.setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
    self.webViewAbout.setPage(aboutPage)
    # Load the about.html file and add current version info.
    aboutFile = QFile(':/plugins/googlemapsengineconnector/about.html')
    aboutFile.open(QIODevice.ReadOnly | QIODevice.Text)
    aboutStr = QTextStream(aboutFile)
    aboutText = aboutStr.readAll()
    newText = aboutText.format(version='1.0')
    self.webViewAbout.setHtml(newText)
    self.webViewAbout.linkClicked.connect(self.handleWebLink)
Esempio n. 5
0
def dimmer():
    dimmer_brightness = settings.read('settings', 'matrix',
                                      'dimmer_brightness')
    default_brightness = settings.read('settings', 'matrix',
                                       'default_brightness')

    if getLight() == False:
        interface.pwm(dimmer_brightness)
    else:
        interface.pwm(default_brightness)
  def populateProjects(self):
    """Adds the project information to the comboBoxProjects widget."""
    self.projectDict = settings.read('gmeconnector/PROJECTS')
    self.comboBoxProjects.clear()
    for key, val in self.projectDict.items():
      projectId = key
      projectName = val
      self.comboBoxProjects.addItem(projectName, projectId)

    defaultProjectId = settings.read('gmeconnector/DEFAULT_PROJECT')
    if defaultProjectId:
      self.checkBoxDefault.setChecked(True)
      index = self.comboBoxProjects.findData(defaultProjectId)
      self.comboBoxProjects.setCurrentIndex(index)
Esempio n. 7
0
def connect():
    global g_conn
    if g_conn is None:
        global g_db_path
        g_db_path = os.path.expanduser(settings.read().db_path)
        g_conn = sqlite3.connect(g_db_path)
        verbose(2, 'connected to', g_db_path)
Esempio n. 8
0
def getImages():
    userSettings = settings.read()
    if userSettings.Photos.isEnabled != True:
        return '{"isNotEnabled": "True"}'
    json = photos.getAlbumsForClient(userSettings.Photos)
    userSettings.write()
    return json
  def populateProjects(self):
    """Read project information and add it to comboBoxProjects widget."""
    self.projectDict = settings.read('gmeconnector/PROJECTS')
    self.comboBoxProjects.clear()
    for projectId, projectName in self.projectDict.iteritems():
      self.comboBoxProjects.addItem(projectName, projectId)

    defaultProjectId = settings.read('gmeconnector/DEFAULT_PROJECT')
    lastUsedProjectId = settings.read('gmeconnector/LAST_USED_PROJECT')
    # Check if the user has selected a default project
    if defaultProjectId in self.projectDict:
      currentProjectId = defaultProjectId
    elif lastUsedProjectId in self.projectDict:
      currentProjectId = lastUsedProjectId
    else:
      currentProjectId = self.projectDict.iterkeys().next()
    index = self.comboBoxProjects.findData(currentProjectId)
    self.comboBoxProjects.setCurrentIndex(index)
def getToken():
  """Read the token parameters from settings and return a token object.

  Returns:
    OAuth2Token instance is succcessful, None if the token is not available.
  """
  token = OAuth2Token()
  token.access_token = settings.read('gmeconnector/ACCESS_TOKEN', object_type=str)
  token.refresh_token = settings.read('gmeconnector/REFRESH_TOKEN', object_type=str)
  token.expires_at = settings.read('gmeconnector/EXPIRES_AT', object_type=str)

  if token.access_token and token.refresh_token and token.expires_at:
    if isTokenValid(token):
      return token
    else:
      return refreshToken(token)
  else:
    return None
  def loadInitialMaps(self):
    self.projectDict = settings.read('gmeconnector/PROJECTS')
    self.comboBox.clear()
    for key, val in self.projectDict.items():
      projectId = key
      projectName = val
      self.comboBox.addItem(projectName, projectId)

    defaultProjectId = settings.read('gmeconnector/DEFAULT_PROJECT')
    lastUsedProjectId = settings.read('gmeconnector/LAST_USED_PROJECT')
    # Check if the user has selected a default project
    if defaultProjectId and defaultProjectId in self.projectDict:
      self.loadMapsForProject(defaultProjectId)
    # If there is no default project, load the last used project
    elif lastUsedProjectId and lastUsedProjectId in self.projectDict:
      self.loadMapsForProject(lastUsedProjectId)
    # Load the first project in the dictionary
    else:
      self.loadMapsForProject(self.projectDict.iterkeys().next())
Esempio n. 12
0
    def load_settings(self):
        self.settings = settings_file.read()

        self.ui.workTimeSpinBox.setValue(
            int(self.settings['TIME']['work_time']) / 60)
        self.ui.timeOfShortBreakSpinBox.setValue(
            int(self.settings['TIME']['time_of_short_break']) / 60)
        self.ui.timeOfLongBreakSpinBox.setValue(
            int(self.settings['TIME']['time_of_long_break']) / 60)
        self.ui.workTimeWhenPostponeBreakSpinBox.setValue(
            int(self.settings['TIME']['work_time_when_postpone_break']) / 60)
        self.ui.numberOfShortsBreaksSpinBox.setValue(
            int(self.settings['BREAKS']['number_of_short_breaks']))
Esempio n. 13
0
    def load_settings(self):
        self.settings = settings_file.read()

        self.ui.workTimeSpinBox.setValue(
            int(self.settings['TIME']['work_time']) / 60)
        self.ui.timeOfShortBreakSpinBox.setValue(
            int(self.settings['TIME']['time_of_short_break']) / 60)
        self.ui.timeOfLongBreakSpinBox.setValue(
            int(self.settings['TIME']['time_of_long_break']) / 60)
        self.ui.workTimeWhenPostponeBreakSpinBox.setValue(
            int(self.settings['TIME']['work_time_when_postpone_break']) / 60)
        self.ui.numberOfShortsBreaksSpinBox.setValue(
            int(self.settings['BREAKS']['number_of_short_breaks']))
Esempio n. 14
0
    def __init__(self, items):
        self.__items = items

        logging.debug("Items:" + items.__str__())
        self._xml = '''<xml>
        <ToUserName><![CDATA[$ToUserName]]></ToUserName>
        <FromUserName><![CDATA[$FromUserName]]></FromUserName>
        <CreateTime>$CreateTime</CreateTime>
        <MsgType><![CDATA[news]]></MsgType>
        <ArticleCount>%s</ArticleCount>
        <Articles>
            %s
        </Articles>
        </xml>
        '''

        itemxml = '''        <item>
        <Title><![CDATA[%s]]></Title>
        <Description><![CDATA[%s]]></Description>
        <PicUrl><![CDATA[%s]]></PicUrl>
        <Url><![CDATA[%s]]></Url>
        </item>'''

        itemsxml = []
        for i in items:
            logging.debug(i)
            onexml = itemxml % (i[VIEW_TITLE], i.get(VIEW_DESCRIPTION, ""),
                                i.get(VIEW_PICURL, ""), i.get(VIEW_URL, ""))
            itemsxml.append(onexml)

        if settings.read(settings.MOD_SETTING_MSG).has_key(
                settings.SET_NEWS_END):
            i = settings.read(settings.MOD_SETTING_MSG)[settings.SET_NEWS_END]
            itemsxml.append(itemxml %
                            (i[VIEW_TITLE], i.get(VIEW_DESCRIPTION, ""),
                             i.get(VIEW_PICURL, ""), i.get(VIEW_URL, "")))

        articlesxml = "".join(itemsxml)
        self._xml = self._xml % (len(itemsxml), articlesxml)
Esempio n. 15
0
def mqtt_run():
    feeds = settings.read('feeds')
    print("Follow %s topics") % (len(feeds))
    feedsTopics = [(f.get('topic'), f.get('priority')) for f in feeds]

    client = mqtt.Client()
    client.on_connect = on_connect
    client.on_message = on_message

    client.connect(brokerIP, brokerPort, 60)
    client.subscribe(feedsTopics)

    client.loop_start()
def buildAuthenticationUri():
  """Creates a URL for authentication.

  Returns;
    str, authentication url.
  """
  baseUrl = OAUTH2_AUTH_URL
  params = {'response_type': 'code',
            'client_id': settings.read('gmeconnector/CLIENT_ID'),
            'scope': OAUTH2_AUTH_SCOPES,
            'state': '123456789',
            'approval_prompt': 'auto',
            'redirect_uri': OAUTH2_REDIRECT_URI}
  authUrl = '%s?%s' % (baseUrl, urllib.urlencode(params))
  return authUrl
Esempio n. 17
0
    def __init__(self, content):
        self.__content = content
        msgSetting = settings.read(settings.MOD_SETTING_MSG)
        logging.debug("Init textmessage[%s]" % content)

        if msgSetting.has_key(settings.SET_TEXT_END):
            content = content + msgSetting[settings.SET_TEXT_END]

        xmlTlp = '''<xml>
        <ToUserName><![CDATA[$ToUserName]]></ToUserName>
        <FromUserName><![CDATA[$FromUserName]]></FromUserName>
        <CreateTime>$CreateTime</CreateTime>
        <MsgType><![CDATA[text]]></MsgType>
        <Content><![CDATA[$Content]]></Content>
        <FuncFlag>0</FuncFlag>
        </xml>'''

        s = Template(xmlTlp)
        self._xml = s.safe_substitute({"Content": content})
def isTokenValid(token):
  """Check if the given token is valid.

  Returns:
    True if the token is valid.
  """
  baseUrl = OAUTH2_TOKENINFO_URL
  params = {'access_token': token.access_token}
  tokenInfoUrl = '%s?%s' % (baseUrl, urllib.urlencode(params))
  req = urllib2.Request(tokenInfoUrl)
  # Make a GET request
  response = makeHttpRequest(req)
  if response:
    response = urllib2.urlopen(req)
    results = json.load(response)
    if results['audience'] == settings.read('gmeconnector/CLIENT_ID'):
      return True
    else:
      return False
  else:
    return False
Esempio n. 19
0
import datetime
import time

from ht1632cpy import HT1632C

import settings
from lightsensor import getLight

interface = HT1632C(2, 0)
interface.pwm(settings.read('settings', 'matrix', 'default_brightness'))


def dimmer():
    dimmer_brightness = settings.read('settings', 'matrix',
                                      'dimmer_brightness')
    default_brightness = settings.read('settings', 'matrix',
                                       'default_brightness')

    if getLight() == False:
        interface.pwm(dimmer_brightness)
    else:
        interface.pwm(default_brightness)


def displayText(x, text, text_color, bg_color, delay):
    interface.clear()

    if text_color == 'text_green':
        c_text = interface.GREEN
    elif text_color == 'text_red':
        c_text = interface.RED
Esempio n. 20
0
import os
import sys

import paho.mqtt.client as mqtt

import tornado.ioloop
import tornado.web
import tornado.template
import tornado.gen
from tornado.queues import Queue

import settings
from display import displayText, clock, dimmer
from standby import stabdby_mode

brokerIP = settings.read('settings', 'mqtt', 'brokerIP')
brokerPort = settings.read('settings', 'mqtt', 'brokerPort')
httpPort = settings.read('settings', 'http', 'port')
standbyFrom = settings.read('settings', 'standby', 'from')
standbyTo = settings.read('settings', 'standby', 'to')

q = Queue(maxsize=2)


class HomePage(tornado.web.RequestHandler):
    def get(self):
        self.render('app.tpl')


class MessagePage(tornado.web.RequestHandler):
    def get(self):
Esempio n. 21
0
def getWeather(includeForecast):
    userSettings = settings.read()
    if userSettings.Weather.isEnabled != True:
        return '{"isNotEnabled": "True"}'
    json = weather.getWeather(includeForecast, userSettings.Weather)
    return json
Esempio n. 22
0
ap = argparse.ArgumentParser()

ap.add_argument("-c", "--camera", type=int, default=0, help="change camera")
ap.add_argument("-d",
                "--display",
                type=int,
                default=1,
                help="Whether or not frame should be displayed")

args = ap.parse_args()

if args.display > 0:
    cv.namedWindow("trackbars", cv.WINDOW_NORMAL)
    cv.resizeWindow("trackbars", 300, 500)
    cv.createTrackbar("L - H", "trackbars", int(rw.read("setting/LH.txt")),
                      179, lambda x: rw.write(x, "setting/LH.txt"))
    cv.createTrackbar("L - S", "trackbars", int(rw.read("setting/LS.txt")),
                      255, lambda x: rw.write(x, "setting/LS.txt"))
    cv.createTrackbar("L - V", "trackbars", int(rw.read("setting/LV.txt")),
                      255, lambda x: rw.write(x, "setting/LV.txt"))
    cv.createTrackbar("U - H", "trackbars", int(rw.read("setting/UH.txt")),
                      179, lambda x: rw.write(x, "setting/UH.txt"))
    cv.createTrackbar("U - S", "trackbars", int(rw.read("setting/US.txt")),
                      255, lambda x: rw.write(x, "setting/US.txt"))
    cv.createTrackbar("U - V", "trackbars", int(rw.read("setting/UV.txt")),
                      255, lambda x: rw.write(x, "setting/UV.txt"))

    cv.createTrackbar("dilation", "trackbars",
                      int(rw.read("setting/dilation_bola.txt")), 50,
                      lambda x: rw.write(x, "setting/dilation_bola.txt"))
Esempio n. 23
0
    
    def closeApp():
        print("Close app signal")
        for task in asyncio.Task.all_tasks():
            print(task)
            task.cancel()
        loop.stop()
    gui_connection.closeApp.connect(closeApp)
    
    with loop:
        #asyncio.run_coroutine_threadsafe(timer(loop, config, gui_connection), loop)
        try:
            loop.run_until_complete(timer(loop, config, gui_connection))
        except asyncio.CancelledError:
            pass
        
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Koffeebreak")
    
    parser.add_argument('--gui', help='set type of gui(none, qt(default))')
    args = parser.parse_args()
    
    config = settings.read()
    if args.gui == "none":
        config['EXECUTION']['gui'] = "none"
    elif args.gui == "qt":
        config['EXECUTION']['gui'] = "qt"
    
    if settings.read_parameter(config, ['EXECUTION', 'gui']) == 'qt':
        start_qt_app(config)
Esempio n. 24
0
import settings as rw
import cv2 as cv
import imutils
from imutils.video import WebcamVideoStream
import numpy as np
import argparse

# LOAD CONFIGURATION ###
l_h_gawang = int(rw.read("setting/LH_gawang.txt"))
l_s_gawang = int(rw.read("setting/LS_gawang.txt"))
l_v_gawang = int(rw.read("setting/LV_gawang.txt"))
u_h_gawang = int(rw.read("setting/UH_gawang.txt"))
u_s_gawang = int(rw.read("setting/US_gawang.txt"))
u_v_gawang = int(rw.read("setting/UV_gawang.txt"))

lower_white = np.array([l_h_gawang, l_s_gawang, l_v_gawang])
upper_white = np.array([u_h_gawang, u_s_gawang, u_v_gawang])

dilation_gawang = rw.odd(int(rw.read("setting/dilation_gawang.txt")))
dilation_iteration_gawang = int(rw.read("setting/dilation_iteration_gawang.txt"))
erosion_gawang = rw.odd(int(rw.read("setting/erosion_gawang.txt")))
erosion_iteration_gawang = int(rw.read("setting/erosion_iteration_gawang.txt"))
gaussian_gawang = rw.odd(int(rw.read("setting/gaussian_gawang.txt")))
radius_gawang = int(rw.read("setting/radius_gawang.txt"))

erosion_kernel = cv.getStructuringElement(cv.MORPH_RECT, (erosion_gawang, erosion_gawang))
dilation_kernel = cv.getStructuringElement(cv.MORPH_RECT, (dilation_gawang, dilation_gawang))


def color_filter(frame):
    frame = cv.GaussianBlur(frame, (gaussian_gawang, gaussian_gawang), 0)
Esempio n. 25
0
from imutils.video import WebcamVideoStream

ap = argparse.ArgumentParser()

ap.add_argument("-c", "--camera", type=int, default=0, help="change camera")
ap.add_argument("-d",
                "--display",
                type=int,
                default=1,
                help="Whether or not frame should be displayed")

args = ap.parse_args()

cv.namedWindow("trackbars", cv.WINDOW_NORMAL)
cv.resizeWindow("trackbars", 300, 500)
cv.createTrackbar("L - H", "trackbars", int(rw.read("setting/LH_gawang.txt")),
                  179, lambda x: rw.write(x, "setting/LH_gawang.txt"))
cv.createTrackbar("L - S", "trackbars", int(rw.read("setting/LS_gawang.txt")),
                  255, lambda x: rw.write(x, "setting/LS_gawang.txt"))
cv.createTrackbar("L - V", "trackbars", int(rw.read("setting/LV_gawang.txt")),
                  255, lambda x: rw.write(x, "setting/LV_gawang.txt"))
cv.createTrackbar("U - H", "trackbars", int(rw.read("setting/UH_gawang.txt")),
                  179, lambda x: rw.write(x, "setting/UH_gawang.txt"))
cv.createTrackbar("U - S", "trackbars", int(rw.read("setting/US_gawang.txt")),
                  255, lambda x: rw.write(x, "setting/US_gawang.txt"))
cv.createTrackbar("U - V", "trackbars", int(rw.read("setting/UV_gawang.txt")),
                  255, lambda x: rw.write(x, "setting/UV_gawang.txt"))

cv.createTrackbar("dilation", "trackbars",
                  int(rw.read("setting/dilation_gawang.txt")), 20,
                  lambda x: rw.write(x, "setting/dilation_gawang.txt"))
Esempio n. 26
0
w = 160
h = 160

cap = cv2.VideoCapture(0)
cap.set(3, w)
cap.set(4, h)

cv2.namedWindow('HueComp')
cv2.namedWindow('SatComp')
cv2.namedWindow('ValComp')
cv2.namedWindow('closing')
cv2.namedWindow('mask')
cv2.namedWindow('tracking')

cv2.createTrackbar('hmin', 'HueComp', int(rw.read("setting/LH.txt")), 179,
                   lambda x: rw.write(x, "setting/LH.txt"))
cv2.createTrackbar('hmax', 'HueComp', int(rw.read("setting/UH.txt")), 179,
                   lambda x: rw.write(x, "setting/UH.txt"))

cv2.createTrackbar('smin', 'SatComp', int(rw.read("setting/LS.txt")), 255,
                   lambda x: rw.write(x, "setting/LS.txt"))
cv2.createTrackbar('smax', 'SatComp', int(rw.read("setting/US.txt")), 255,
                   lambda x: rw.write(x, "setting/US.txt"))

cv2.createTrackbar('vmin', 'ValComp', int(rw.read("setting/LV.txt")), 255,
                   lambda x: rw.write(x, "setting/LV.txt"))
cv2.createTrackbar('vmax', 'ValComp', int(rw.read("setting/UV.txt")), 255,
                   lambda x: rw.write(x, "setting/UV.txt"))

while (1):
Esempio n. 27
0
        print("Close app signal")
        for task in asyncio.Task.all_tasks():
            print(task)
            task.cancel()
        loop.stop()

    gui_connection.closeApp.connect(closeApp)

    with loop:
        #asyncio.run_coroutine_threadsafe(timer(loop, config, gui_connection), loop)
        try:
            loop.run_until_complete(timer(loop, config, gui_connection))
        except asyncio.CancelledError:
            pass


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Koffeebreak")

    parser.add_argument('--gui', help='set type of gui(none, qt(default))')
    args = parser.parse_args()

    config = settings.read()
    if args.gui == "none":
        config['EXECUTION']['gui'] = "none"
    elif args.gui == "qt":
        config['EXECUTION']['gui'] = "qt"

    if settings.read_parameter(config, ['EXECUTION', 'gui']) == 'qt':
        start_qt_app(config)
Esempio n. 28
0
def getVerse():
    userSettings = settings.read()
    if userSettings.Verse.isEnabled != True:
        return '{"isNotEnabled": "True"}'
    json = verse.get()
    return json
Esempio n. 29
0
import asyncqt
from PyQt5.QtCore import QLocale, QTranslator, QLibraryInfo
from PyQt5.QtWidgets import QApplication

import info
import settings
from mainwindow import MainWindow

if __name__ == '__main__':
    app = QApplication(sys.argv)
    loop = asyncqt.QEventLoop(app)
    asyncio.set_event_loop(loop)

    # Loading settings
    settings = settings.ApplicationSettings()
    settings.read()

    locale = settings.language if settings.language is not None and len(
        settings.language) > 0 else QLocale.system().name()

    qt_translator = QTranslator()
    if qt_translator.load('qt_' + locale,
                          QLibraryInfo.location(
                              QLibraryInfo.TranslationsPath)):
        app.installTranslator(qt_translator)

    my_app_translator = QTranslator()
    if my_app_translator.load('kenwood_db_gen_' + locale,
                              os.path.join(info.APP_DIR, 'translations')):
        app.installTranslator(my_app_translator)
Esempio n. 30
0
def getSettings():
    userSettings = settings.read()
    jsonString = json.dumps(userSettings.toJSON())
    return jsonString