Exemplo n.º 1
0
def run(app):
    # Ask user for AssetJet database location
    dlgDbLocation = DbLocation()
    # Hide the 'What's This' question mark
    dlgDbLocation.setWindowFlags(QtCore.Qt.WindowTitleHint)
    if dlgDbLocation.exec_():
        loc = os.path.join(dlgDbLocation.getText(),'assetjet.db')
        # create directory if it doesn't exist yet
        if not os.path.exists(dlgDbLocation.getText()):
            os.mkdir(dlgDbLocation.getText())
        cfg.add_entry('Database', 'DbFileName', loc)
                      
    # Start download thread if database is not existing yet
    if not os.path.exists(loc):
        # Check internet connection
        from assetjet.util import util
        if util.test_url('http://finance.yahoo.com'):
            # Start download thread
            download = download_data.Downloader(loc)
            download.daemon = True
            download.start()
            
            # Create download progress dialog
            dlgProgress = QtGui.QProgressDialog(
                                labelText='Downloading 1 year of daily returns for members of the S&P 500. \n This may take a couple of minutes.\n' ,
                                minimum = 0, maximum = 500,
                                flags=Qt.CustomizeWindowHint | Qt.WindowTitleHint)
            dlgProgress.setWindowTitle('Downloading...')                                       
            dlgProgress.setCancelButton(None)
            dlgProgress.setWindowIcon(QtGui.QIcon(':/Pie-chart.ico'))
            dlgProgress.show()
    
            # Update progress bar through signal
            download.downloaded.connect(dlgProgress.setValue)
            download.finished.connect(dlgProgress.close)
            app.exec_()  
            
            # TODO: let it run in parallel with the local server thread
            download.wait()
        else:
            msgBox = QMessageBox()
            msgBox.setWindowTitle('No Internet Connection')
            msgBox.setText("To run AssetJet the first time, you need a working \n" \
                           "internet connection to download the historical returns.")
            msgBox.setStandardButtons(QMessageBox.Ok)
            msgBox.setIcon(QMessageBox.Warning)
            msgBox.setDefaultButton(QMessageBox.Ok)
            msgBox.setWindowIcon(QtGui.QIcon(':/Pie-chart.ico'))
            reply = msgBox.exec_()
            sys.exit()
Exemplo n.º 2
0
def main():
    # Create MainApp
    app = QtGui.QApplication(sys.argv)

    # Check for Updates when run as frozen executable
    if getattr(sys, 'frozen', False):
        updater.update(app)

    # Start wizard to set database path
    if not cfg.config.has_option('Wizard', 'done'):
        wizard.run(app)
        cfg.add_entry('Wizard', 'done', 'True')

    # Splash screen
    splash_pix = QtGui.QPixmap(':/splashAssetJet.png')
    splash = QtGui.QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Load the heavy modules here
    import pandas
    import numpy
    import scipy
    import local_server
    time.sleep(1)

    # Initialise web server to server HTML to WebView
    srv = local_server.LocalServer()
    srv.daemon = True
    srv.start()
    log.Debug("Started web server")

    # Launch the app and pass control to the main controller
    mainForm = MainController()
    mainForm.show_()
    splash.finish(mainForm)
    sys.exit(app.exec_())
    sys.exit(0)
Exemplo n.º 3
0
def main():
    # Create MainApp
    app = QtGui.QApplication(sys.argv)
       
    # Check for Updates when run as frozen executable
    if getattr(sys, 'frozen', False):
        updater.update(app)
        
    # Start wizard to set database path
    if not cfg.config.has_option('Wizard','done'):
        wizard.run(app)
        cfg.add_entry('Wizard','done', 'True')
        
    # Splash screen
    splash_pix = QtGui.QPixmap(':/splashAssetJet.png') 
    splash = QtGui.QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()
    
    # Load the heavy modules here
    import pandas
    import numpy
    import scipy
    import local_server
    time.sleep(1)
  
    # Initialise web server to server HTML to WebView
    srv = local_server.LocalServer()
    srv.daemon=True
    srv.start()
    log.Debug("Started web server")
    
    # Launch the app and pass control to the main controller 
    mainForm = MainController()
    mainForm.show_()
    splash.finish(mainForm)
    sys.exit(app.exec_())
    sys.exit(0)