Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • DM/dm-docs
  • hammonds/dm-docs
  • hparraga/dm-docs
3 results
Show changes
Commits on Source (6)
Showing
with 274 additions and 0 deletions
File added
This diff is collapsed.
File added
This diff is collapsed.
File added
../src/python
\ No newline at end of file
#!/bin/sh
# DM setup script for Bourne-type shells
# This file is typically sourced in user's .bashrc file
myDir=`dirname $BASH_SOURCE`
currentDir=`pwd` && cd $myDir
if [ ! -z "$DM_ROOT_DIR" -a "$DM_ROOT_DIR" != `pwd` ]; then
echo "WARNING: Resetting DM_ROOT_DIR environment variable (old value: $DM_ROOT_DIR)"
fi
export DM_ROOT_DIR=`pwd`
if [ -z $DM_DATA_DIR ]; then
export DM_DATA_DIR=$DM_ROOT_DIR/../data
if [ -d $DM_DATA_DIR ]; then
cd $DM_DATA_DIR
export DM_DATA_DIR=`pwd`
fi
fi
if [ ! -d $DM_DATA_DIR ]; then
#echo "WARNING: $DM_DATA_DIR directory does not exist. Developers should point DM_DATA_DIR to the desired area."
unset DM_DATA_DIR
fi
if [ -z $DM_VAR_DIR ]; then
export DM_VAR_DIR=$DM_ROOT_DIR/../var
if [ -d $DM_VAR_DIR ]; then
cd $DM_VAR_DIR
export DM_VAR_DIR=`pwd`
fi
fi
# Check support setup
if [ -z $DM_SUPPORT_DIR ]; then
export DM_SUPPORT_DIR=$DM_ROOT_DIR/../support
if [ -d $DM_SUPPORT_DIR ]; then
cd $DM_SUPPORT_DIR
export DM_SUPPORT_DIR=`pwd`
fi
fi
if [ ! -d $DM_SUPPORT_DIR ]; then
echo "ERROR: $DM_SUPPORT_DIR directory does not exist. Developers should point DM_SUPPORT_DIR to the desired area."
return 1
fi
export DM_HOST_ARCH=`uname | tr [A-Z] [a-z]`-`uname -m`
# Add to path only if directory exists.
prependPathIfDirExists() {
_dir=$1
if [ -d ${_dir} ]; then
PATH=${_dir}:$PATH
fi
}
# Setup epics variables
PATH=$DM_ROOT_DIR/bin:$PATH
PATH=.:$PATH
export PATH
if [ -z $LD_LIBRARY_PATH ]; then
LD_LIBRARY_PATH=.
else
LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
fi
export LD_LIBRARY_PATH
# Setup python path. First check for wx, then try to find it locally, and
# then re-check for it.
# Check if we have local python
if [ -z $DM_PYTHON_DIR ]; then
pythonDir=$DM_SUPPORT_DIR/python/$DM_HOST_ARCH
else
pythonDir=$DM_PYTHON_DIR
fi
if [ -d $pythonDir ]; then
cd $pythonDir
pythonDir=`pwd`
export PATH=`pwd`/bin:$PATH
export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH
export DM_PYTHON_DIR=$pythonDir
fi
if [ -z $PYTHONPATH ]; then
PYTHONPATH=$DM_ROOT_DIR/lib/python
else
PYTHONPATH=$DM_ROOT_DIR/lib/python:$PYTHONPATH
fi
export PYTHONPATH
# Get back to where we were before invoking the setup script
cd $currentDir
# Print out user environment
echo
echo "Your DM environment is defined as follows:"
echo
env | grep DM_ | grep -v GDM_
echo
echo
#!/usr/bin/env python
#######################################################################
DM_SESSION_ROLE_HTTP_HEADER = 'Dm-Session-Role'
DM_STATUS_CODE_HTTP_HEADER = 'Dm-Status-Code'
DM_STATUS_MESSAGE_HTTP_HEADER = 'Dm-Status-Message'
DM_EXCEPTION_TYPE_HTTP_HEADER = 'Dm-Exception-Type'
#!/usr/bin/env python
#######################################################################
DM_ADMIN_ROLE = 'admin'
DM_USER_ROLE = 'user'
#!/usr/bin/env python
#######################################################################
DM_SERVICE_PROTOCOL_HTTP = 'http'
DM_SERVICE_PROTOCOL_HTTPS = 'https'
#!/usr/bin/env python
#######################################################################
DM_OK = 0
DM_ERROR = 1
DM_CONFIGURATION_ERROR = 2
DM_INTERNAL_ERROR = 3
DM_INVALID_ARGUMENT_ERROR = 4
DM_INVALID_REQUEST_ERROR = 5
DM_COMMAND_FAILED_ERROR = 6
#!/usr/bin/env python
#
# Command failed exception class.
#
#######################################################################
from dm.common.constants import dmStatus
from dm.common.exceptions.dmException import DmException
#######################################################################
class CommandFailed(DmException):
def __init__ (self, error='', **kwargs):
DmException.__init__(self, error, dmStatus.DM_COMMAND_FAILED_ERROR, **kwargs)
#!/usr/bin/env python
#
# Configuration error class.
#
#######################################################################
from dm.common.constants import dmStatus
from dm.common.exceptions.dmException import DmException
#######################################################################
class ConfigurationError(DmException):
def __init__ (self, error='', **kwargs):
DmException.__init__(self, error, dmStatus.DM_CONFIGURATION_ERROR, **kwargs)
#!/usr/bin/env python
#
# Base DM exception class.
#
#######################################################################
import exceptions
import json
from dm.common.constants import dmStatus
#######################################################################
class DmException(exceptions.Exception):
"""
Base DM exception class.
Usage:
DmException(errorMessage, errorCode)
DmException(args=errorMessage)
DmException(exception=exceptionObject)
"""
def __init__(self, error='', code=dmStatus.DM_ERROR, **kwargs):
args = error
if args == '':
args = kwargs.get('args', '')
ex = kwargs.get('exception', None)
if ex != None:
if isinstance(ex, exceptions.Exception):
exArgs = '%s' % (ex)
if args == '':
args = exArgs
else:
args = "%s (%s)" % (args, exArgs)
exceptions.Exception.__init__(self, args)
self._code = code
def getArgs(self):
return self.args
def getErrorCode(self):
return self._code
def getErrorMessage(self):
return '%s' % (self.args)
def getClassName(self):
return '%s' % (self.__class__.__name__)
def getExceptionType(self):
return '%s' % (self.__class__.__name__).split('.')[-1]
def getJsonRep(self):
return json.dumps({
'errorMessage' : self.getErrorMessage(),
'errorCode' : self.getErrorCode(),
'exceptionType' : self.getExceptionType(),
})
#!/usr/bin/env python
#
# DM exception map
#
#######################################################################
from dm.common.constants import dmStatus
exceptionMap = {
dmStatus.DM_ERROR : 'dmException.DmException',
dmStatus.DM_CONFIGURATION_ERROR : 'configurationError.ConfigurationError',
dmStatus.DM_INTERNAL_ERROR : 'internalError.InternalError',
dmStatus.DM_INVALID_ARGUMENT_ERROR : 'invalidArgument.InvalidArgument',
dmStatus.DM_INVALID_REQUEST_ERROR : 'invalidRequest.InvalidRequest',
dmStatus.DM_COMMAND_FAILED_ERROR : 'commandFailed.CommandFailed',
}
#######################################################################
# Testing
if __name__ == '__main__':
for item in exceptionMap.items():
print item
#!/usr/bin/env python
#
# Internal error class.
#
#######################################################################
from dm.common.constants import dmStatus
from dm.common.exceptions.dmException import DmException
#######################################################################
class InternalError(DmException):
def __init__ (self, error='', **kwargs):
DmException.__init__(self, error, dmStatus.DM_INTERNAL_ERROR, **kwargs)