예제 #1
0
def startWithCli():
    if not "html-text" in sys.modules:
        import html_text
    # Cli input
    #config.mainWindow.hide()
    #config.cli = True
    #config.printContentOnConsole = printContentOnConsole
    config.bibleWindowContentTransformers.append(printContentOnConsole)
    config.studyWindowContentTransformers.append(printContentOnConsole)
    while config.cli:
        print("--------------------")
        print("Enter '.bible' to read bible text, '.study' to read study resource, '.help' to read UBA command reference, '.gui' to launch gui, '.quit' to quit,")
        command = input("or UBA command: ").strip()
        if command == ".gui":
            del config.bibleWindowContentTransformers[-1]
            del config.studyWindowContentTransformers[-1]
            config.cli = False
        elif command == ".bible":
            print(html_text.extract_text(config.bibleWindowContent))
            # The following line does not work on Windows on UBA startup
            #config.mainWindow.mainPage.runJavaScript("document.documentElement.outerHTML", 0, printContentOnConsole)
        elif command == ".study":
            print(html_text.extract_text(config.studyWindowContent))
            # The following line does not work on Windows on UBA startup
            #config.mainWindow.studyPage.runJavaScript("document.documentElement.outerHTML", 0, printContentOnConsole)
        elif command in (".help", ".command"):
            getCommandDocumentation()
        elif command == ".quit":
            ConfigUtil.save()
            exit()
        else:
            config.mainWindow.runTextCommand(command)
    config.mainWindow.show()
    if platform.system() == "Windows":
        config.mainWindow.showMaximized()
예제 #2
0
    def setup():
        if (len(sys.argv) > 1) and sys.argv[1] == "cli":
            try:
                import telnetlib3
            except:
                print("Please run 'pip install telnetlib3' to use remote CLI")
                ConfigUtil.save()
                exit(0)

            try:
                import telnetlib3
                import asyncio
                from util.RemoteCliHandler import RemoteCliHandler

                port = 8888
                if (len(sys.argv) > 2):
                    port = int(sys.argv[2])
                print("Running in remote CLI Mode on port {0}".format(port))
                print("Access by 'telnet {0} {1}'".format(RemoteCliHandler.get_ip(), port))
                print("Press Ctrl-C to stop the server")
                loop = asyncio.get_event_loop()
                coro = telnetlib3.create_server(port=port, shell=RemoteCliHandler.shell)
                server = loop.run_until_complete(coro)
                loop.run_until_complete(server.wait_closed())
                exit(0)
            except KeyboardInterrupt:
                exit(0)
            except Exception as e:
                print(str(e))
                exit(-1)
예제 #3
0
def exitApplication():
    config.mainWindow.textCommandParser.stopTtsAudio()
    # Run shutdown plugins
    if config.enablePlugins:
        for plugin in FileUtil.fileNamesWithoutExtension(os.path.join("plugins", "shutdown"), "py"):
            if not plugin in config.excludeShutdownPlugins:
                script = os.path.join(os.getcwd(), "plugins", "shutdown", "{0}.py".format(plugin))
                config.mainWindow.execPythonFile(script)
    ConfigUtil.save()
    if config.restartUBA and hasattr(config, "cli"):
        subprocess.Popen("{0} uba.py gui".format(sys.executable), shell=True)
예제 #4
0
    def get_redis(self):
        if self.redis_client:
            return self.redis_client

        self.redis_client = redis.StrictRedis(
            host=ConfigUtil.get('REDIS', 'redis_host'),
            port=ConfigUtil.get('REDIS', 'redis_port'),
            db=ConfigUtil.get('REDIS', 'redis_db'),
            password=ConfigUtil.get('REDIS', 'redis_password')
        )
        return self.redis_client
예제 #5
0
def exitApplication():
    config.mainWindow.textCommandParser.stopTtsAudio()
    # Run shutdown plugins
    if config.enablePlugins:
        for plugin in FileUtil.fileNamesWithoutExtension(
                os.path.join("plugins", "shutdown"), "py"):
            if not plugin in config.excludeShutdownPlugins:
                script = os.path.join(os.getcwd(), "plugins", "shutdown",
                                      "{0}.py".format(plugin))
                config.mainWindow.execPythonFile(script)
    ConfigUtil.save()
