Пример #1
0
def handle_start(args):
    from mslib.mscolab.server import APP, initialize_managers, start_server
    setup_logging(args)
    logging.info("MSS Version: %s", __version__)
    logging.info("Python Version: %s", sys.version)
    logging.info("Platform: %s (%s)", platform.platform(), platform.architecture())
    logging.info("Launching user interface...")

    app, sockio, cm, fm = initialize_managers(APP)
    start_server(app, sockio, cm, fm)
Пример #2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-v",
                        "--version",
                        help="show version",
                        action="store_true",
                        default=False)
    parser.add_argument("--host",
                        help="hostname",
                        default="127.0.0.1",
                        dest="host")
    parser.add_argument("--port", help="port", dest="port", default="8081")
    parser.add_argument("--threadpool",
                        help="threadpool",
                        dest="use_threadpool",
                        action="store_true",
                        default=False)
    parser.add_argument("--debug",
                        help="show debugging log messages on console",
                        action="store_true",
                        default=False)
    parser.add_argument("--logfile",
                        help="If set to a name log output goes to that file",
                        dest="logfile",
                        default=None)
    args = parser.parse_args()

    if args.version:
        print(
            "***********************************************************************"
        )
        print("\n            Mission Support System (mss)\n")
        print(
            "***********************************************************************"
        )
        print("Documentation: http://mss.rtfd.io")
        print("Version:", __version__)
        sys.exit()

    setup_logging(args)

    logging.info("Configuration File: '%s'", mss_wms_settings.__file__)

    application.run(args.host, args.port)
Пример #3
0
def main():
    try:
        prefix = os.environ["CONDA_DEFAULT_ENV"]
    except KeyError:
        prefix = ""
    app_prefix = prefix
    if prefix:
        app_prefix = "-{}".format(prefix)
    icon_hash = hashlib.md5('.'.join([__version__, app_prefix]).encode('utf-8')).hexdigest()

    parser = argparse.ArgumentParser()
    parser.add_argument("-v", "--version", help="show version", action="store_true", default=False)
    parser.add_argument("--debug", help="show debugging log messages on console", action="store_true", default=False)
    parser.add_argument("--logfile", help="Specify logfile location. Set to empty string to disable.", action="store",
                        default=os.path.join(constants.MSS_CONFIG_PATH, "mss_pyui.log"))
    parser.add_argument("-m", "--menu", help="adds mss to menu", action="store_true", default=False)
    parser.add_argument("-d", "--deinstall", help="removes mss from menu", action="store_true", default=False)

    args = parser.parse_args()

    if args.version:
        print("***********************************************************************")
        print("\n            Mission Support System (mss)\n")
        print("***********************************************************************")
        print("Documentation: http://mss.rtfd.io")
        print("Version:", __version__)
        sys.exit()

    setup_logging(args)

    if args.menu:
        # Experimental feature to get mss into application menu
        if platform.system() == "Linux":
            icon_size = '48x48'
            src_icon_path = icons(icon_size)
            icon_destination = constants.POSIX["icon_destination"].format(icon_size, icon_hash)
            dirname = os.path.dirname(icon_destination)
            if not os.path.exists(dirname):
                os.makedirs(dirname)
            shutil.copyfile(src_icon_path, icon_destination)
            desktop = constants.POSIX["desktop"]
            application_destination = constants.POSIX["application_destination"].format(app_prefix)
            dirname = os.path.dirname(application_destination)
            if not os.path.exists(dirname):
                os.makedirs(dirname)
            if prefix:
                prefix = "({})".format(prefix)
            desktop = desktop.format(prefix,
                                     os.path.join(sys.prefix, "bin", "mss"),
                                     icon_destination)
            with open(application_destination, 'w') as f:
                f.write(desktop)
            logging.info("menu entry created")
        sys.exit()
    if args.deinstall:
        application_destination = constants.POSIX["application_destination"].format(app_prefix)
        if os.path.exists(application_destination):
            os.remove(application_destination)
        icon_size = '48x48'
        icon_destination = constants.POSIX["icon_destination"].format(icon_size, icon_hash)
        if os.path.exists(icon_destination):
            os.remove(icon_destination)
        logging.info("menu entry removed")
        sys.exit()

    logging.info("MSS Version: %s", __version__)
    logging.info("Python Version: %s", sys.version)
    logging.info("Platform: %s (%s)", platform.platform(), platform.architecture())
    logging.info("Launching user interface...")

    application = QtWidgets.QApplication(sys.argv)
    application.setWindowIcon(QtGui.QIcon(icons('128x128')))
    application.setApplicationDisplayName("MSS")
    mainwindow = MSSMainWindow()
    mainwindow.create_new_flight_track()
    mainwindow.show()
    sys.exit(application.exec_())
