Пример #1
0
def fVersionCheck():
    import os, sys
    axModules = [
        ("BugId", "__main__", oVersionInformation),
        ("cBugId", "cBugId", cBugId.oVersionInformation),
        ("mFileSystem", "mFileSystem", mFileSystem.oVersionInformation),
        ("mWindowsAPI", "mWindowsAPI", mWindowsAPI.oVersionInformation),
        ("oConsole", "oConsole", oConsole.oVersionInformation),
    ]
    uCounter = 0
    for (sModuleName, sSysModuleName, oModuleVersionInformation) in axModules:
        assert sModuleName == oModuleVersionInformation.sProjectName, \
            "Module %s reports that it is called %s" % (sModuleName, oModuleVersionInformation.sProjectName)
        sInstallationPath = os.path.dirname(
            sys.modules[sSysModuleName].__file__)
        oConsole.fPrint("+ ", INFO, oModuleVersionInformation.sProjectName, NORMAL, " version: ", INFO, \
            oModuleVersionInformation.sCurrentVersion, NORMAL, ", installed at ", INFO, sInstallationPath, NORMAL, ".")
        oConsole.fProgressBar(uCounter * 1.0 / len(axModules), \
            "* Checking %s for updates..." % oModuleVersionInformation.sProjectName)
        if oModuleVersionInformation.bPreRelease:
            oConsole.fPrint("  + You are running a ", HILITE, "pre-release",
                            NORMAL, " version. ",
                            "The latest release version is ", INFO,
                            oModuleVersionInformation.sLatestVersion, NORMAL,
                            ".")
        elif not oModuleVersionInformation.bUpToDate:
            oConsole.fPrint("  + Version ", INFO,
                            oModuleVersionInformation.sLatestVersion, NORMAL,
                            " is available at ", INFO,
                            oModuleVersionInformation.sUpdateURL, NORMAL, ".")
        uCounter += 1
    oConsole.fPrint("+ Windows version: ", INFO,
                    str(mWindowsAPI.oWindowsVersion), NORMAL, ".")
    oConsole.fPrint()
Пример #2
0
def fuVersionCheck():
  axModules = [
    ("BugId",       sys.modules["__main__"],        oVersionInformation,                              None),
    ("cBugId",      sys.modules[cBugId.__module__], getattr(cBugId, "oVersionInformation", None),     getattr(cBugId, "fsVersionCheck", None)),
    ("FileSystem",  FileSystem,                     getattr(FileSystem, "oVersionInformation", None), getattr(FileSystem, "fsVersionCheck", None)),
    ("Kill",        Kill,                           getattr(Kill, "oVersionInformation", None),       getattr(Kill, "fsVersionCheck", None)),
  ];
  uCounter = 0;
  for (sModuleName, oModule, oModuleVersionInformation, fsVersionCheck) in axModules:
    if oModuleVersionInformation:
      assert sModuleName == oModuleVersionInformation.sProjectName, \
          "Module %s reports that it is called %s" % (sModuleName, oModuleVersionInformation.sProjectName);
      oConsole.fPrint("+ ", oModuleVersionInformation.sProjectName, " version ", oModuleVersionInformation.sCurrentVersion, ".");
      oConsole.fProgressBar(uCounter * 1.0 / len(axModules), "* Checking %s for updates..." % oModuleVersionInformation.sProjectName);
      if oModuleVersionInformation.bPreRelease:
        oConsole.fPrint("  + You are running a ", HILITE, "pre-release", NORMAL, " version. ",
            "The latest release version is ", INFO, oModuleVersionInformation.sLatestVersion, NORMAL, ".");
      elif not oModuleVersionInformation.bUpToDate:
        oConsole.fPrint("  + Version ", INFO, oModuleVersionInformation.sLatestVersion, NORMAL,
            " is available at ", INFO, oModuleVersionInformation.sUpdateURL, NORMAL, ".");
    elif fsVersionCheck:
      oConsole.fPrint("* ", INFO, sModuleName, NORMAL, " version check reports: ", INFO, fsVersionCheck(), ".");
    else:
      oConsole.fPrint("- You are running an ", ERROR, "outdated", NORMAL, " version of ", INFO, sModuleName, NORMAL, ".");
    oConsole.fPrint("  + Installation path: %s" % os.path.dirname(oModule.__file__));
    uCounter += 1;
  oConsole.fPrint();
  return 0;