예제 #6
0
def main():
    import sys
    from qtpy.QtWidgets import QApplication
    from qtpy.QtCore import QCoreApplication
    from util.ConfigUtil import ConfigUtil
    from util.LanguageUtil import LanguageUtil

    ConfigUtil.setup()
    config.noQt = False
    config.thisTranslation = LanguageUtil.loadTranslation("en_US")
    QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
    app = QApplication(sys.argv)
    dialog = DownloadBibleMp3Dialog(DummyParent())
    dialog.exec_()
예제 #7
0
        self.resetItems()


## Standalone development code


class DummyParent():
    def runTextCommand(self, command):
        print(command)


if __name__ == '__main__':
    import sys
    from qtpy.QtWidgets import QApplication
    from qtpy.QtCore import QCoreApplication
    from util.ConfigUtil import ConfigUtil
    from util.LanguageUtil import LanguageUtil

    ConfigUtil.setup()
    config.noQt = False
    config.bibleCollections["Custom"] = ['ABP', 'ACV']
    config.bibleCollections["King James"] = [
        'KJV', 'KJVx', 'KJVA', 'KJV1611', 'KJV1769x'
    ]
    config.thisTranslation = LanguageUtil.loadTranslation("en_US")
    QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)

    app = QApplication(sys.argv)
    dialog = LibraryCatalogDialog(DummyParent())
    dialog.saveRemoteCatalogToCache()
    dialog.exec_()
예제 #8
0
from util.NetworkUtil import NetworkUtil

# Change working directory to UniqueBible directory
thisFile = os.path.realpath(__file__)
wd = thisFile[:-7]
if os.getcwd() != wd:
    os.chdir(wd)

# Create custom files
FileUtil.createCustomFiles()

# Make sure config.py exists before importing config and all other scripts which depends on config
import config
# Setup config values
from util.ConfigUtil import ConfigUtil
ConfigUtil.setup()

# Check argument passed to UBA as a parameter
initialCommand = " ".join(sys.argv[1:]).strip()
config.noQt = False
config.cli = False
if initialCommand == "cli":
    config.cli = True
elif initialCommand == "gui":
    initialCommand = ""
elif len(sys.argv) > 1 and sys.argv[1] in ("telnet-server", "http-server", "execute-macro"):
    config.noQt = True
initialCommandIsPython = True if initialCommand.endswith(".py") and os.path.isfile(initialCommand) else False

# Check for dependencies and other essential elements
from util.checkup import *
예제 #9
0
파일: AI.py 프로젝트: kamiyong/pyqt5
import os
from util.ConfigUtil import ConfigUtil
from util.Logger import recordLog

if __name__ == '__main__':
    try:
        print("parent: ", os.getcwd())
        util = ConfigUtil()
        util.setFilePath(r"resource\config\AppConfig.txt")
        config = util.getConfig()
        recordLog("Config: " + config.toString())
        cmd = r"{}{}&python {}\main.py".format(config.getCondaPath(),
                                               config.getLibName(),
                                               os.getcwd())
        recordLog("cmd: " + cmd)
        cmd = cmd.replace("\n", " ")
        info = os.system(cmd)
        recordLog(info)
    except Exception as e:
        recordLog(e)
        raise e
예제 #10
0
# -*- coding: utf-8 -*-

from flask import Flask
from flask.ext.bootstrap import Bootstrap

from route import TopRoute, AwsRoute, UserRoute, MinecraftRoute, ModRoute, DownloadRoute
from util.ConfigUtil import ConfigUtil


application = Flask(__name__, template_folder='../templates', static_folder="../static")
application.secret_key = ConfigUtil.get('COMMON', 'secret_key')
Bootstrap(application)

modules_define = [
    TopRoute.app,
    AwsRoute.app,
    UserRoute.app,
    MinecraftRoute.app,
    ModRoute.app,
    DownloadRoute.app
]
for app in modules_define:
    application.register_blueprint(app)
예제 #11
0
 def is_match_password(pass1, pass2, pass3):
     return pass1 == ConfigUtil.get('USER', 'password1') and pass2 == ConfigUtil.get('USER', 'password2') and pass3 == ConfigUtil.get('USER', 'password3')