Exemplo n.º 1
0
def showException(title):
    error = sys.exc_info()[1]
    if isinstance(error, Throwable):
        Logger.getLogger("jython").log(Level.WARNING, title, error)
        ExceptionDetailsErrorDialog.openError(None, title, wisdom(), error)
    else:
        error = str(error)
        Logger.getLogger("jython").log(Level.WARNING, "%s: %s\n%s" % (title, error, traceback.format_exc()))
        MessageDialog.openWarning(None, title, "%s\n\n\n%s" % (wisdom(), error))
Exemplo n.º 2
0
  def __init__(self):
    self._log            = Logger.getLogger(VLAB.LOGGER_NAME)
    self._reqElemFac     = VLabRequestElementFactory() 
    self._defaultFactory = DefaultRequestElementFactory.getInstance()
    self._requestFile    = File('')
    self.pmap            = {} 

    me=self.__class__.__name__ +'::'+VLAB.me()
    self._log.info(me + ": constructor completed...")
Exemplo n.º 3
0
 def created(who,what):
   if (not (File(what)).exists()):
     (Logger.getLogger(VLAB.LOGGER_NAME)).info(JString.format ("Error: \"%s\" failed to generate \"%s\"", [who, what]))
Exemplo n.º 4
0
 def dependsOn(who,what):
   if (not (File(what)).exists()):
     (Logger.getLogger(VLAB.LOGGER_NAME)).info(JString.format ("Error: \"%s\" expected \"%s\" to exist", [who, what]))
#  You should have received a copy of the GNU Lesser General
#  Public License along with HCSS.
#  If not, see <http://www.gnu.org/licenses/>.
# 
# Some tools used in several spectrometer SPG scripts
#
# Author: Jeroen de Jong
#

from java.util.logging import Logger, Level
from herschel.ia.pal import ListContext
from herschel.pacs.signal import ProductUtil
from herschel.pacs.spg.common.util import PacsProcessingException
from herschel.pacs.signal import RangeDescription

LOGGER = Logger.getLogger("herschel.pacs.spg.pipeline.spg_spec_tools")
       
# Computes the average ra/dec from the rebinned cubes of a level-2 product
# and puts this into the observation context meta data
def extractRaDecToObs(obs):
    context = obs.level2


    subcontext = ListContext()
    # for camera in ['red', 'blue']:
    for camera in ['red']:
        rcube = context.getCamera(camera).rcube
        if rcube.available:
            subcontext.refs.add(rcube.productRef)

    # tamanio = subcontext.getAllRefs().size()
Exemplo n.º 6
0
"""
api.py

Provides utility defs and classes to assist in scripting for the OpenRS emulator.

Authors: Blake Beaupain
"""

from java.util.logging import Logger

# Initialize the script logger.
log = Logger.getLogger("OpenRS:Script")

# TODO: Initialize any defs/classes for the scripting system.
    def log_results(self, logger):
        """

        :param logger:
        :return:
        """
        _method_name = 'log_results'

        if logger is not None:
            # Get counts for all the ComparerResult objects
            # in this ComparerResults object
            results_summary = self.__get_summary()

            jlogger = JLogger.getLogger(logger.get_name(),
                                        logger.resource_bundle_name)

            jlogger.setLevel(JLevel.INFO)

            # Determine what the severity level is going to be for the
            # summary log message. Needs to be set in accordance with
            # what the severest test message was.
            if results_summary[ComparerResults._INFOS_COUNT] > 0:
                jlogger.setLevel(JLevel.INFO)
            if results_summary[ComparerResults._WARNINGS_COUNT] > 0:
                jlogger.setLevel(JLevel.WARNING)
            if results_summary[ComparerResults._ERRORS_COUNT] > 0:
                jlogger.setLevel(JLevel.SEVERE)

            total_messages_count = \
                int(results_summary[ComparerResults._ERRORS_COUNT]) + \
                int(results_summary[ComparerResults._WARNINGS_COUNT]) + \
                int(results_summary[ComparerResults._INFOS_COUNT])

            logger.log(jlogger.getLevel(),
                       'WLSDPLY-09901',
                       results_summary[ComparerResults._ERRORS_COUNT],
                       results_summary[ComparerResults._WARNINGS_COUNT],
                       results_summary[ComparerResults._INFOS_COUNT],
                       class_name=self._class_name,
                       method_name=_method_name)

            if total_messages_count > 0:
                logger.log(jlogger.getLevel(),
                           'WLSDPLY-09811',
                           total_messages_count,
                           class_name=self._class_name,
                           method_name=_method_name)

            for comparison_result in self._comparison_result_dict.values():
                if comparison_result.get_infos_count() > 0:
                    jlogger.setLevel(JLevel.INFO)
                    self.__log_results_category_details(
                        comparison_result.get_infos_messages(), _method_name,
                        jlogger)

            for comparison_result in self._comparison_result_dict.values():
                if comparison_result.get_warnings_count() > 0:
                    jlogger.setLevel(JLevel.WARNING)
                    self.__log_results_category_details(
                        comparison_result.get_warnings_messages(),
                        _method_name, jlogger)

            for comparison_result in self._comparison_result_dict.values():
                if comparison_result.get_errors_count() > 0:
                    jlogger.setLevel(JLevel.SEVERE)
                    self.__log_results_category_details(
                        comparison_result.get_errors_messages(), _method_name,
                        jlogger)

            jlogger.setLevel(JLevel.INFO)

        return
