コード例 #1
0
def setupProxy(sitRootPath=None, sitProxyPath=None):
    """
        Convenience-wrapper to create a default proxy directory.

        WARNING: If a proxy already exists, it will be DELETED !

        You may specify the absolute paths for the SIT root- and/or
        proxy directories. If omitted, typical defaults will be used.
    """
    from ToolBOSCore.Storage import ProxyDir
    from ToolBOSCore.Storage import SIT

    if not sitRootPath:
        sitRootPath = SIT.getDefaultRootPath()

    if not sitProxyPath:
        sitProxyPath = SIT.getDefaultProxyPath()

    Any.requireIsTextNonEmpty(sitRootPath)
    Any.requireIsTextNonEmpty(sitProxyPath)
    Any.requireIsDir(sitRootPath)

    # delete existing proxy if it exists, it might be screwed up
    if os.path.exists(sitProxyPath):
        logging.info('cleaning existing proxy in %s' % sitProxyPath)
        FastScript.remove(sitProxyPath)

    logging.info('creating proxy directory... (this may take some time)')
    logging.info('SIT Root:  %s' % sitRootPath)
    logging.info('SIT Proxy: %s' % sitProxyPath)
    ProxyDir.createProxyDir(sitRootPath, sitProxyPath, verbose=False)
コード例 #2
0
def updateComponentIndex(sitRootPath, sitProxyPath, dryRun):
    """
        Cleans the index directory and creates all symlinks from scratch.
    """
    Any.requireIsDir(sitRootPath)
    Any.requireIsDir(sitProxyPath)
    Any.requireIsBool(dryRun)

    ProxyDir.requireIsProxyDir(sitProxyPath)

    indexBaseDir = getIndexBaseDir(sitProxyPath)

    # We would like to start with a fresh indexBaseDir, however cannot delete
    # it because it also contains the DTBOS *.def files. Hence we only remove
    # subdirectories (corresponding to the RTMaps versions) within this
    # directories and keep *.def files as they are. See TBCORE-974).
    #
    #FastScript.remove( indexBaseDir )

    for subDir in FastScript.getDirsInDir(indexBaseDir):
        path = os.path.join(indexBaseDir, subDir)
        FastScript.remove(path)

    for version in getVersionsAvailable(sitRootPath):
        dstDir = os.path.join(indexBaseDir, version)
        logging.debug('mkdir %s', dstDir)

        if not dryRun:
            FastScript.mkdir(dstDir)

    logging.debug('updating RTMaps component index...')

    registerDistributionPackages(sitRootPath, sitProxyPath, dryRun)
    registerNormalPackages(sitRootPath, dryRun)
    registerNormalPackages(sitProxyPath, dryRun)
コード例 #3
0
    def test_findProxyInstallations(self):
        # check if user has a valid proxy:
        sitRootPath = SIT.getParentPath()
        sitProxyPath = SIT.getPath()

        Any.requireIsDir(sitRootPath)
        Any.requireIsDir(sitProxyPath)
        ProxyDir.requireIsProxyDir(sitProxyPath)

        # create a fake package directory within the proxy...
        packageName = 'UnittestABCDEF123'
        goodNameDir = os.path.join(sitProxyPath, 'Libraries', packageName)
        goodVersionDir = os.path.join(goodNameDir, '42.0')
        badVersionDir = os.path.join(goodNameDir, '21.0')
        FastScript.mkdir(goodVersionDir)

        resultList = ProxyDir.findProxyInstallations()
        self.assertTrue(
            len(resultList) >= 1
        )  # may be greater if developer has real software installed in proxy

        self.assertTrue(goodVersionDir in resultList)
        self.assertFalse(badVersionDir in resultList)

        # clean-up
        FastScript.remove(goodNameDir)
コード例 #4
0
def getIndexBaseDir(sitProxyPath=None):
    """
        Returns the path to the user's index base directory.

        If 'sitProxyPath' is omitted then the current Proxy-SIT is used.
    """
    if sitProxyPath is None:
        sitProxyPath = SIT.getPath()

    ProxyDir.requireIsProxyDir(sitProxyPath)

    indexBaseDir = os.path.join(sitProxyPath, 'Modules', 'Index')

    return indexBaseDir
