Esempio n. 1
0
 def fStatusThread(oSelf):
     try:
         bMatchingPath = oSelf.arPathRegExps or oSelf.arNegativePathRegExps
         bMatchingName = oSelf.arNameRegExps or oSelf.arNegativeNameRegExps
         bMatchingPathOrName = bMatchingPath or bMatchingName
         while oSelf.oScanThreadsStarted.uValue != oSelf.oScanThreadsFinished.uValue and not oSelf.oException:
             uNumberOfItemsFound = oSelf.oNumberOfItemsFound.uValue
             uNumberOfFilesFound = oSelf.oNumberOfFilesFound.uValue
             uNumberOfFoldersFound = oSelf.oNumberOfFoldersFound.uValue
             uNumberOfItemsCompleted = oSelf.oNumberOfItemsCompleted.uValue
             uNumberOfItemsRemaining = uNumberOfItemsFound - uNumberOfFoldersFound - uNumberOfFilesFound
             nProgress = 1.0 * uNumberOfItemsCompleted / uNumberOfItemsFound if uNumberOfItemsFound else 0
             nSubProgress = 1.0 * oSelf.oMatchesByFilePath.uSize / uNumberOfFilesFound if uNumberOfFilesFound else 0
             oConsole.fProgressBar(
                 nProgress,
                 sMessage="%s%d files (%d/%d items remaining)" % (
                     "Matched %s for %d/" % (
                         " and ".join([
                             s for s in [
                                 "path" if bMatchingPath else None,
                                 "name" if bMatchingName else None,
                             ] if s
                         ]),
                         oSelf.oMatchesByFilePath.uSize,
                     ) if bMatchingPathOrName else "Found ",
                     uNumberOfFilesFound,
                     uNumberOfItemsRemaining,
                     uNumberOfItemsFound,
                 ),
                 nSubProgress=nSubProgress,
             )
             time.sleep(0.25)
     except Exception as oException:
         oSelf.oException = oException
         raise
 def fStatusThread(oSelf):
     try:
         while oSelf.oScanThreadsStarted.uValue != oSelf.oScanThreadsFinished.uValue and not oSelf.oException:
             nProgress = 1.0 * oSelf.oFileScansFinished.uValue / oSelf.uNumberOfFiles
             sStatus = "Matched content in %d files (%d/%d remaining)" % (
                 len(oSelf.dMatched_auLineNumbers_by_sFilePath),
                 oSelf.uNumberOfFiles - oSelf.oFileScansFinished.uValue,
                 oSelf.uNumberOfFiles,
             )
             oConsole.fProgressBar(nProgress, sStatus)
             time.sleep(0.25)
     except Exception as oException:
         oSelf.oException = oException
         raise
