Skip to Content.

mget-help - RE: [mget-help] mget statistics toolbox

Please Wait...

Subject: Marine Geospatial Ecology Tools (MGET) help

Text archives


From: "Jason Roberts" <>
To: "'Weber, Marc'" <>
Cc: <>
Subject: RE: [mget-help] mget statistics toolbox
Date: Tue, 18 Mar 2014 13:37:23 -0400

Hi Marc,

 

Sorry about this. It sounds like there is an installation problem, probably with MGET but possibly with R. Unfortunately I cannot determine the root cause without knowing more information.

 

Could you please:

 

1.    Save the attached Python script to your Windows desktop.

2.    Double click on it to run it.

3.    It will create a file on the desktop called GetMoreInformation.txt. Please email me that file.

 

Thank you,

 

Jason

 

 

From: Weber, Marc [mailto:]
Sent: Tuesday, March 18, 2014 12:09 PM
To:
Subject: [mget-help] mget statistics toolbox

 

Hi-

I have mget toolbox installed, and I’m an R user with R 3.0.2 installed.  When I try to run any of the tools using R in the mget statistics toolbox, however, nothing happens – the tools run successfully, but no R window is initialized, no output file is generated if specified.  I’m guessing there is something wrong in environment variables (I’m running Windows 7), but I don’t see any mention of issues like this in documentation.  Thanks,

 

---------------------------------------------
Marc Weber

Geographer
Western Ecology Division
US EPA
200 S.W. 35th Street
Corvallis, OR 97333
Voice: (541) 754-4469
email:
---------------------------------------------

 

import os, sys, glob, traceback

outputTextFile = os.path.join(os.path.dirname(__file__), 
os.path.splitext(os.path.basename(__file__))[0] + '.txt')
f = open(outputTextFile, 'w')

f.write(__file__ + '\n')
f.write(sys.executable + '\n')

sitePackagesDir = os.path.join(os.path.dirname(sys.executable), 'Lib', 
'site-packages')

f.write(sitePackagesDir + ' : ' + repr(os.path.isdir(sitePackagesDir)) + '\n')
f.write(os.path.join(sitePackagesDir, '_GeoEcoArcGISHelper.pyd')  + ' : ' + 
repr(os.path.isdir(os.path.join(sitePackagesDir, '_GeoEcoArcGISHelper.pyd'))) 
+ '\n')
f.write(os.path.join(sitePackagesDir, 'GeoEco')  + ' : ' + 
repr(os.path.isdir(os.path.join(sitePackagesDir, 'GeoEco'))) + '\n')
f.write(sys.version + '\n')
f.write(repr(glob.glob('C:\\*')) + '\n')

if os.path.isdir(sitePackagesDir):
    f.write('\n')
    f.write(repr(glob.glob(sitePackagesDir + '\\*')) + '\n')

installedFromFile = 'C:\\Program 
Files\\GeoEco\\ArcGISToolbox\\InstalledFrom.txt'
installedFromX86File = 'C:\\Program Files 
(x86)\\GeoEco\\ArcGISToolbox\\InstalledFrom.txt'

f.write('\n')
f.write(os.path.dirname(installedFromFile) + ' : ' + 
repr(os.path.isdir(os.path.dirname(installedFromFile))) + '\n')
f.write(installedFromFile + ' : ' + repr(os.path.isfile(installedFromFile)) + 
'\n')
if os.path.isfile(installedFromFile):
    try:
        f2 = file(installedFromFile, 'rU')
        f.write(f2.read())
        f2.close()
    except:
        pass

f.write('\n')
f.write(os.path.dirname(installedFromX86File) + ' : ' + 
repr(os.path.isfile(os.path.dirname(installedFromX86File))) + '\n')
f.write(installedFromX86File + ' : ' + 
repr(os.path.isfile(installedFromX86File)) + '\n')
if os.path.isfile(installedFromX86File):
    try:
        f2 = file(installedFromX86File, 'rU')
        f.write(f2.read())
        f2.close()
    except:
        pass

f.write('\n')
f.write('Trying to import _GeoEcoArcGISHelper\n')
try:
    import _GeoEcoArcGISHelper
except:
    traceback.print_exc(file=f)
else:
    f.write('Successfully imported _GeoEcoArcGISHelper from %s\n' % 
sys.modules['_GeoEcoArcGISHelper'].__file__)

f.write('\n')
f.write('Trying to import _winreg\n')
try:
    import _winreg
except:
    traceback.print_exc(file=f)