コード例 #5
0
def registerNormalPackages(sitPath, dryRun=False):
    """
        Searches the SIT for RTMaps packages and invokes
        registerHondaPackage() for each of them.
    """
    Any.requireIsDir(sitPath)
    Any.requireIsBool(dryRun)

    sitProxyPath = SIT.getPath()
    ProxyDir.requireIsProxyDir(sitProxyPath)

    searchBaseDir = os.path.join(sitPath, 'Modules', 'RTMaps')
    # Any.requireIsTextNonEmpty( searchBaseDir ) # dir. might not exist
    Any.requireIsTextNonEmpty(searchBaseDir)

    indexBaseDir = getIndexBaseDir(sitProxyPath)
    # Any.requireIsDir( indexBaseDir )           # dir. might not exist
    Any.requireIsTextNonEmpty(indexBaseDir)

    logging.debug('SIT path:       %s', sitPath)
    logging.debug('search basedir: %s', searchBaseDir)
    logging.debug('index basedir:  %s', indexBaseDir)

    # find *.pck files
    logging.debug('scanning %s...', searchBaseDir)
    pckPaths = FastScript.findFiles(searchBaseDir, ext='.pck')
    Any.requireIsList(pckPaths)

    logging.debug('found HORP files:')
    logging.debug(pckPaths)

    # process each *.pck file (tokenize path and create symlink)
    for pckPath in pckPaths:

        # the *.pck file is located on the 3rd subdirectory level relative
        # to the installRoot, so compute the installRoot based on this
        tokens = pckPath.split(os.path.sep)
        installRoot = os.path.sep.join(tokens[:-3])
        package = SIT.strip(installRoot)

        Any.requireIsDir(installRoot)
        Any.requireIsTextNonEmpty(package)

        try:
            registerNormalPackage(package, sitProxyPath, indexBaseDir, dryRun)
        except ValueError as e:
            logging.error(e)
コード例 #6
0
    def test_proxyInstallation(self):
        oldcwd = os.getcwd()
        packageName = 'ExamplePackage'
        packageVersion = '1.0'
        category = 'Applications'
        projectRoot = os.path.join('.', packageName, packageVersion)
        output = StringIO() if Any.getDebugLevel() <= 3 else None
        platform = Platforms.getHostPlatform()
        sitPath = SIT.getPath()

        # build + install package
        FastScript.changeDirectory(projectRoot)

        bst = BuildSystemTools()
        bst.setStdOut(output)
        bst.setStdErr(output)
        bst.compile()

        Any.requireIsDirNonEmpty('build')
        Any.requireIsDirNonEmpty(os.path.join('build', platform))
        Any.requireIsDirNonEmpty('examples')
        Any.requireIsDirNonEmpty(os.path.join('examples', platform))

        for fileName in ('ThreadingExampleAtomicOperation',
                         'ThreadingExampleJoin', 'ThreadingExampleTraps'):
            Any.requireIsFileNonEmpty(os.path.join('bin', platform, fileName))

        if not ProxyDir.isProxyDir(sitPath):
            self.skip("%s: Is not a proxy directory" % sitPath)

        bst.makeDocumentation()
        bst.proxyInstall()
        installRoot = os.path.join(sitPath, category, packageName,
                                   packageVersion)

        # check result
        Any.requireIsDir(installRoot)
        Any.requireIsDirNonEmpty(os.path.join(installRoot, 'bin', platform))
        Any.requireIsDirNonEmpty(os.path.join(installRoot, 'doc/html'))
        Any.requireIsFileNonEmpty(
            os.path.join(installRoot, 'doc/html/index.html'))
        Any.requireIsFileNonEmpty(os.path.join(installRoot, 'pkgInfo.py'))
        Any.requireIsFileNonEmpty(os.path.join(installRoot,
                                               'packageVar.cmake'))

        for fileName in ('ThreadingExampleAtomicOperation',
                         'ThreadingExampleJoin', 'ThreadingExampleTraps'):
            Any.requireIsFileNonEmpty(
                os.path.join(installRoot, 'bin', platform, fileName))

        # clean-up
        bst.uninstall(cleanGlobalInstallation=False)
        bst.distclean()

        self.assertFalse(os.path.exists(installRoot))

        FastScript.changeDirectory(oldcwd)