Esempio n. 3
0
def fOutputVersionInformation(bCheckForUpdates,
                              bShowInstallationFolders,
                              dsAdditionalVersion_by_sName={}):
    # Read product details for rs and all modules it uses.
    aoProductDetails = mProductDetails.faoGetProductDetailsForAllLoadedModules(
    )
    o0MainProductDetails = mProductDetails.fo0GetProductDetailsForMainModule()
    oConsole.fLock()
    try:
        aoProductDetailsCheckedForUpdates = []
        aoProductDetailsSuccessfullyCheckedForUpdates = []
        if bCheckForUpdates:
            for oProductDetails in aoProductDetails:
                if oProductDetails.o0Repository is None:
                    continue
                aoProductDetailsCheckedForUpdates.append(oProductDetails)
                oConsole.fProgressBar(
                    len(aoProductDetailsCheckedForUpdates) * 1.0 /
                    len(aoProductDetails),
                    "Checking %s for updates..." %
                    oProductDetails.sProductName,
                )
                try:
                    oProductDetails.foGetLatestProductDetailsFromRepository()
                except mProductDetails.mExceptions.cProductDetailsException as oException:
                    oConsole.fOutput(
                        COLOR_ERROR,
                        CHAR_ERROR,
                        COLOR_NORMAL,
                        " Version check for ",
                        COLOR_INFO,
                        oProductDetails.sProductName,
                        COLOR_NORMAL,
                        " failed: ",
                        COLOR_INFO,
                        str(oException),
                    )
                else:
                    aoProductDetailsSuccessfullyCheckedForUpdates.append(
                        oProductDetails)
            if len(aoProductDetailsSuccessfullyCheckedForUpdates) == 0:
                oConsole.fOutput(
                    COLOR_WARNING,
                    CHAR_WARNING,
                    COLOR_NORMAL,
                    "Failed to get any product version information.",
                )
                oConsole.fOutput(
                    "  (This often indicates you are running a ",
                    COLOR_INFO,
                    "pre-release",
                    COLOR_NORMAL,
                    " version, or a version that is very ",
                    COLOR_INFO,
                    "out of date",
                    COLOR_NORMAL,
                    ").",
                )
                oConsole.fOutput(
                    "  To try and resolve this issue, please update this product to the latest",
                )
                oConsole.fOutput("  version and try again.", )

        if f0OutputLogo:
            f0OutputLogo()

        oConsole.fOutput(
            "┌───[",
            COLOR_HILITE,
            " Version information ",
            COLOR_NORMAL,
            "]",
            sPadding="─",
        )
        # Output the main product information first, then its dependencies alphabetically:
        if o0MainProductDetails:
            fOutputProductDetails(
                o0MainProductDetails,
                bIsMainProduct=True,
                bShowInstallationFolders=bShowInstallationFolders,
                bCheckForUpdates=bCheckForUpdates,
                bCheckForUpdatesSuccessful=o0MainProductDetails
                in aoProductDetailsSuccessfullyCheckedForUpdates,
            )
        doRemainingProductDetails_by_sName = dict([
            (oProductDetails.sProductName, oProductDetails)
            for oProductDetails in aoProductDetails
            if oProductDetails != o0MainProductDetails
        ])
        for sProductName in sorted(doRemainingProductDetails_by_sName.keys()):
            oProductDetails = doRemainingProductDetails_by_sName[sProductName]
            fOutputProductDetails(
                oProductDetails,
                bIsMainProduct=False,
                bShowInstallationFolders=bShowInstallationFolders,
                bCheckForUpdates=bCheckForUpdates,
                bCheckForUpdatesSuccessful=oProductDetails
                in aoProductDetailsSuccessfullyCheckedForUpdates,
            )
        asProductNames = (([o0MainProductDetails.sProductName]
                           if o0MainProductDetails else []) +
                          list(doRemainingProductDetails_by_sName.keys()))

        oConsole.fOutput(
            "│ ",
            CHAR_LIST,
            " ",
            COLOR_INFO,
            "Windows",
            COLOR_NORMAL,
            " version: ",
            COLOR_INFO,
            oSystemInfo.sOSName,
            COLOR_NORMAL,
            " release ",
            COLOR_INFO,
            oSystemInfo.sOSReleaseId,
            COLOR_NORMAL,
            ", build ",
            COLOR_INFO,
            oSystemInfo.sOSBuild,
            COLOR_NORMAL,
            " ",
            COLOR_INFO,
            oSystemInfo.sOSISA,
            COLOR_NORMAL,
            ".",
        )
        oConsole.fOutput(
            "│ ",
            CHAR_LIST,
            " ",
            COLOR_INFO,
            "Python",
            COLOR_NORMAL,
            " version: ",
            COLOR_INFO,
            str(platform.python_version()),
            COLOR_NORMAL,
            " ",
            COLOR_INFO,
            fsGetPythonISA(),
            COLOR_NORMAL,
            ".",
        )

        for (sName, sVersion) in dsAdditionalVersion_by_sName.items():
            oConsole.fOutput(
                "│ ",
                CHAR_LIST,
                " ",
                COLOR_INFO,
                sName,
                COLOR_NORMAL,
                " version: ",
                COLOR_INFO,
                sVersion,
                COLOR_NORMAL,
                ".",
            )

        oConsole.fOutput(
            "└",
            sPadding="─",
        )
    finally:
        oConsole.fUnlock()
