123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #!/usr/bin/python
- """
- This is the main program for KCG
- It imports all modules and starts the Gui
- """
- from PyQt4 import QtGui, QtCore
- import sys
- import os
- import argparse as ap
- import base.kcgwidget as kcgw
- import config
- from config import Configuration
- translator = QtCore.QTranslator()
- kcgw.translator = translator
- # kcgw.tr = translator.translate
- kcgw.tr = QtCore.QCoreApplication.translate
- config.install_path = os.path.dirname(config.__file__) + "/"
- try: # Try to use Erax for exception logging
- sys.path.append(os.path.expanduser('~/Documents/PythonProjects/'))
- from erax import Erax
- exception_log_handler = Erax('https://psraspi.no-ip.biz/p/erax/insert/78e55a9524a191f7628f82a20bcaa167:kcg',
- no_epl_errors=True, cert='/tmp/raspi.pem')
- exception_log_handler.install()
- except ImportError:
- pass
- def print_version(verbose=False):
- # print "KCG - KAPTURE Control Gui"
- # print "=" * 30
- print "KCG",
- with open(config.install_path+'VERSION', 'r') as v:
- print v.read().strip()
- if verbose:
- print "=" * 30
- print "Using Python:"
- print sys.version
- print "=" * 30
- print "From: " + config.install_path
- def run():
- """
- Main Function, gets called when GUI is started
- :return:
- """
- parser = ap.ArgumentParser("KCG - KAPTURE Control Gui")
- parser.add_argument('--config', type=str, default='', help='Override Configuration file settings.'
- 'Format: "Section:setting=content;Section:setting2=content;Section2:setting3=content" etc.')
- parser.add_argument('--version', action='store_true', help="Print Version and exit")
- parser.add_argument('--vversion', action='store_true', help="Print Version verbose and exit")
- parser.add_argument('--testing', action='store_true', default=False,
- help="start KCG in testing version. DO NOT USE THIS IN PRODUCTION.")
- args = parser.parse_args()
- if args.version or args.vversion:
- print_version(args.vversion)
- sys.exit()
- kcgw.testing = args.testing
- app = QtGui.QApplication(sys.argv)
- app.installTranslator(translator)
- app.processEvents()
- # pixmap = QtGui.QPixmap(config.install_path+"icons/KCG_Logo.png").scaled(400, 400)
- # splash_screen = QtGui.QSplashScreen(pixmap)
- # splash_screen.setMask(pixmap.mask())
- # splash_screen.show()
- # splash_screen.update()
- # splash_screen.showMessage("Loading KCG", QtCore.Qt.AlignCenter | QtCore.Qt.AlignBottom, QtCore.Qt.red)
- # splash_screen.update()
- # app.processEvents()
- conf = Configuration(args.config)
- conf.setup()
- while conf.error:
- conf.doSetup()
- if args.testing:
- config.default_subdirectory_name='t'
- import base.kcg as kcg
- gui = kcg.Gui()
- # splash_screen.finish(gui)
- gui.show()
- sys.exit(app.exec_())
|