Пример #4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-v",
                        "--version",
                        help="show version",
                        action="store_true",
                        default=False)
    parser.add_argument("--host",
                        help="hostname",
                        default="127.0.0.1",
                        dest="host")
    parser.add_argument("--port", help="port", dest="port", default="8081")
    parser.add_argument("--threadpool",
                        help="threadpool",
                        dest="use_threadpool",
                        action="store_true",
                        default=False)
    parser.add_argument("--debug",
                        help="show debugging log messages on console",
                        action="store_true",
                        default=False)
    parser.add_argument("--logfile",
                        help="If set to a name log output goes to that file",
                        dest="logfile",
                        default=None)
    parser.add_argument("--update",
                        help="Updates MSS to the newest version",
                        action="store_true",
                        default=False)

    subparsers = parser.add_subparsers(help='Available actions', dest='action')
    gallery = subparsers.add_parser("gallery",
                                    help="Subcommands surrounding the gallery")
    gallery.add_argument(
        "--create",
        action="store_true",
        default=False,
        help="Generates plots of all layers not already present")
    gallery.add_argument("--clear",
                         action="store_true",
                         default=False,
                         help="Deletes all plots and corresponding code")
    gallery.add_argument(
        "--refresh",
        action="store_true",
        default=False,
        help=
        "Deletes all plots and regenerates them, a mix of --clear and --create"
    )
    gallery.add_argument(
        "--levels",
        default="",
        help="A comma-separated list of all levels visible on the gallery.\n"
        "E.g. --levels 200,300"
        "Use --levels all to include all levels.\n"
        "Default is the middle level.")
    gallery.add_argument(
        "--itimes",
        default="",
        help="A comma-separated list of all init times visible on the gallery"
        ", in ISO format.\nE.g. --itimes 2012-10-17T12:00:00\n"
        "Use --itimes all to use all available itimes.\n"
        "Default is the latest itime.")
    gallery.add_argument(
        "--vtimes",
        default="",
        help="A comma-separated list of all valid times visible on the gallery"
        ", in ISO format.\nE.g. --vtimes 2012-10-19T12:00:00\n"
        "Use --vtimes all to use all available vtimes.\n"
        "Default is the latest vtime")
    gallery.add_argument(
        "--show-code",
        action="store_true",
        default=False,
        help="Generates plots of all layers not already present, "
        "and generates code snippets for each plot when clicking on the image")
    gallery.add_argument(
        "--url-prefix",
        default="",
        help=
        "Normally the plot images should appear at the relative url /static/plots/*.png.\n"
        "In case they are prefixed by something, e.g. /demo/static/plots/*.png,"
        " please provide the prefix /demo here.")

    args = parser.parse_args()

    if args.version:
        print(
            "***********************************************************************"
        )
        print("\n            Mission Support System (MSS)\n")
        print(
            "***********************************************************************"
        )
        print("Documentation: http://mss.rtfd.io")
        print("Version:", __version__)
        sys.exit()

    updater = Updater()
    if args.update:
        updater.on_update_available.connect(
            lambda old, new: updater.update_mss())
        updater.on_log_update.connect(lambda s: print(s.replace("\n", "")))
        updater.on_status_update.connect(lambda s: print(s.replace("\n", "")))
        updater.run()
        while Worker.workers:
            list(Worker.workers)[0].wait()
        sys.exit()

    setup_logging(args)

    if args.action == "gallery":
        create = args.create or args.refresh
        clear = args.clear or args.refresh
        server.generate_gallery(create,
                                clear,
                                args.show_code,
                                url_prefix=args.url_prefix,
                                levels=args.levels,
                                itimes=args.itimes,
                                vtimes=args.vtimes)
        logging.info("Gallery generation done.")
        sys.exit()

    updater.on_update_available.connect(lambda old, new: logging.info(
        f"MSS can be updated from {old} to {new}.\nRun"
        " the --update argument to update the server."))
    updater.run()

    logging.info("Configuration File: '%s'", mswms_settings.__file__)

    application.run(args.host, args.port)