check-deployment-target-gui.py 2.65 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
    """ $ /home/taste/tool-src/add-ons/install-gaisler-4.10.sh """
11
    os.system("xterm -e $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
# When editing, replace dot (.) with underscore (_)
# the TASTE GUI mixes them up if there is more than one underscore
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" :
27
                  check_gr740_rtems410_gaisler_posix,
28
29
              "x86_linux"              : lambda: True,
              "x86_win32"              : lambda: True
30
31
32
             }

def query_user(platform):
33
34
35
36
37
38
39
40
41
42
    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
43
44

def main():
45
    app = QApplication(sys.argv)
46
47
48
    # check if the target in supported
    try:
        platform = sys.argv[1]
49
        PLATFORMS[platform.replace('.', '_')]()
50
    except KeyError:
51
52
53
54
        warn_box = QMessageBox()
        warn_box.setIcon(QMessageBox.Information)
        warn_box.setText("Unknown platform: {}".format(platform))
        warn_box.exec_()
55
56
57
        return 1
    except IndexError:
        print("You must specify the target in the command line")
58
59
60
61
    except NotImplementedError as exc:
        install_it, = exc.args
        if query_user(platform):
            install_it()
62
63
64
65
66
67
68
        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_()

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

if __name__ == '__main__':
    main()