Пример #3
0
def fVersionCheck():
    import os, platform, sys
    oConsole.fLock()
    try:
        oConsole.fPrint("+ ", INFO, "Windows", NORMAL, " version: ", INFO, mWindowsAPI.oWindowsVersion.sProductName, \
          NORMAL, " release ", INFO, mWindowsAPI.oWindowsVersion.sReleaseId, NORMAL, ", build ", INFO, \
          mWindowsAPI.oWindowsVersion.sCurrentBuild, NORMAL, " ", INFO, mWindowsAPI.oWindowsVersion.sISA, NORMAL, ".")
        oConsole.fPrint("+ ", INFO, "Python", NORMAL, " version: ", INFO, str(platform.python_version()), NORMAL, " ", \
          INFO, mWindowsAPI.fsGetPythonISA(), NORMAL, ".")
        axModules = [
            ("BugId", "__main__", oVersionInformation),
            ("cBugId", "cBugId", cBugId.oVersionInformation),
            ("mFileSystem", "mFileSystem", mFileSystem.oVersionInformation),
            ("mWindowsAPI", "mWindowsAPI", mWindowsAPI.oVersionInformation),
            ("oConsole", "oConsole", oConsole.oVersionInformation),
        ]
        uCounter = 0
        for (sModuleName, sSysModuleName,
             oModuleVersionInformation) in axModules:
            assert sModuleName == oModuleVersionInformation.sProjectName, \
                "Module %s reports that it is called %s" % (sModuleName, oModuleVersionInformation.sProjectName)
            sInstallationPath = os.path.dirname(
                sys.modules[sSysModuleName].__file__)
            oConsole.fPrint("+ ", INFO, oModuleVersionInformation.sProjectName, NORMAL, " version: ", INFO, \
                oModuleVersionInformation.sCurrentVersion, NORMAL, ", installed at ", INFO, sInstallationPath, NORMAL, ".")
            oConsole.fProgressBar(uCounter * 1.0 / len(axModules), \
                "* Checking %s for updates..." % oModuleVersionInformation.sProjectName)
            if oModuleVersionInformation.bPreRelease:
                oConsole.fPrint("  You are running a ", HILITE, "pre-release",
                                NORMAL, " version: ",
                                "the latest release version is ", INFO,
                                oModuleVersionInformation.sLatestVersion,
                                NORMAL, ".")
            elif not oModuleVersionInformation.bUpToDate:
                oConsole.fPrint("  Version ", HILITE,
                                oModuleVersionInformation.sLatestVersion,
                                NORMAL, " is available at ", HILITE,
                                oModuleVersionInformation.sUpdateURL, NORMAL,
                                ".")
            uCounter += 1
        oConsole.fPrint()
    finally:
        oConsole.fUnlock()