Esempio n. 4
0
 uTotalFiles = len(doInputFile_by_sRelativePathInOutputZip);
 if bVerbose:
   oConsole.fOutput(
     "* Adding ",
     COLOR_INFO, str(uTotalFiles),
     COLOR_NORMAL, " files to ",
     COLOR_INFO, oOutputZipFile.sPath,
     COLOR_NORMAL, ":",
   );
 uProcessedBytes = 0;
 uProcessedFiles = 0;
 for sRelativePath in fasSortedAlphabetically(doInputFile_by_sRelativePathInOutputZip.keys()):
   oInputFile = doInputFile_by_sRelativePathInOutputZip[sRelativePath];
   oOutputFile = oOutputZipFile.fo0GetDescendant(sRelativePath, bParseZipFiles = True);
   nProgress = 1.0 * uProcessedFiles / uTotalFiles;
   oConsole.fProgressBar(nProgress, "* %s: Reading..." % sRelativePath);
   sb0Data = oInputFile.fsb0Read(bThrowErrors = False);
   if sb0Data is None:
     oConsole.fOutput(
       COLOR_ERROR, CHAR_ERROR,
       COLOR_NORMAL, " Cannot read input file ",
       COLOR_INFO, oInputFile.sPath,
       COLOR_NORMAL, "!",
     );
     sys.exit(guExitCodeCannotReadFRomFileSystem);
   if oOutputFile.fbIsFile(bParseZipFiles = True):
     oConsole.fProgressBar(nProgress, "* %s: Overwriting (%s)..." % (sRelativePath, fsBytesToHumanReadableString(len(sb0Data))));
     if not oOutputFile.fbWrite(sb0Data):
       oConsole.fOutput(
         COLOR_ERROR, CHAR_ERROR,
         COLOR_NORMAL, " Cannot write ",
Esempio n. 5
0
def fOutputLicenseInformation(bUpdateIfNeeded=False):
    # Read product details for rs and all modules it uses.
    aoProductDetails = mProductDetails.faoGetProductDetailsForAllLoadedModules(
    )
    o0MainProductDetails = mProductDetails.fo0GetProductDetailsForMainModule()
    oConsole.fLock()
    try:
        aoLicenses = []
        asProductNamesWithoutLicenseRequirement = []
        asLicensedProductNames = []
        asProductNamesInTrial = []
        asUnlicensedProductNames = []
        for oProductDetails in aoProductDetails:
            if not oProductDetails.bRequiresLicense:
                asProductNamesWithoutLicenseRequirement.append(
                    oProductDetails.sProductName)
            elif oProductDetails.o0License:
                if oProductDetails.o0License not in aoLicenses:
                    aoLicenses.append(oProductDetails.o0License)
                asLicensedProductNames.append(oProductDetails.sProductName)
            elif oProductDetails.bHasTrialPeriod and oProductDetails.bInTrialPeriod:
                asProductNamesInTrial.append(oProductDetails.sProductName)
            else:
                asUnlicensedProductNames.append(oProductDetails.sProductName)

        if o0MainProductDetails and o0MainProductDetails.sb0LicenseServerURL is not None:
            oLicenseServer = mProductDetails.cLicenseServer(
                o0MainProductDetails.sb0LicenseServerURL)
            uCheckedLicenseCounter = 0
            aoUpdatedLicenses = []
            for oLicense in aoLicenses:
                oConsole.fProgressBar(
                    uCheckedLicenseCounter * 1.0 / len(aoLicenses),
                    "Checking license %s with server..." % oLicense.sLicenseId,
                )
                sLicenseServerError = oLicense.fsCheckWithServerAndGetError(
                    oLicenseServer, bForceCheck=True)
                sServerURL = str(o0MainProductDetails.sb0LicenseServerURL,
                                 "ascii", "strict")
                if sLicenseServerError:
                    oConsole.fOutput(
                        COLOR_ERROR,
                        CHAR_ERROR,
                        COLOR_NORMAL,
                        " License check for ",
                        COLOR_INFO,
                        oLicense.sLicenseId,
                        COLOR_NORMAL,
                        " on server ",
                        COLOR_INFO,
                        sServerURL,
                        COLOR_NORMAL,
                        " failed:",
                    )
                    oConsole.fOutput(
                        "  ",
                        COLOR_INFO,
                        sLicenseServerError,
                    )
                uCheckedLicenseCounter += 1
                if oLicense.bMayNeedToBeUpdated and bUpdateIfNeeded:
                    oConsole.fProgressBar(
                        uCheckedLicenseCounter * 1.0 / len(aoLicenses),
                        "Downloading updated license %s from server..." %
                        oLicense.sLicenseId,
                    )
                    oUpdatedLicense = oLicenseServer.foDownloadUpdatedLicense(
                        oLicense)
                    oConsole.fOutput(
                        COLOR_OK,
                        CHAR_OK,
                        COLOR_NORMAL,
                        " Downloaded updated license ",
                        COLOR_INFO,
                        oLicense.sLicenseId,
                        COLOR_NORMAL,
                        " from server ",
                        COLOR_INFO,
                        str(oLicenseServer.sbServerURL, "ascii", "strict"),
                        COLOR_NORMAL,
                        ".",
                    )
                    aoUpdatedLicenses.append(oUpdatedLicense)
            if len(aoUpdatedLicenses) > 0:
                for oProductDetails in aoProductDetails:
                    if oProductDetails.sb0LicenseServerURL is None:
                        continue
                        # No need for a license == do not store license
                    aoUpdatedLicensesForThisProduct = [
                        oUpdatedLicense
                        for oUpdatedLicense in aoUpdatedLicenses
                        if oProductDetails.sProductName in
                        oUpdatedLicense.asProductNames
                    ]
                    mProductDetails.fWriteLicensesToProductFolder(
                        aoUpdatedLicensesForThisProduct, oProductDetails)
                    oConsole.fOutput(
                        COLOR_OK,
                        CHAR_OK,
                        COLOR_NORMAL,
                        " Saved ",
                        COLOR_INFO,
                        str(len(aoUpdatedLicensesForThisProduct)),
                        COLOR_NORMAL,
                        " updated license",
                        ""
                        if len(aoUpdatedLicensesForThisProduct) == 1 else "s",
                        " for product ",
                        COLOR_INFO,
                        oProductDetails.sProductName,
                        COLOR_NORMAL,
                        " in folder ",
                        COLOR_INFO,
                        oProductDetails.sInstallationFolderPath,
                        COLOR_NORMAL,
                        ".",
                    )

        if f0OutputLogo:
            f0OutputLogo()

        oConsole.fOutput(
            "┌───[",
            COLOR_HILITE,
            " License information ",
            COLOR_NORMAL,
            "]",
            sPadding="─",
        )
        if aoLicenses:
            oConsole.fOutput(
                "│ ",
                COLOR_OK,
                CHAR_OK,
                COLOR_NORMAL,
                " This system uses system id ",
                COLOR_INFO,
                mProductDetails.fsGetSystemId(),
                COLOR_NORMAL,
                " with the license server.",
            )
            oConsole.fOutput(
                "├",
                sPadding="─",
            )
        for oLicense in aoLicenses:
            oConsole.fOutput(
                "│ ",
                COLOR_OK,
                CHAR_OK,
                COLOR_NORMAL,
                " License ",
                COLOR_INFO,
                oLicense.sLicenseId,
                COLOR_NORMAL,
                " covers ",
                COLOR_INFO,
                oLicense.sUsageTypeDescription,
                COLOR_NORMAL,
                " by ",
                COLOR_INFO,
                oLicense.sLicenseeName,
                COLOR_NORMAL,
                " of ",
                COLOR_INFO,
                oLicense.asProductNames[0],
                COLOR_NORMAL,
                " on ",
                COLOR_INFO,
                str(oLicense.uLicensedInstances),
                COLOR_NORMAL,
                " machine",
                "s" if oLicense.uLicensedInstances != 1 else "",
                ".",
            )
            oConsole.fOutput(
                "│   Covered products: ",
                faxListOutput(oLicense.asProductNames, "and",
                              oLicense.asProductNames, COLOR_INFO,
                              COLOR_NORMAL, COLOR_NORMAL),
                COLOR_NORMAL,
                ".",
            )
            oConsole.fOutput(
                "│   License source: ",
                COLOR_INFO,
                oLicense.sLicenseSource,
                COLOR_NORMAL,
                ".",
            )
        if asProductNamesInTrial:
            oConsole.fOutput(
                "│ ",
                COLOR_WARNING,
                CHAR_WARNING,
                COLOR_NORMAL,
                " A ",
                COLOR_INFO,
                "trial period",
                COLOR_NORMAL,
                " is active for the following product",
                "s" if len(asProductNamesInTrial) > 1 else "",
                ":",
            )
            oConsole.fOutput(
                "│   ",
                faxListOutput(asProductNamesInTrial, "and",
                              asProductNamesInTrial, COLOR_INFO, COLOR_NORMAL,
                              COLOR_NORMAL),
                COLOR_NORMAL,
                ".",
            )
        if asProductNamesWithoutLicenseRequirement:
            oConsole.fOutput(
                "│ ",
                COLOR_OK,
                CHAR_OK,
                " ",
                COLOR_INFO,
                "No license",
                COLOR_NORMAL,
                " is required to use the following product",
                "s"
                if len(asProductNamesWithoutLicenseRequirement) > 1 else "",
                ":",
            )
            oConsole.fOutput(
                "│   ",
                faxListOutput(asProductNamesWithoutLicenseRequirement, "and",
                              [], COLOR_INFO, COLOR_NORMAL, COLOR_NORMAL),
                COLOR_NORMAL,
                ".",
            )
        if asUnlicensedProductNames:
            oConsole.fOutput(
                "│ ",
                COLOR_ERROR,
                CHAR_ERROR,
                COLOR_NORMAL,
                " ",
                COLOR_INFO,
                "No valid license",
                COLOR_NORMAL,
                " was found and ",
                COLOR_INFO,
                "the trial period has been exceeded",
                COLOR_NORMAL,
                " for the following product",
                "s" if len(asUnlicensedProductNames) > 1 else "",
                ":",
            )
            oConsole.fOutput(
                "│   ",
                faxListOutput(asUnlicensedProductNames, "and",
                              asUnlicensedProductNames, COLOR_INFO,
                              COLOR_NORMAL, COLOR_NORMAL),
                COLOR_NORMAL,
                ".",
            )

        (asLicenseErrors, asLicenseWarnings
         ) = mProductDetails.ftasGetLicenseErrorsAndWarnings()
        if asLicenseErrors:
            oConsole.fOutput("├───[",
                             COLOR_ERROR,
                             " Software license error ",
                             COLOR_NORMAL,
                             "]",
                             sPadding="─")
            for sLicenseError in asLicenseErrors:
                oConsole.fOutput("│ ", COLOR_ERROR, CHAR_ERROR, COLOR_INFO,
                                 " ", sLicenseError)
        if asLicenseWarnings:
            oConsole.fOutput("├───[",
                             COLOR_WARNING,
                             " Software license warning ",
                             COLOR_NORMAL,
                             "]",
                             sPadding="─")
            for sLicenseWarning in asLicenseWarnings:
                oConsole.fOutput("│ ", COLOR_WARNING, CHAR_WARNING, COLOR_INFO,
                                 " ", sLicenseWarning)
        oConsole.fOutput("└", sPadding="─")
    finally:
        oConsole.fUnlock()
Esempio n. 6
0
 if not o0OutputFolder:
     oConsole.fOutput(
         COLOR_ERROR,
         CHAR_ERROR,
         COLOR_NORMAL,
         " Output folder ",
         COLOR_INFO,
         oOutputBaseFolder.sPath,
         COLOR_NORMAL,
         " cannot be found!",
     )
     sys.exit(guExitCodeBadArgument)
 nProgress = 1.0 * (uProcessedFolders + uProcessedFiles) / (
     len(aoInputFolders) + len(aoInputFiles))
 oConsole.fProgressBar(nProgress,
                       "* %s: Creating folder..." %
                       sRelativePath,
                       bCenterMessage=False)
 if oOutputFolder.fbExists(bParseZipFiles=True):
     if not oOutputFolder.fbIsFolder(bParseZipFiles=True):
         # File exists: error
         oConsole.fOutput(
             COLOR_ERROR,
             CHAR_ERROR,
             COLOR_NORMAL,
             "Cannot create folder ",
             COLOR_INFO,
             sRelativePath,
             COLOR_NORMAL,
             " in folder ",
             COLOR_INFO,
             oOutputBaseFolder.sPath,