Exemplo n.º 8
0
    '/htmlunit-2.13/lib/commons-codec-1.8.jar',
    '/htmlunit-2.13/lib/commons-collections-3.2.1.jar'
]

def loadjars(): #appends jars to jython path
    for jar in jars:
        #print(jarpath+jar)
        container = jarpath+jar
        sys.path.append(container)

loadjars()

import java.util.logging.Logger as Logger
import java.util.logging.Level as Level

Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);


import com.gargoylesoftware.htmlunit.WebClient as WebClient
webclient = WebClient()   

def get_page(page, url):
    if page is None:
        return webclient.getPage(url)
    else:
        return page.getPage(url)
    
def get_first_by_xpath(page, xpath_fmt, *kargs):
    xpath = xpath_fmt % kargs
    inputs = page.getByXPath(xpath)
    #if not inputs:
Exemplo n.º 9
0
This module contains utility functions for use within Jython unit tests written
for Aqua JSystem. They allow logging and access to various jsystem components 
(sut, system objects, etc.).
"""

import unittest

from java.util.logging import Logger
from jsystem.framework.system import SystemManagerImpl
from jsystem.framework.report import ListenerstManager
from jsystem.framework.sut import SutFactory
from jsystem.framework.monitor import MonitorsManager
from jsystem.framework import RunProperties
from jsystem.framework.fixture import RootFixture

log = Logger.getLogger("Jython")
report = ListenerstManager.getInstance()
system = SystemManagerImpl.getInstance()
sut = SutFactory.getInstance().getSutInstance()
monitors = MonitorsManager.getInstance()
runProperties = RunProperties.getInstance()

class Parameter(object):
    pass
        
class SystemTestCase(unittest.TestCase):
    __fixture__ = RootFixture
    __tearDownFixture__ = RootFixture
    __parameters__ = dict()
    def __init__(self, name):
        unittest.TestCase.__init__(self, name)
Exemplo n.º 10
0
                  action="store_true", dest="explodeBrep",
                  help="writes face.<i>.brep file before meshing each patch")
parser.set_defaults(crit="MinAngleFace", scaleFactor=1.0, ifacemin=0, ifacemax=0)

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 4:
	parser.print_usage()
	sys.exit(1)

brepfile = args[0]
outputDir = args[1]
leng = float(args[2])
defl = float(args[3])

logger=Logger.getLogger("mesh")
(brepdir, brepfile) = os.path.split(brepfile)
if brepdir is None:
	brepdir = "."

phases = [False, False, False, False]
for s in options.phases.split(","):
	p = int(s)
	if p < 1 or p > 3:
		parser.print_usage()
		sys.exit(1)
	phases[p] = True

#System.setProperty("org.jcae.mesh.amibe.ds.Mesh.epsilon", str(options.epsilon))
#System.setProperty("org.jcae.mesh.amibe.ds.Mesh.cumulativeEpsilon", str(options.cumulativeEpsilon))
Exemplo n.º 11
0
 def __init__(self):
     from java.util.logging import Logger
     self.logger = Logger.getLogger('jython.hotel')
Exemplo n.º 12
0
from java.lang import IllegalStateException
from java.util.logging import Logger, Level

import entities.EntityUtils as entityUtils
from pb import PbTypes
from pb import PbWlstWrappers
from weblogic.management.scripting.core.utils.wlst_core import WLSTException
from wlst.WlstWrapper import pushd, popd, get, create

LOGGER = Logger.getLogger("entities.PbWlstEntity")


def applyChange(pbWlstEntity, mbeanAttribute):
    requiredValue = pbWlstEntity.pbEntity.get(mbeanAttribute.name)
    try:
        pushd(mbeanAttribute.mbeanAttributePath[0])
    except WLSTException:
        # The value is not present as the parent is not present.
        LOGGER.warning("No path exists to set attribute. Path: '" +
                       mbeanAttribute.mbeanAttributePath[0] +
                       "',  Attribute: '" +
                       mbeanAttribute.mbeanAttributePath[1] + "'. Ignoring.")
        return

    try:
        pbWlstEntity.setValue(mbeanAttribute, requiredValue)
        popd()
    except Exception, e:
        LOGGER.severe("Unable to set attribute identified by '" +
                      mbeanAttribute.name + "', to value '" +
                      str(requiredValue) + "'")
# Select the ipipe scripts based on the observation mode
from herschel.pacs.spg.pipeline   import SelectPacsPipeline
from herschel.pacs.signal         import SlicedFrames
from herschel.pacs.signal.context import PacsContext
from herschel.pacs.spg.common     import PacsPropagateMetaKeywordsTask
from herschel.pacs.spg.pipeline.ProductSinkHandling import *
from herschel.pacs.spg.pipeline.spg_spec_tools import *
from herschel.ia.pal              import *
from herschel.pacs.cal import *
from herschel.pacs.cal import GetPacsCalDataTask
from herschel.ia.obs import ObservationContext
from herschel.ia.numeric.toolbox.basic import *
from herschel.pacs.spg.common.util import PacsProcessingExceptionHandler
from java.lang import Throwable

_logger = Logger.getLogger("pacsspectro_pipeline")

# Cameras to reduce
try:
    cameraList
except NameError:
    cameraList = ['red','blue']

# Check that we have data for all camera's
for camera in list(cameraList):
    if obs.level0.getCamera(camera).available == False:
        _logger.warning("There is no level 0 data for camera: "+camera)
        cameraList.remove(camera)

maxErrors = len(cameraList)
if maxErrors == 0:
Exemplo n.º 14
0
 def log(self, m):
     l = Logger.getLogger(self.qn)
     l.info(m)
Exemplo n.º 15
0
from java.io import FileInputStream
from java.util import Properties
from java.util.logging import Logger

from com.muse.properties.secure import EncryptionUtils

global ENCRPYTED_VALUE_PREFIX
ENCRPYTED_VALUE_PREFIX = "::ENCRYPTED::"

global LOGGER
LOGGER = Logger.getLogger("PbCommon")


def getBoolFromString(str):
    return (str == "true" or str == "True")


def getDecryptedValue(props, key):
    password = props.get(key)
    if password:
        passkey = props.get('security.passkey')

        if password.startswith(ENCRPYTED_VALUE_PREFIX):
            password = EncryptionUtils.decryptString(
                passkey, password[len(ENCRPYTED_VALUE_PREFIX):])

    return password


def decryptfunc(obj):
    pass
    def log_results(self, logger):
        """

        :return:
        """
        _method_name = 'log_results'

        if logger is not None:
            # Get counts for all the ValidationResult objects
            # in this ValidationResults object
            results_summary = self.__get_summary()

            jlogger = JLogger.getLogger(logger.get_name(),
                                        logger.resource_bundle_name)

            jlogger.setLevel(JLevel.INFO)

            # Determine what the severity level is going to be for the
            # summary log message. Needs to be set in accordance with
            # what the severest validation message was.
            if results_summary['infos_count'] > 0:
                jlogger.setLevel(JLevel.INFO)
            if results_summary['warnings_count'] > 0:
                jlogger.setLevel(JLevel.WARNING)
            if results_summary['errors_count'] > 0:
                jlogger.setLevel(JLevel.SEVERE)

            total_messages_count = \
                int(results_summary['errors_count']) + int(results_summary['warnings_count']) + \
                int(results_summary['infos_count'])

            logger.log(jlogger.getLevel(),
                       'WLSDPLY-05204',
                       results_summary['errors_count'],
                       results_summary['warnings_count'],
                       results_summary['infos_count'],
                       class_name=self._class_name,
                       method_name=_method_name)

            if total_messages_count > 0:
                logger.log(jlogger.getLevel(),
                           'WLSDPLY-05207',
                           total_messages_count,
                           class_name=self._class_name,
                           method_name=_method_name)

            for validation_result in self._validation_result_dict.values():
                if validation_result.get_infos_count() > 0:
                    jlogger.setLevel(JLevel.INFO)
                    self.__log_results_category_details(
                        validation_result.get_infos_messages(), _method_name,
                        jlogger)

            for validation_result in self._validation_result_dict.values():
                if validation_result.get_warnings_count() > 0:
                    jlogger.setLevel(JLevel.WARNING)
                    self.__log_results_category_details(
                        validation_result.get_warnings_messages(),
                        _method_name, jlogger)

            for validation_result in self._validation_result_dict.values():
                if validation_result.get_errors_count() > 0:
                    jlogger.setLevel(JLevel.SEVERE)
                    self.__log_results_category_details(
                        validation_result.get_errors_messages(), _method_name,
                        jlogger)

            jlogger.setLevel(JLevel.INFO)

        return
Exemplo n.º 17
0
 def __init__(self):
   self._log = Logger.getLogger(VLAB.LOGGER_NAME)
   me=self.__class__.__name__ +'::'+VLAB.me()
   self._log.info(me + ": constructor completed...")
   self._log.info(me + ": returning...")
Exemplo n.º 18
0
from java.util.logging import Logger
logger = Logger.getLogger("WarBase")


st = {}
st['n'] =0

def actionWarBase():
	broadcastMessageToAll("", "")
	actionWarBase.n+=getNbElementsInBag()
	#setDebugString(`st['n']`+`actionWarBase.n`)
	for m in getMessages():
		if m.getMessage() == "whereAreYouBase":
			reply(m,"Here","")
	nbEnv = getNbElementsInBag()
	if nbEnv > 0:
		return createRocketLauncher()

	st['n'] += 1
	requestRole('gr', 'role')
	setDebugString(str(getNumberOfAgentsInRole('gr','role')))
	return idle()

actionWarBase.n = 0
Exemplo n.º 19
0
from edu.cmu.sphinx.linguist.flat import FlatLinguist
from edu.cmu.sphinx.recognizer import Recognizer
from edu.cmu.sphinx.util import LogMath
from java.util.logging import Logger
from java.util.logging import Level
from java.net import URL
from java.util import ArrayList

# if (args.length < 1) {
#  throw new Error("USAGE: GroovyTranscriber <sphinx4 root> [<WAV file>]")
# }

root = "../../../../../../../.."

# init common 
Logger.getLogger("").setLevel(Level.WARNING)
logMath = LogMath(1.0001, true)
absoluteBeamWidth = -1
relativeBeamWidth = 1E-80
wordInsertionProbability = 1E-36
languageWeight = 8.0

# init audio data
audioSource = AudioFileDataSource(3200, None)
audioURL =  URL("file:" + root + "/src/apps/edu/cmu/sphinx/demo/transcriber/10001-90210-01803.wav")
# (args.length > 1) ?
#  File(args[0]).toURI().toURL() :
 
audioSource.setAudioFile(audioURL, None)

# init front end
Exemplo n.º 20
0
	def info(self, message):
		Logger.getLogger(self.qn).info(message)
Exemplo n.º 21
0
import os
import time
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
from java.io import ByteArrayOutputStream
from java.util.logging import Logger, StreamHandler, SimpleFormatter

errors = ByteArrayOutputStream(100)
logger = Logger.getLogger('com.android.chimpchat.adb.AdbChimpDevice')
logger.addHandler(StreamHandler(errors, SimpleFormatter()))
current_activity = None


def click(device, x, y):
    if device is not None:
        device.touch(x, y, MonkeyDevice.DOWN_AND_UP)


def drag(device, startx, starty, endx, endy):
    if device is not None:
        device.drag((startx, starty), (endx, endy), 0.001, 10)


def get_usb_device():
    devices = os.popen('adb devices').read().strip().split('\n')[1:]
    for name in devices:
        device_name = name.split('\t')[0]
        if "2967" in device_name:
            return True


def get_device():
Exemplo n.º 22
0
if __name__ == '__main__':
    from wlstModule import *  # @UnusedWildImport

from java.net import InetAddress
from java.util.logging import *
from java.util.logging import Logger
import sys

logger = Logger.getLogger("scratch")

print "" + InetAddress.getLocalHost().getHostName()