check-deployment-target-gui.py 2.51 KB
Newer Older
1 2 3
#!/usr/bin/env python

import sys
4
import os
5 6 7 8
import PySide
from PySide.QtGui import (QApplication,
                          QMessageBox)

9
def install_gr740_rtems410_gaisler_posix():
10 11
    """ $ /home/taste/tool-src/add-ons/install-gaisler-4.10.sh """
    os.system("$HOME/tool-src/add-ons/install-gaisler-4.10.sh")
12

13 14 15
def check_gr740_rtems410_gaisler_posix():
    if not os.path.isdir("/opt/rtems-4.10"):
        raise NotImplementedError(install_gr740_rtems410_gaisler_posix)
16 17


18 19 20 21 22 23 24 25 26 27 28 29 30 31
PLATFORMS = { "crazyflie_v2.gnat"      : lambda: True,
              "stm32f4_discovery.gnat" : lambda: True,
              "leon.rtems_posix"       : lambda: True,
              "leon2.rtems412_posix"   : lambda: True,
              "leon3.rtems412_posix"   : lambda: True,
              "gr712.rtems412_posix"   : lambda: True,
              "gr740.rtems412_posix"   : lambda: True,
              "gr740.rtems410_gaisler_posix" :
                  check_gr740_rtems410_gaisler_posix,
              "x86.linux"              : lambda: True,
              "x86.win32"              : lambda: True
             }

def query_user(platform):
32 33 34 35 36 37 38 39 40 41
    msg_box = QMessageBox()
    msg_box.setWindowTitle("This plaform is not installed!")
    ok    = msg_box.addButton("Install now",   QMessageBox.AcceptRole)
    later = msg_box.addButton("Install later", QMessageBox.RejectRole)
    msg_box.setEscapeButton(later)
    msg_box.setDefaultButton(ok)
    msg_box.setIcon(QMessageBox.Warning)
    msg_box.setText("Do you want to install target\n{} ?".format(platform))
    msg_box.exec_()
    return msg_box.clickedButton() == ok
42 43

def main():
44
    app = QApplication(sys.argv)
45 46 47 48 49
    # check if the target in supported
    try:
        platform = sys.argv[1]
        PLATFORMS[platform]()
    except KeyError:
50 51 52 53
        warn_box = QMessageBox()
        warn_box.setIcon(QMessageBox.Information)
        warn_box.setText("Unknown platform: {}".format(platform))
        warn_box.exec_()
54 55 56
        return 1
    except IndexError:
        print("You must specify the target in the command line")
57 58 59 60
    except NotImplementedError as exc:
        install_it, = exc.args
        if query_user(platform):
            install_it()
61 62 63 64 65 66 67
        else:
            warn_box = QMessageBox()
            warn_box.setIcon(QMessageBox.Information)
            warn_box.setText("You can install the platform later by typing:\n"
                              + str(install_it.__doc__))
            warn_box.exec_()

68 69 70 71 72 73 74
    else:
        print("Platform {} is installed".format(platform))
        sys.exit(0)

if __name__ == '__main__':
    main()