Exemplo n.º 1
0
def setup_sasmodels():
    """
    Prepare sasmodels for running within sasview.
    """
    # Set SAS_MODELPATH so sasmodels can find our custom models
    import sas
    plugin_dir = os.path.join(sas.get_user_dir(), PLUGIN_MODEL_DIR)
    os.environ['SAS_MODELPATH'] = plugin_dir
Exemplo n.º 2
0
def setup_sasmodels():
    """
    Prepare sasmodels for running within sasview.
    """
    # Set SAS_MODELPATH so sasmodels can find our custom models
    plugin_dir = os.path.join(sas.get_user_dir(), PLUGIN_MODEL_DIR)
    os.environ['SAS_MODELPATH'] = plugin_dir
    #Initialize environment variable with custom setting but only if variable not set
    SAS_OPENCL = sas.get_custom_config().SAS_OPENCL
    if SAS_OPENCL and "SAS_OPENCL" not in os.environ:
        os.environ["SAS_OPENCL"] = SAS_OPENCL
Exemplo n.º 3
0
def setup_sasmodels():
    """
    Prepare sasmodels for running within sasview.
    """
    # Set SAS_MODELPATH so sasmodels can find our custom models
    plugin_dir = os.path.join(sas.get_user_dir(), PLUGIN_MODEL_DIR)
    os.environ['SAS_MODELPATH'] = plugin_dir
    #Initialize environment variable with custom setting but only if variable not set
    SAS_OPENCL = sas.get_custom_config().SAS_OPENCL
    if SAS_OPENCL and "SAS_OPENCL" not in os.environ:
        os.environ["SAS_OPENCL"] = SAS_OPENCL
Exemplo n.º 4
0
def setup_mpl(backend=None):
    # Always use private .matplotlib setup to avoid conflicts with other
    mplconfigdir = os.path.join(sas.get_user_dir(), '.matplotlib')
    if not os.path.exists(mplconfigdir):
        os.mkdir(mplconfigdir)
    os.environ['MPLCONFIGDIR'] = mplconfigdir
    # Set backend to WXAgg; this overrides matplotlibrc, but shouldn't override
    # mpl.use().  Note: Don't import matplotlib here since the script that
    # we are running may not actually need it; also, putting as little on the
    # path as we can
    if backend:
        os.environ['MPLBACKEND'] = backend

    # TODO: ... so much for not importing matplotlib unless we need it...
    from matplotlib import backend_bases
    backend_bases.FigureCanvasBase.filetypes.pop('pgf', None)
Exemplo n.º 5
0
def setup_mpl(backend=None):
    # Always use private .matplotlib setup to avoid conflicts with other
    mplconfigdir = os.path.join(sas.get_user_dir(), '.matplotlib')
    if not os.path.exists(mplconfigdir):
        os.mkdir(mplconfigdir)
    os.environ['MPLCONFIGDIR'] = mplconfigdir
    # Set backend to WXAgg; this overrides matplotlibrc, but shouldn't override
    # mpl.use().  Note: Don't import matplotlib here since the script that
    # we are running may not actually need it; also, putting as little on the
    # path as we can
    if backend:
        os.environ['MPLBACKEND'] = backend

    # TODO: ... so much for not importing matplotlib unless we need it...
    from matplotlib import backend_bases
    backend_bases.FigureCanvasBase.filetypes.pop('pgf', None)
Exemplo n.º 6
0
 def get_user_file():
     """
     returns the user data file, eg .sasview/categories.json.json
     """
     return os.path.join(get_user_dir(), USER_FILE)
Exemplo n.º 7
0
from six import reraise

from sasmodels.sasview_model import load_custom_model, load_standard_models

from sas import get_user_dir

# Explicitly import from the pluginmodel module so that py2exe
# places it in the distribution. The Model1DPlugin class is used
# as the base class of plug-in models.
from .pluginmodel import Model1DPlugin

logger = logging.getLogger(__name__)

PLUGIN_DIR = 'plugin_models'
PLUGIN_LOG = os.path.join(get_user_dir(), PLUGIN_DIR, "plugins.log")
PLUGIN_NAME_BASE = '[plug-in] '


def plugin_log(message):
    """
    Log a message in a file located in the user's home directory
    """
    out = open(PLUGIN_LOG, 'a')
    now = time.time()
    stamp = datetime.datetime.fromtimestamp(now).strftime('%Y-%m-%d %H:%M:%S')
    out.write("%s: %s\n" % (stamp, message))
    out.close()


def _check_plugin(model, name):
Exemplo n.º 8
0
import shutil

from sasmodels.sasview_model import load_custom_model, load_standard_models

from sas import get_user_dir

# Explicitly import from the pluginmodel module so that py2exe
# places it in the distribution. The Model1DPlugin class is used
# as the base class of plug-in models.
from .pluginmodel import Model1DPlugin

logger = logging.getLogger(__name__)


PLUGIN_DIR = 'plugin_models'
PLUGIN_LOG = os.path.join(get_user_dir(), PLUGIN_DIR, "plugins.log")
PLUGIN_NAME_BASE = '[plug-in] '


def plugin_log(message):
    """
    Log a message in a file located in the user's home directory
    """
    out = open(PLUGIN_LOG, 'a')
    now = time.time()
    stamp = datetime.datetime.fromtimestamp(now).strftime('%Y-%m-%d %H:%M:%S')
    out.write("%s: %s\n" % (stamp, message))
    out.close()


def _check_plugin(model, name):