コード例 #7
0
def registerDistributionPackages(sitRootPath, sitProxyPath, dryRun=False):
    """
        Searches the SIT for packages shipped with RTMaps itself
        (by Intempora).
    """
    Any.requireIsDir(sitRootPath)
    ProxyDir.requireIsProxyDir(sitProxyPath)
    Any.requireIsBool(dryRun)

    platformList = getPlatformNames()
    rtmapsVersions = getVersionsAvailable(sitRootPath)

    Any.requireIsListNonEmpty(platformList)
    Any.requireIsListNonEmpty(rtmapsVersions)

    installBaseDir = os.path.join(sitRootPath, 'External', 'RTMaps')

    indexBaseDir = getIndexBaseDir(sitProxyPath)
    # Any.requireIsDir( indexBaseDir )           # dir. might not exist
    Any.requireIsTextNonEmpty(indexBaseDir)

    # find *.pck files shipped with RTMaps
    for rtmapsVersion in rtmapsVersions:
        logging.debug('searching for packages shipped with RTMaps %s',
                      rtmapsVersion)

        for platform in platformList:
            searchPath = os.path.join(installBaseDir, rtmapsVersion, platform,
                                      'packages')

            pckPaths = FastScript.findFiles(searchPath, ext='.pck')
            Any.requireIsList(pckPaths)

            for pckPath in pckPaths:
                pckFile = os.path.basename(pckPath)
                Any.requireIsTextNonEmpty(pckFile)

                symlink = os.path.join(indexBaseDir, rtmapsVersion, platform,
                                       pckFile)
                target = pckPath

                FastScript.link(target, symlink, dryRun)
コード例 #8
0
    def test_createProxyDir(self):
        sitProxyPath = tempfile.mkdtemp(prefix='test-')
        sitRootPath = SIT.getRootPath()
        canonicalPath = ToolBOSSettings.canonicalPath

        Any.requireIsDir(sitRootPath)

        # proxy directory must not exist, yet (function would refuse otherwise)
        FastScript.remove(sitProxyPath)
        ProxyDir.createProxyDir(sitRootPath, sitProxyPath)

        Any.requireIsDir(os.path.join(sitProxyPath, 'Libraries'))
        Any.requireIsDir(os.path.join(sitProxyPath, 'Modules/BBCM'))
        Any.requireIsDir(os.path.join(sitProxyPath, 'Libraries'))

        self.assertTrue(
            os.path.islink(os.path.join(sitProxyPath, canonicalPath)))
        self.assertTrue(
            os.path.islink(os.path.join(sitProxyPath, 'External/java/1.8')))

        FastScript.remove(sitProxyPath)
コード例 #9
0
class TaskButtonsWidget(QGroupBox, object):
    """
        Provides a group box with the main control buttons (build, clean,
        install, run unittest,...)
    """

    build = pyqtSignal()
    clean = pyqtSignal()
    globalInstall = pyqtSignal()
    proxyInstall = pyqtSignal()
    quit = pyqtSignal()
    test = pyqtSignal()

    hasProxy = ProxyDir.isProxyDir(SIT.getPath())

    def __init__(self):
        super(QGroupBox, self).__init__('commands')

        self._buildButton = QPushButton("&build")
        self._cleanButton = QPushButton("&distclean")
        self._testButton = QPushButton("run &testsuite")
        self._proxyInstButton = QPushButton("pro&xy inst.")
        self._globalInstButton = QPushButton("global &inst.")
        self._quitButton = QPushButton("&quit")

        self._cleanButton.setToolTip('delete build artefacts')
        self._buildButton.setToolTip('compile for selected platforms')
        self._proxyInstButton.setToolTip('install into Proxy-SIT')
        self._globalInstButton.setToolTip('globally install into SIT')
        self._testButton.setToolTip('start unittest (if present)')

        if not self.hasProxy:
            self._proxyInstButton.setToolTip('No Proxy-SIT available')
            self._proxyInstButton.setEnabled(False)

        self._cleanButton.pressed.connect(self.clean.emit)
        self._buildButton.pressed.connect(self.build.emit)
        self._proxyInstButton.pressed.connect(self.proxyInstall.emit)
        self._globalInstButton.pressed.connect(self.globalInstall.emit)
        self._testButton.pressed.connect(self.test.emit)
        self._quitButton.pressed.connect(self.quit.emit)

        # set start-up focus and run
        self._buildButton.setFocus()

        self._layout = QGridLayout()
        self._layout.addWidget(self._cleanButton, 1, 1)
        self._layout.addWidget(self._buildButton, 1, 2)
        self._layout.addWidget(self._proxyInstButton, 2, 1)
        self._layout.addWidget(self._globalInstButton, 2, 2)
        self._layout.addWidget(self._testButton, 3, 1)
        self._layout.addWidget(self._quitButton, 3, 2)


        if not os.path.exists( 'unittest.sh' ) and \
           not os.path.exists( 'unittest.bat' ):

            self._testButton.setEnabled(False)
            self._testButton.setToolTip(
                'unittest.sh or unittest.bat not found')

        self.setLayout(self._layout)

    def setEnabled(self, status, button='all'):
        Any.requireIsBool(status)
        Any.requireIsTextNonEmpty(button)

        if button == 'all':
            self._buildButton.setEnabled(status)
            self._cleanButton.setEnabled(status)
            self._globalInstButton.setEnabled(status)
            self._proxyInstButton.setEnabled(status and self.hasProxy)
            self._testButton.setEnabled(status)

        elif button == 'build':
            self._buildButton.setEnabled(status)

        elif button == 'clean':
            self._cleanButton.setEnabled(status)

        elif button == 'globalInstall':
            self._globalInstButton.setEnabled(status)

        elif button == 'proxyInstall':
            self._proxyInstButton.setEnabled(status and self.hasProxy)

        elif button == 'test':
            self._testButton.setEnabled(status)

        else:
            raise ValueError('unknown button: %s' % button)