Пример #4
0
def fPrintVersionInformation(bCheckForUpdates, bCheckAndShowLicenses, bShowInstallationFolders):
  # Read product details for rs and all modules it uses.
  aoProductDetails = mProductDetails.faoGetProductDetailsForAllLoadedModules();
  oMainProductDetails = mProductDetails.foGetProductDetailsForMainModule();
  if bCheckForUpdates:
    uCheckedProductCounter = 0;
    for oProductDetails in aoProductDetails:
      oConsole.fProgressBar(
        uCheckedProductCounter * 1.0 / len(aoProductDetails),
        "Checking %s for updates..." % oProductDetails.sProductName,
      );
      try:
        oProductDetails.oLatestProductDetailsFromRepository;
      except Exception as oException:
        oConsole.fPrint(
          ERROR, u"- Version check for ", ERROR_INFO, oProductDetails.sProductName,
          ERROR, " failed: ", ERROR_INFO, str(oException),
        );
      uCheckedProductCounter += 1;
  oConsole.fLock();
  try:
    if bCheckAndShowLicenses:
      aoLicenses = [];
      asLicensedProductNames = [];
      asProductNamesInTrial = [];
      asUnlicensedProductNames = [];
      for oProductDetails in aoProductDetails:
        if oProductDetails.oLicense:
          if oProductDetails.oLicense not in aoLicenses:
            aoLicenses.append(oProductDetails.oLicense);
          asLicensedProductNames.append(oProductDetails.sProductName);
        elif oProductDetails.bHasTrialPeriod and oProductDetails.bInTrialPeriod:
          asProductNamesInTrial.append(oProductDetails.sProductName);
        else:
          asUnlicensedProductNames.append(oProductDetails.sProductName);

      oLicenseCheckServer = mProductDetails.cLicenseCheckServer(oMainProductDetails.sLicenseServerURL);
      uCheckedLicenseCounter = 0;
      for oLicense in aoLicenses:
        oConsole.fProgressBar(
          uCheckedLicenseCounter * 1.0 / len(aoLicenses),
          "Checking license %s with server..." % oLicense.sLicenseId,
        );
        sLicenseCheckServerError = oLicense.fsCheckWithServerAndGetError(oLicenseCheckServer, bForceCheck = True);
        if sLicenseCheckServerError:
          oConsole.fPrint(
            ERROR, u"- License check for ", ERROR_INFO, oLicense.sLicenseId,
            ERROR, " on server ", ERROR_INFO, oMainProductDetails.sLicenseServerURL,
            ERROR, " failed: ", ERROR_INFO, sLicenseCheckServerError,
          );
        uCheckedLicenseCounter += 1;
    
    oConsole.fPrint(
      u"\u250C\u2500 ", INFO, "Version information", NORMAL, " ", sPadding = u"\u2500"
    );
    # Output the BugId product information first, then its dependencies:
    fPrintProductDetails(oMainProductDetails, bIsMainProduct = True, bShowInstallationFolders = bShowInstallationFolders);
    for oProductDetails in aoProductDetails:
      if oProductDetails != oMainProductDetails:
        fPrintProductDetails(oProductDetails, bIsMainProduct = False, bShowInstallationFolders = bShowInstallationFolders);
    
    oConsole.fPrint(
      u"\u2502 \u2219 ", INFO, "Windows",
      NORMAL, " version: ", INFO, oSystemInfo.sOSName,
      NORMAL, " release ", INFO, oSystemInfo.sOSReleaseId,
      NORMAL, ", build ", INFO, oSystemInfo.sOSBuild,
      NORMAL, " ", INFO, oSystemInfo.sOSISA,
      NORMAL, ".",
    );
    oConsole.fPrint(
      u"\u2502 \u2219 ", INFO, "Python",
      NORMAL, " version: ", INFO, str(platform.python_version()),
      NORMAL, " ", INFO, fsGetPythonISA(),
      NORMAL, ".",
    );
    
    if bCheckAndShowLicenses:
      oConsole.fPrint(
        u"\u251C\u2500 ", INFO, "License information", NORMAL, " ", sPadding = u"\u2500",
      );
      if aoLicenses:
        oConsole.fPrint(
          NORMAL, u"\u2502 \u2219 This system is registered with id ", INFO, mProductDetails.fsGetSystemId(), NORMAL, " on the license server",
        );
      for oLicense in aoLicenses:
        oConsole.fPrint(
          u"\u2502 \u2219 License ", INFO, oLicense.sLicenseId,
          NORMAL, " for ", INFO, oLicense.asProductNames[0], 
          NORMAL, " covers ", INFO, oLicense.sUsageTypeDescription, 
          NORMAL, " by ", INFO, oLicense.sLicenseeName,
          NORMAL, " of the following products:",
        );
        oConsole.fPrint(u"\u2502     ", faxListOutput(oLicense.asProductNames, "and", INFO, NORMAL));
      if asProductNamesInTrial:
        oConsole.fPrint(*(
          [
            u"\u2502 \u2219 "
          ] + faxListOutput(asProductNamesInTrial, "and", WARNING_INFO, WARNING)  + [
            WARNING, " ", len(asProductNamesInTrial) == 1 and "is" or "are", " not covered by a valid, active license but ",
            len(asProductNamesInTrial) == 1 and "it is in its" or "they are in their", " trial period.",
          ]
        ));
      if asUnlicensedProductNames:
        oConsole.fPrint(*(
          [
            u"\u2502 \u2219 "
          ] + faxListOutput(asUnlicensedProductNames, "and", ERROR_INFO, ERROR)  + [
            ERROR, " ", len(asProductNamesInTrial) == 1 and "is" or "are", " not covered by a valid, active license and ",
            len(asProductNamesInTrial) == 1 and "has exceeded its" or "have exceeded their", " trial period.",
          ]
        ));
    oConsole.fPrint(
      u"\u2514", sPadding = u"\u2500",
    );
    oConsole.fPrint();
  finally:
    oConsole.fUnlock();

  (asLicenseErrors, asLicenseWarnings) = mProductDetails.ftasGetLicenseErrorsAndWarnings();
  if asLicenseErrors:
    oConsole.fLock();
    try:
      oConsole.fPrint(ERROR, u"\u250C\u2500", ERROR_INFO, " Software license error ", ERROR, sPadding = u"\u2500");
      for sLicenseError in asLicenseErrors:
        oConsole.fPrint(ERROR, u"\u2502 ", ERROR_INFO, sLicenseError);
      oConsole.fPrint(ERROR, u"\u2514", sPadding = u"\u2500");
    finally:
      oConsole.fUnlock();
  if asLicenseWarnings:
    oConsole.fLock();
    try:
      oConsole.fPrint(WARNING, u"\u250C\u2500", WARNING_INFO, " Software license warning ", WARNING, sPadding = u"\u2500");
      for sLicenseWarning in asLicenseWarnings:
        oConsole.fPrint(WARNING, u"\u2502 ", WARNING_INFO, sLicenseWarning);
      oConsole.fPrint(WARNING, u"\u2514", sPadding = u"\u2500");
    finally:
      oConsole.fUnlock();
