Exemple #1
0
def InitialiseFWGlobals():
    global FWCodeDir
    global FWProjectsDir
    global FWShortVersion
    global FWLongVersion

    try:
        rKey = GetFWRegKey()
    except Exception as e:
        logging.exception("Couldn't find FieldWorks registry entry")
        raise

    FWCodeDir = rKey.GetValue(FWREG_CODEDIR)
    FWProjectsDir = rKey.GetValue(FWREG_PROJECTSDIR)

    # On developer's machines we also check the build directories
    # for FieldWorks.exe

    if not os.access(os.path.join(FWCodeDir, "FieldWorks.exe"), os.F_OK):
        if os.access(
                os.path.join(FWCodeDir, r"..\Output\Release\FieldWorks.exe"),
                os.F_OK):
            FWCodeDir = os.path.join(FWCodeDir, r"..\Output\Release")
        elif os.access(
                os.path.join(FWCodeDir, r"..\Output\Debug\FieldWorks.exe"),
                os.F_OK):
            FWCodeDir = os.path.join(FWCodeDir, r"..\Output\Debug")
        else:
            # This can happen if there is a ghost registry entry for
            # an uninstalled FLEx
            msg = "FieldWorks.exe not found in %s" \
                            % FWCodeDir
            logger.error(msg)
            raise Exception(msg)

    # Add the FW code directory to the search path for importing FW libs.
    sys.path.append(FWCodeDir)

    logger.info("sys.path = %s" % "\n\t".join(sys.path))

    # These can't be imported until the path is set:
    clr.AddReference("FwUtils")
    from SIL.FieldWorks.Common.FwUtils import VersionInfoProvider

    # Get the full version information out of FW itself
    vip = VersionInfoProvider(Assembly.GetAssembly(VersionInfoProvider), False)
    FWShortVersion = System.Version(vip.ShortNumericAppVersion)  # e.g. 8.1.3
    FWLongVersion = vip.ApplicationVersion

    logger.info("Found FieldWorks installation")
    logger.info("FWCodeDir = %s" % FWCodeDir)
    logger.info("FWProjectsDir = %s" % FWProjectsDir)
    logger.info("FWShortVersion = %s" % FWShortVersion)
    logger.info("FWLongVersion = %s" % FWLongVersion)
Exemple #2
0
 def client_version(self):
     """Client version
     """
     asm = Assembly.GetAssembly(OC)
     ver = asm.GetName().Version
     return (ver.Major, ver.Minor)
Exemple #3
0
InitialiseFWGlobals()

#----------------------------------------------------------------
# Add the FW code directory to the search path for importing FW libs.
sys.path.append(FWCodeDir)

#----------------------------------------------------------------
# The following imports rely on the FW Code path appended above:

if FWMajorVersion == "8":
    # Get the full version information out of FW itself
    clr.AddReference("CoreImpl")
    from SIL.CoreImpl import VersionInfoProvider
    from System.Reflection import Assembly

    vip = VersionInfoProvider(Assembly.GetAssembly(VersionInfoProvider), False)
    FWAppVersion = System.Version(vip.ShortNumericAppVersion) # e.g. 8.1.3
else:
    # Get the full version information out of FW itself
    clr.AddReference("FwUtils")
    from SIL.FieldWorks.Common.FwUtils import FwVersionInfoProvider
    from System.Reflection import Assembly

    vip = FwVersionInfoProvider(Assembly.GetAssembly(FwVersionInfoProvider), False)
    i = vip.ApplicationVersion.find(": ")
    FWAppVersion = System.Version(vip.ApplicationVersion[i+2:i+7]) # e.g. 7.2.4

FWFullVersion = vip.ApplicationVersion
print "Startup: FW Version =", FWFullVersion

clr.AddReference("SILUtils")