コード例 #10
0
    def __init__(self, model):
        super(DependenciesDialog, self).__init__()

        Any.requireIsInstance(model, QtPackageModel.BSTPackageModel)

        numColumns = 4

        self._model = model
        self._treeMode = True
        self._reverseMode = False
        self._tree = None
        self._treeWidget = QTreeWidget()
        self._red = QColor(255, 120, 120)
        self._green = QColor(220, 255, 220)
        self._grey = QColor(240, 240, 240)
        self._canonicalPath = self._model.getCanonicalPath()
        self._sitProxyPath = SIT.getPath()
        self._sitRootPath = SIT.getRootPath()
        self._hasProxy = ProxyDir.isProxyDir(self._sitProxyPath)

        # obtain data and create one QTreeWidgetItem for each
        self._data1 = self._model.getDependencySet()
        self._data2 = self._model.getDependencyTree()
        self._data3 = self._model.getReverseDependencySet()
        self._data4 = self._model.getReverseDependencyTree()

        self._aptCmd = self._model.getDepInstallCmd_APT()

        logging.debug('data1: %s', self._data1)
        logging.debug('data2: %s', self._data2)
        logging.debug('data3: %s', self._data3)
        logging.debug('data4: %s', self._data4)

        depsEnabled = self._data1 is not None and self._data2 is not None
        revDepsEnabled = self._data3 is not None and self._data4 is not None

        if depsEnabled:
            self._tree1 = self._createTreeWidgetFromSet(self._data1, False)
            self._tree2 = self._createTreeWidgetFromList(self._data2, False)

        if revDepsEnabled:
            self._tree3 = self._createTreeWidgetFromSet(self._data3, True)
            self._tree4 = self._createTreeWidgetFromList(self._data4, True)

        if not depsEnabled and not revDepsEnabled:
            logging.error('unable to show dependency-dialog')
            return

        depsTooltip = 'low-level packages needed by the current one'

        if revDepsEnabled:
            revDepsTooltip = 'high-level packages which use the current one'
        else:
            revDepsTooltip = 'not globally installed --> no reverse dependencies'

        self._depRadio_direct = QRadioButton('&dependencies')
        self._depRadio_direct.setChecked(True)
        self._depRadio_direct.setToolTip(depsTooltip)
        self._depRadio_direct.clicked.connect(self._showDependencies)

        self._depRadio_reverse = QRadioButton('&reverse dependencies')
        self._depRadio_reverse.setToolTip(revDepsTooltip)
        self._depRadio_reverse.setEnabled(revDepsEnabled)
        self._depRadio_reverse.clicked.connect(self._showReverseDependencies)

        depSelectLayout = QVBoxLayout()
        depSelectLayout.addWidget(self._depRadio_direct)
        depSelectLayout.addWidget(self._depRadio_reverse)

        depSelectWidget = QGroupBox('direction')
        depSelectWidget.setLayout(depSelectLayout)

        # initial / default view: show own dependencies as tree
        self._tree = self._tree2
        self._updateView()

        self._treeWidget.setColumnCount(numColumns)
        self._treeWidget.setRootIsDecorated(
            False)  # top-left has no parent line
        self._treeWidget.setSortingEnabled(False)

        header = self._treeWidget.header()
        header.setStretchLastSection(False)
        header.setSectionResizeMode(
            0, QHeaderView.Stretch)  # stretch first column

        headerWidget = QTreeWidgetItem([
            'dependency', 'installed in proxy SIT', 'installed in global SIT',
            'installed locally'
        ])

        for i in range(1, numColumns):
            header.setSectionResizeMode(i, QHeaderView.ResizeToContents)
            headerWidget.setTextAlignment(i, Qt.AlignCenter)

        self._treeWidget.setHeaderItem(headerWidget)

        self._aptLabel = QLabel('Debian/Ubuntu packages needed:')

        self._aptWidget = QTextEdit(self._aptCmd)
        self._aptWidget.setFixedHeight(100)
        self._aptWidget.setFontFamily("Courier New")
        self._aptWidget.setReadOnly(True)

        toggleView = QPushButton('&toggle tree/flat view')
        toggleView.pressed.connect(self._toggleTree)

        self._expandButton = QPushButton('&expand all')
        self._expandButton.pressed.connect(self._treeWidget.expandAll)

        self._collapseButton = QPushButton('&collapse all')
        self._collapseButton.pressed.connect(self._treeWidget.collapseAll)
        self._collapseButton.pressed.connect(
            lambda: self._tree.setExpanded(True))

        closeButton = QPushButton('&OK')
        closeButton.pressed.connect(self.close)

        buttonLayout = QHBoxLayout()
        buttonLayout.setAlignment(Qt.AlignRight)
        buttonLayout.addWidget(toggleView)
        buttonLayout.addSpacing(1)
        buttonLayout.addWidget(self._expandButton)
        buttonLayout.addWidget(self._collapseButton)
        buttonLayout.addWidget(closeButton)

        buttonWidget = QWidget()
        buttonWidget.setLayout(buttonLayout)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(depSelectWidget)
        mainLayout.addWidget(self._treeWidget)
        mainLayout.addWidget(self._aptLabel)
        mainLayout.addWidget(self._aptWidget)
        mainLayout.addWidget(buttonWidget)

        # noinspection PyArgumentList
        screen = QApplication.desktop().screenGeometry()

        dialogWidth = screen.width() * 0.5
        dialogHeight = screen.height() * 0.75

        self.setLayout(mainLayout)
        self.setWindowTitle('Dependencies of %s' % self._canonicalPath)
        self.resize(dialogWidth, dialogHeight)
        self.move(screen.center() - self.rect().center())  # center
        self.show()