Пример #5
0
    for uBackground in xrange(0, 0x10):
        asLineOutput = []
        for uForeground in xrange(0, 0x10, 1):
            uColor = uForeground + uBackground * 0x10
            asLineOutput.extend([0xFF00 + uColor, "##"])
        oConsole.fPrint(*asLineOutput)

    # Use a large value, as this will be very slow unless the progress bar is not drawn when it's not changed as it should be.
    uStartTime = time.time()
    uEndTime = uStartTime + nDelayInSecondsForVisualChecks
    while 1:
        nProgress = (time.time() - uStartTime) / nDelayInSecondsForVisualChecks
        if nProgress > 1:
            break
        oConsole.fProgressBar(
            nProgress, "Screen width = %d" % (oConsole.uWindowWidth or 100))

    if oConsole.uWindowWidth is not None:
        # These tests apply to non-redirected output (to a window) only
        sTestMessage = "\t\tx\tTabs to spaces"
        uTestMessageLength = len(sTestMessage)
        oConsole.fStatus(sTestMessage)
        assert oConsole.uLastLineLength == uTestMessageLength, \
            "Expected last line to be %d chars, got %d" % (uTestMessageLength, oConsole.uLastLineLength)
        uTestMessageLength = len(
            sTestMessage.replace("\t\tx\t", "12341234x234"))
        oConsole.fStatus(sTestMessage, uConvertTabsToSpaces=4)
        assert oConsole.uLastLineLength == uTestMessageLength, \
            "Expected last line to be %d chars, got %d" % (uTestMessageLength, oConsole.uLastLineLength)

    oConsole.fPrint(0xFF1E, "Padding test", sPadding=" -")