else:
    def GetRegistryValue(f, hkey, hkeyStr, subkey, valueName=None):
        if valueName is None:
            f.write('Trying to get the value of %s\\%s\n' % (hkeyStr, subkey))
        else:
            f.write('Trying to get the %s value of %s\\%s\n' % (valueName, 
hkeyStr, subkey))
        try:
            h = _winreg.OpenKey(hkey, subkey)
            try:
                try:
                    if valueName is None:
                        value = _winreg.QueryValue(h, None)
                    else:
                        value = _winreg.QueryValueEx(h, valueName)[0]
                except:
                    traceback.print_exc(file=f)
                else:
                    f.write('The value was: %r\n' % value)
            finally:
                _winreg.CloseKey(h)
        except:
            traceback.print_exc(file=f)

    GetRegistryValue(f, _winreg.HKEY_CLASSES_ROOT, 'HKEY_CLASSES_ROOT', 
'Python.CompiledFile\\shell\\open\\command')
    GetRegistryValue(f, _winreg.HKEY_CLASSES_ROOT, 'HKEY_CLASSES_ROOT', 
'Python.File\\shell\\open\\command')
    GetRegistryValue(f, _winreg.HKEY_LOCAL_MACHINE, 'HKEY_LOCAL_MACHINE', 
'SOFTWARE\\Classes\\Python.CompiledFile\\shell\\open\\command')
    GetRegistryValue(f, _winreg.HKEY_LOCAL_MACHINE, 'HKEY_LOCAL_MACHINE', 
'SOFTWARE\\Classes\\Python.File\\shell\\open\\command')

    f.write('\n')
    GetRegistryValue(f, _winreg.HKEY_LOCAL_MACHINE, 'HKEY_LOCAL_MACHINE', 
'SOFTWARE\\R-core\\R32', 'Current Version')
    GetRegistryValue(f, _winreg.HKEY_LOCAL_MACHINE, 'HKEY_LOCAL_MACHINE', 
'SOFTWARE\\R-core\\R32', 'InstallPath')
    GetRegistryValue(f, _winreg.HKEY_LOCAL_MACHINE, 'HKEY_LOCAL_MACHINE', 
'SOFTWARE\\R-core\\R', 'Current Version')
    GetRegistryValue(f, _winreg.HKEY_LOCAL_MACHINE, 'HKEY_LOCAL_MACHINE', 
'SOFTWARE\\R-core\\R', 'InstallPath')

f.write('\n')
f.write('Trying to import GeoEco.OceanographicAnalysis.Fronts\n')
try:
    import GeoEco.OceanographicAnalysis.Fronts
except:
    traceback.print_exc(file=f)
else:
    f.write('Successfully imported GeoEco.OceanographicAnalysis.Fronts from 
%s\n' % sys.modules['GeoEco.OceanographicAnalysis.Fronts'].__file__)
    cleanFrontsFile = 
os.path.join(os.path.dirname(sys.modules['GeoEco.OceanographicAnalysis.Fronts'].__file__),
 'CleanFronts.py')
    if os.path.exists(cleanFrontsFile):
        f.write('%s exists\n' % cleanFrontsFile)
        f.write('Trying to import win32api\n')
        try:
            import win32api
        except:
            traceback.print_exc(file=f)
        else:
            f.write('Calling win32api.FindExecutable on %s\n' % 
cleanFrontsFile)
            try:
                executable = win32api.FindExecutable(cleanFrontsFile, 
cleanFrontsFile)[1]
            except:
                traceback.print_exc(file=f)
            else:
                f.write('win32api.FindExecutable returned %s\n' % executable)
    else:
        f.write('%s DOES NOT EXIST' % cleanFrontsFile)

    f.write('\n')
    f.write('Initializing MGET logging\n')
    f.close()

    loggingIniContents = u"""
[handlers]
keys=LogFile

[handler_LogFile]
class=FileHandler
formatter=LogFile
args=(u'""" + outputTextFile + """',)

[formatters]
keys=LogFile

[formatter_LogFile]
format=%(asctime)s %(levelname)s %(message)s

[loggers]
keys=root,GeoEco,ArcGIS,COM,DatabaseAccess,Datasets,R

[logger_GeoEco]
level=DEBUG
handlers=LogFile
propagate=0
qualname=GeoEco

[logger_ArcGIS]
level=DEBUG
handlers=LogFile
propagate=0
qualname=GeoEco.ArcGIS

[logger_COM]
level=DEBUG
handlers=LogFile
propagate=0
qualname=GeoEco.COM

[logger_DatabaseAccess]
level=DEBUG
handlers=LogFile
propagate=0
qualname=GeoEco.DatabaseAccess

[logger_Datasets]
level=DEBUG
handlers=LogFile
propagate=0
qualname=GeoEco.Datasets

[logger_R]
level=DEBUG
handlers=LogFile
propagate=0
qualname=GeoEco.R

[logger_root]
level=DEBUG
handlers=LogFile
"""
    loggingIniPath = os.path.join(os.path.dirname(__file__), 
os.path.splitext(os.path.basename(__file__))[0] + '_Logging.ini')
    fLoggingIni = open(loggingIniPath, 'w')
    try:
        fLoggingIni.write(loggingIniContents)
    finally:
        fLoggingIni.close()

    try:
        from GeoEco.Logging import Logger
        Logger.Initialize(loggingConfigFile=unicode(loggingIniPath))
    finally:
        os.remove(loggingIniPath)

    Logger.Info('Trying to access R')
    try:
        from GeoEco.R import R, RDependency
        
        d = RDependency(2, 5, 0)
        d.Initialize()

        r = R.GetInterpreter()
        Logger.Info('Trying 1+1 with R.')
        r('print(1+1)')
    except:
        Logger.LogExceptionAsError()

f.close()

#raw_input()
Archives powered by MHonArc.
Top of Page