コード例 #11
0
desc = 'Lists all packages installed only in your SIT sandbox ("proxy directory").'

argman = ArgsManagerV2.ArgsManager(desc)

argman.addExample('%prog')

args = vars(argman.run())

verbose = args['verbose']

#----------------------------------------------------------------------------
# Main program
#----------------------------------------------------------------------------

try:
    packageList = ProxyDir.findProxyInstallations(checkLinks=True)

except AssertionError as details:
    logging.error(details)
    sys.exit(-1)

# suppress the specific package "Modules/Index/*" which contains
# registered components for DTBOS/RTMaps (see JIRA ticket TBCORE-910)
sitPath = SIT.getPath()
indexPath = os.path.join(sitPath, 'Modules/Index')

for project in packageList:

    if not project.startswith(indexPath) or verbose:
        print(project)
コード例 #12
0
dryRun = args['dry_run']
find = args['find']
linkNewPackagesIntoProxy = args['no_new']
removeBrokenSymlinks = args['keep_broken']
removeEmptyCategories = args['keep_empty']
removeProxyInstallations = args['remove']
updateRTMapsIndex = args['keep_index']

#----------------------------------------------------------------------------
# Main program
#----------------------------------------------------------------------------

if find:

    try:
        for project in ProxyDir.findProxyInstallations(checkLinks=True):
            print(project)
        sys.exit(0)

    except AssertionError as details:
        logging.error(details)
        sys.exit(-1)

else:

    try:
        UserSetup.silentUpgrade()
        ProxyDir.updateProxyDir(removeBrokenSymlinks, removeEmptyCategories,
                                linkNewPackagesIntoProxy, checkProxyLinkTarget,
                                checkProxyLinkedVersion,
                                removeProxyInstallations, cleanHomeDirectory,
コード例 #13
0
#----------------------------------------------------------------------------
# Commandline parsing
#----------------------------------------------------------------------------


logging.basicConfig( level=logging.DEBUG )


# TBCORE-1215: consider $SIT as default root path if present (and not a proxy)

sitEnvVar = FastScript.getEnv( 'SIT' )

if sitEnvVar:

    if ProxyDir.isProxyDir( sitEnvVar ):
        sitRootPath  = SIT.getDefaultRootPath()
    else:
        sitRootPath  = sitEnvVar

else:
    sitRootPath = SIT.getDefaultRootPath()


sitProxyPath     = SIT.getDefaultProxyPath()
sitVersion       = SIT.getVersion()


# Replace the username in the sitProxyPath by a generic placeholder so that
# the unittests relying on the consistent output will pass, see TBCORE-1378.
#