def __requestData(self, availableTimes, parameters, maxSize):
        from com.raytheon.viz.pointdata import PointDataRequest
        from java.lang import String
        import jep
        from com.raytheon.uf.common.time import DataTime
        length = len(availableTimes)
        dts = jep.jarray(length,DataTime)

        if maxSize==0 : #DR15153: retrive latest Metar for Metarmonitor & PersistMonitor
            dts = jep.jarray(1,DataTime)
            dts[0] = DataTime(availableTimes[length-1])
        else : # for maxSize >= 1
            dts = self._createJarray(availableTimes, maxSize)
            if len(dts)==0 : 
                dts = jep.jarray(1,DataTime)
                dts[0] = DataTime(availableTimes[length-1])

        constraints = self._buildConstraints(None) #times are explicitly set so we don't need to constrain those
        params = jep.jarray(len(parameters), String)
        for i in range(len(parameters)):
            params[i] = String(parameters[i])
        if self.site:
            stations = jep.jarray(1, String)
            stations[0] = String(self.site)
        else:
            stations = None
        return PointDataRequest.requestPointData(dts,
            self.pluginName, params, stations,
            constraints)
Beispiel #2
0
 def test_object_setitem_jarray(self):
     from java.lang import Object
     ar = jarray(1, Object)
     t = jarray(1, JINT_ID)
     t[0] = 7
     ar[0] = t
     self.assertEqual(ar[0][0], t[0])
Beispiel #3
0
 def test_object_setitem_jarray(self):
     from java.lang import Object
     ar = jarray(1, Object)
     t = jarray(1, JINT_ID)
     t[0] = 7
     ar[0] = t
     self.assertEqual(ar[0][0], t[0])
Beispiel #4
0
def makeArea(gridLoc, pointList, refname=None):
    " Make a Reference Area with a unique ReferenceID"
    from com.vividsolutions.jts.geom import GeometryFactory, LinearRing, Coordinate, Polygon
    from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceData
    CoordinateType = ReferenceData.CoordinateType
    geomFactory = GeometryFactory()
    import jep
    size = len(pointList)
    if pointList[0] != pointList[size - 1]:  # closing the loop
        pointList.append(pointList[0])
    pointArray = jep.jarray(len(pointList), Coordinate)
    for i in range(len(pointList)):
        pointArray[i] = pointList[i]
    lr = geomFactory.createLinearRing(pointArray)
    poly = geomFactory.createPolygon(lr, jep.jarray(0, LinearRing))
    polyArray = jep.jarray(1, Polygon)
    polyArray[0] = poly
    region = geomFactory.createMultiPolygon(polyArray)
    if refname is None:
        refname = "Ref" + getTime()
    refId = ReferenceID(refname)
    refData = ReferenceData(gridLoc, refId, region, CoordinateType.LATLON)
    # randerso: I don't think this is necessary
    # refData.convertToAWIPS()
    return refData
Beispiel #5
0
def __getMaskIndiciesForJava(mask):
    flatMask = mask.flat  #flatten the array
    flatIndicies = numpy.nonzero(flatMask)  # get the indicies of the set cells
    ysize = mask.shape[1]
    indexes = []
    # convert the flat incicies to the x, y indicies
    for i in flatIndicies:
        indexes.append((i / ysize, i % ysize))

    #  Make two new jarrays to hold the final coordinate tuples
    size = len(indexes[0][0])
    xcoords = jep.jarray(size, jep.JINT_ID)
    ycoords = jep.jarray(size, jep.JINT_ID)

    #===================================================================
    #  Convert the coordinates from a tuple of numpy arrays to a list of
    #  coordinate tuples

    for index in xrange(size):
        try:
            x = indexes[0][0][index]
            y = indexes[0][1][index]
            xcoords[index] = int(x)
            ycoords[index] = int(y)
        except Exception, e:
            print e
    def __requestData(self, availableTimes, parameters, maxSize):
        from com.raytheon.viz.pointdata import PointDataRequest
        from java.lang import String
        import jep
        from com.raytheon.uf.common.time import DataTime
        length = len(availableTimes)
        dts = jep.jarray(length,DataTime)

        if maxSize==0 : #DR15153: retrive latest Metar for Metarmonitor & PersistMonitor
            dts = jep.jarray(1,DataTime)
            dts[0] = DataTime(availableTimes[length-1])
        else : # for maxSize >= 1
            dts = self._createJarray(availableTimes, maxSize)
            if len(dts)==0 : 
                dts = jep.jarray(1,DataTime)
                dts[0] = DataTime(availableTimes[length-1])

        constraints = self._buildConstraints(None) #times are explicitly set so we don't need to constrain those
        params = jep.jarray(len(parameters), String)
        for i in range(len(parameters)):
            params[i] = String(parameters[i])
        if self.site:
            stations = jep.jarray(1, String)
            stations[0] = String(self.site)
        else:
            stations = None
        return PointDataRequest.requestPointData(dts,
            self.pluginName, params, stations,
            constraints)
Beispiel #7
0
def __getMaskIndiciesForJava(mask):
    flatMask = mask.flat              #flatten the array
    flatIndicies = numpy.nonzero(flatMask)  # get the indicies of the set cells
    ysize = mask.shape[1]
    indexes = []
    # convert the flat incicies to the x, y indicies
    for i in flatIndicies:
        indexes.append((i / ysize, i % ysize))

    #  Make two new jarrays to hold the final coordinate tuples
    size = len(indexes[0][0])
    xcoords = jep.jarray(size, jep.JINT_ID)
    ycoords = jep.jarray(size, jep.JINT_ID)    

    #===================================================================
    #  Convert the coordinates from a tuple of numpy arrays to a list of
    #  coordinate tuples

    for index in xrange(size):
        try:
            x = indexes[0][0][index]
            y = indexes[0][1][index]
            xcoords[index] = int(x)
            ycoords[index] = int(y)
        except Exception, e:
            print e                
Beispiel #8
0
def numpy2java(a):
    if (len(a.shape) == 1):
        jA = jarray(a.shape[0], JFLOAT_ID, 0)
        for i in range(a.shape[0]):
            jA[i] = float(a[i])
        return jA
    elif(len(a.shape) == 2):
        jA = jarray(a.shape[0]*a.shape[1], JFLOAT_ID, 0)
        for i in range(a.shape[0]):
            for j in range(a.shape[1]):
                jA[i*a.shape[0]+j] = float(a[i][j])
        return jA
 def rmFile(self, fname):
     '''
     @summary: Public interface for deleting a localization file.
               Operation not enabled for Base and Configured level.
     @param fname: File path to file, below level/name path components.
     @return: Throws LocalFileInstallerException on failure.
     '''
     lev = self.__context.getLocalizationLevel()
     if lev.toString().upper() == "BASE":
         raise LocalFileInstallerException(
             "I can GET files from BASE, but I won't DELETE them.  It just wouldn't be right."
         )
     self.__duc.setFilename(fname)
     resp = None
     try:
         urm = PrivilegedUtilityRequestMessage()
         urmArray = jep.jarray(1, AbstractPrivilegedUtilityCommand)
         urmArray[0] = self.__duc
         urm.setCommands(urmArray)
         resp = self.route(urm, self.__service)
         if resp == None:
             return False
     except:
         traceback.print_exc()
         return False
     return True
Beispiel #10
0
 def test_slice(self):
     ar = jarray(20, JINT_ID, 0)
     py_ar = list(range(20))
     for i in py_ar:
         ar[i] = i
     self.assertEqual(py_ar[0:2], list(ar[0:2]))
     self.assertEqual(py_ar[1:-1], list(ar[1:-1]))
 def getList(self, dirname):
     '''
     @summary: Public interface for listing localization files.
     @param dirname: File path to localizaton data directory, below
                     level/name path components.
     @return: List of files found, throws LocalFileInstallerException
              on failure.
     '''
     self.__luc.setSubDirectory(dirname)
     nnn = len(dirname) + 1
     resp = None
     try:
         urm = UtilityRequestMessage()
         urmArray = jep.jarray(1, AbstractUtilityCommand)
         urmArray[0] = self.__luc
         urm.setCommands(urmArray)
         resp = self.route(urm, self.__service)
         respList = resp.getResponses()
         entries = respList[0].getEntries()
         retList = []
         for one in entries:
             onefil = one.getFileName()
             if onefil == dirname:
                 retList.append(onefil)
             else:
                 retList.append(onefil[nnn:])
     except ThriftClient.ThriftRequestException as e:
         raise LocalFileInstallerException(
             "getList: Error sending request to server: " + str(e))
     return retList
Beispiel #12
0
    def getRawData(self, unit=None):
        # import only the modules that are needed
        from com.raytheon.uf.common.numeric.buffer import FloatBufferWrapper

        nx = self.jobj.getGridGeometry().getGridRange().getSpan(0)
        ny = self.jobj.getGridGeometry().getGridRange().getSpan(1)
        dest = FloatBufferWrapper(nx, ny)
        pnfa = None
        if unit:
            from javax.measure.unit import UnitFormat
            from com.raytheon.uf.common.geospatial.data import UnitConvertingDataFilter
            from com.raytheon.uf.common.numeric.dest import FilteredDataDestination
            from jep import jarray

            unitObj = UnitFormat.getUCUMInstance().parseObject(unit)
            converter = self.jobj.getUnit().getConverterTo(unitObj)
            filter = UnitConvertingDataFilter(converter)
            filters = jarray(1, UnitConvertingDataFilter)
            filters[0] = filter
            unitDest = FilteredDataDestination.addFilters(dest, filters)
            self.jobj.populateData(unitDest)
        else:
            self.jobj.populateData(dest)
        data = np.array(dest.getArray(), dtype=np.float32)
        data = data.reshape((ny, nx))
        return data
Beispiel #13
0
 def test_slice(self):
     ar = jarray(20, JINT_ID, 0)
     py_ar = list(range(20))
     for i in py_ar:
         ar[i] = i
     self.assertEqual(py_ar[0:2], list(ar[0:2]))
     self.assertEqual(py_ar[1:-1], list(ar[1:-1]))
Beispiel #14
0
 def test_set_string_array(self):
     from java.lang import String
     from jep.test import Test
     t = Test()
     ar = jarray(1, String)
     ar[0] = String("String")
     result = t.setStringArray(ar)
     self.assertEqual(result[0], ar[0])
Beispiel #15
0
 def test_array_assignment(self):
     from jep import jarray
     from java.lang import Object
     arr = jarray(1, Object)
     refcount1 = sys.gettotalrefcount()
     arr[0] = self.obj
     refcount2 = sys.gettotalrefcount()
     self.assertEquals(refcount1, refcount2 - 1)
Beispiel #16
0
 def test_array_assignment(self):
     from jep import jarray
     from java.lang import Object
     arr = jarray(1, Object)
     refcount1 = sys.gettotalrefcount()
     arr[0] = self.obj
     refcount2 = sys.gettotalrefcount()
     self.assertEquals(refcount1, refcount2 - 1)
Beispiel #17
0
 def test_array_creation(self):
     from jep import jarray
     from java.lang import Object
     refcount1 = sys.gettotalrefcount()
     result = jarray(1, Object)
     del result
     refcount2 = sys.gettotalrefcount()
     self.assertEquals(refcount1, refcount2 - 1)
Beispiel #18
0
 def test_set_string_array(self):
     from java.lang import String
     from jep.test import Test
     t = Test()
     ar = jarray(1, String)
     ar[0] = String("String")
     result = t.setStringArray(ar)
     self.assertEqual(result[0], ar[0])
Beispiel #19
0
 def test_array_creation(self):
     from jep import jarray
     from java.lang import Object
     refcount1 = sys.gettotalrefcount()
     result = jarray(1, Object)
     del result
     refcount2 = sys.gettotalrefcount()
     self.assertEquals(refcount1, refcount2 - 1)
Beispiel #20
0
 def test_array_access(self):
     from jep import jarray
     from java.lang import Object
     arr = jarray(1, Object)
     arr[0] = self.obj
     refcount1 = sys.gettotalrefcount()
     result = arr[0]
     del result
     refcount2 = sys.gettotalrefcount()
     self.assertEquals(refcount1, refcount2 - 1)
Beispiel #21
0
 def test_array_access(self):
     from jep import jarray
     from java.lang import Object
     arr = jarray(1, Object)
     arr[0] = self.obj
     refcount1 = sys.gettotalrefcount()
     result = arr[0]
     del result
     refcount2 = sys.gettotalrefcount()
     self.assertEquals(refcount1, refcount2 - 1)
Beispiel #22
0
 def test_set_string_array(self):
     from java.lang import String
     #from jep.test import Test             # <AK> changed
     import jep  #     -||-
     Test = jep.findClass('jep.test.Test')  #     -||-
     t = Test()
     ar = jarray(1, String)
     ar[0] = String("String")
     result = t.setStringArray(ar)
     self.assertEqual(result[0], ar[0])
Beispiel #23
0
    def test_read_file(self):
        from java.io import FileInputStream
        from java.lang import String

        filename = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                'data/read_file.txt')
        fin = FileInputStream(filename)
        ar = jarray(20, JBYTE_ID)
        count = fin.read(ar)
        s = String(ar, 0, count)
        self.assertEqual(str(s).strip(), 'aewrv3v')
 def __requestForecastData(self, availableHours, parameters):
     from com.raytheon.viz.pointdata import PointDataRequest
     from com.raytheon.uf.common.time import DataTime
     from java.lang import String
     import jep
     dts = jep.jarray(len(availableHours), DataTime)
     for i in range(len(availableHours)):
         dts[i] = DataTime(self.refTime, int(availableHours[i]))
     constraints = self._buildConstraints(None) #times are explicitly set so we don't need to constrain those
     params = jep.jarray(len(parameters), String)
     for i in range(len(parameters)):
         params[i] = String(parameters[i])
     if self.site:
         stations = jep.jarray(1, String)
         stations[0] = String(self.site)
     else:
         stations = None
     return PointDataRequest.requestPointData(dts,
         self.pluginName, params, stations,
         constraints)        
Beispiel #25
0
    def test_read_file(self):
        from java.io import FileInputStream
        from java.lang import String

        filename = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'data/read_file.txt')
        fin = FileInputStream(filename)
        ar = jarray(20, JBYTE_ID)
        count = fin.read(ar)
        s = String(ar, 0, count)
        self.assertEqual(str(s).strip(), 'aewrv3v')
 def __requestForecastData(self, availableHours, parameters):
     from com.raytheon.viz.pointdata import PointDataRequest
     from com.raytheon.uf.common.time import DataTime
     from java.lang import String
     import jep
     dtsLen = len(availableHours)
     dts = jep.jarray(dtsLen, DataTime)
     for i in range(dtsLen):
         dts[i] = DataTime(self.refTime, availableHours[i].intValue())
     constraints = self._buildConstraints(
         None
     )  #fctTimes are explicitly set so we don't need to constrain those
     params = jep.jarray(len(parameters), String)
     for i in range(len(parameters)):
         params[i] = String(parameters[i])
     if self.site:
         stations = jep.jarray(1, String)
         stations[0] = String(self.site)
     else:
         stations = None
     return PointDataRequest.requestPointData(dts, self.pluginName, params,
                                              stations, constraints)
Beispiel #27
0
 def _contextForList(self, loctypes, loclevels, locname=None):
     # gets the contexts in list form, for ease of use, we always use a list of contexts
     # for methods that can take both
     contexts = jarray(len(loctypes), JavaLocalizationContext)
     for i in range(len(loctypes)):
         if locname is None and loclevels is None:
             return None
         elif loclevels is not None:
             contexts[i] = self.jpathManager.getContext(
                 loctypes[i], loclevels[i])
         if locname is not None:
             contexts[i].setContextName(locname)
     return contexts
 def _createJarray(self, availableTimes, maxSize): 
     from com.raytheon.uf.common.time import DataTime
     import jep 
     length = len(availableTimes)
     if maxSize > length:
         sz = length
     else:
         sz = maxSize
     dts = jep.jarray(sz, DataTime)
     for i in range(sz):
         dts[i] = DataTime(availableTimes[length-1-i])
     
     return dts
 def _createJarray(self, availableTimes, maxSize): 
     from com.raytheon.uf.common.time import DataTime
     import jep 
     length = len(availableTimes)
     if maxSize > length:
         sz = length
     else:
         sz = maxSize
     dts = jep.jarray(sz, DataTime)
     for i in range(sz):
         dts[i] = DataTime(availableTimes[length-1-i])
     
     return dts
Beispiel #30
0
def getGeometryData(request, times):
    if type(times) is list:
        # presuming list of DataTimes
        jtimes = jep.jarray(len(times), JavaDataTime)
        for i in xrange(len(times)):
            jtimes[i] = times[i].toJavaObj()    
        javaData = JavaDataAccessLayer.getGeometryData(request.toJavaObj(), jtimes)
    else:
        # presuming TimeRange
        javaData = JavaDataAccessLayer.getGeometryData(request.toJavaObj(), times.toJavaObj())        
    data = []
    for jd in javaData:
        data.append(JGeometryData.JGeometryData(jd))
    return data
Beispiel #31
0
def getGeometryData(request, times):
    if type(times) is list:
        # presuming list of DataTimes
        jtimes = jep.jarray(len(times), JavaDataTime)
        for i in xrange(len(times)):
            jtimes[i] = times[i].toJavaObj()    
        javaData = JavaDataAccessLayer.getGeometryData(request.toJavaObj(), jtimes)
    else:
        # presuming TimeRange
        javaData = JavaDataAccessLayer.getGeometryData(request.toJavaObj(), times.toJavaObj())        
    data = []
    for jd in javaData:
        data.append(JGeometryData.JGeometryData(jd))
    return data
Beispiel #32
0
 def makeArea(self, pointList, refname=None):
     " Make a Reference Area with a unique ReferenceID"
     from com.vividsolutions.jts.geom import GeometryFactory, LinearRing, Coordinate, Polygon
     from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceData_CoordinateType as CoordinateType
     geomFactory = GeometryFactory()
     import jep
     size = len(pointList)
     if pointList[0] != pointList[size-1]: # closing the loop
         pointList.append(pointList[0])
     pointArray = jep.jarray(len(pointList), Coordinate)
     for i in range(len(pointList)):
         pointArray[i] = pointList[i]
     lr = geomFactory.createLinearRing(pointArray)
     poly = geomFactory.createPolygon(lr, jep.jarray(0, LinearRing))
     polyArray = jep.jarray(1, Polygon)
     polyArray[0] = poly
     region = geomFactory.createMultiPolygon(polyArray)
     if refname is None:
         refname = "Ref" + getTime()    
     refId = ReferenceID(refname)
     refData = ReferenceData(self.__gridLoc, refId, region, CoordinateType.valueOf("LATLON"))
     # randerso: I don't think this is necessary
     # refData.convertToAWIPS()
     return refData
Beispiel #33
0
    def _conflictingLocks(self, hazParms):
        # find all the time ranges that should be locked
        neededTRs = set()
        
        for hazParm in hazParms:
            trList = self._getWEInventory(hazParm)
            neededTRs = neededTRs.union(trList)
        
        # Find all the time ranges that are locked in Hazards
        myTRs = self.lockedByMe(ELEMENT, LEVEL)
        myTRs = set(myTRs)
        
        # Add locks we already have to the needed TRs,
        # in case grids were deleted
        neededTRs = neededTRs.union(myTRs)

        # Squish the TRs into contiguous blocks
        neededTRs = self._mergeTimeranges(neededTRs)
        
        # See if there are any blocks we don't have yet
        missingTRs = neededTRs - myTRs
        
        # If not, then there are no conflicts and we're done.
        if len(missingTRs) == 0:
            return 0

        startTimes = jep.jarray(len(missingTRs), Date)
        
        midx = 0
        for missingTR in missingTRs:
            startTimes[midx] = missingTR.toJavaObj().getStart()
            midx += 1

        hazardParm = self.getParm(MODEL, ELEMENT, LEVEL)
        gridData = None
        try:
            gridData = hazardParm.startParmEdit(startTimes)
        except RuntimeError, runtimeErr:
            if runtimeErr.message is None:
                raise
            if runtimeErr.message.startswith("com.raytheon.viz.gfe.GFEOperationFailedException:"):
                return 1
            else:
                raise
Beispiel #34
0
    def _conflictingLocks(self, hazParms):
        # find all the time ranges that should be locked
        neededTRs = set()
        
        for hazParm in hazParms:
            trList = self._getWEInventory(hazParm)
            neededTRs = neededTRs.union(trList)
        
        # Find all the time ranges that are locked in Hazards
        myTRs = self.lockedByMe(ELEMENT, LEVEL)
        myTRs = set(myTRs)
        
        # Add locks we already have to the needed TRs,
        # in case grids were deleted
        neededTRs = neededTRs.union(myTRs)

        # Squish the TRs into contiguous blocks
        neededTRs = self._mergeTimeranges(neededTRs)
        
        # See if there are any blocks we don't have yet
        missingTRs = neededTRs - myTRs
        
        # If not, then there are no conflicts and we're done.
        if len(missingTRs) == 0:
            return 0

        startTimes = jep.jarray(len(missingTRs), Date)
        
        midx = 0
        for missingTR in missingTRs:
            startTimes[midx] = missingTR.toJavaObj().getStart()
            midx += 1

        hazardParm = self.getParm(MODEL, ELEMENT, LEVEL)
        gridData = None
        try:
            gridData = hazardParm.startParmEdit(startTimes)
        except RuntimeError, runtimeErr:
            if runtimeErr.message is None:
                raise
            if runtimeErr.message.startswith("com.raytheon.viz.gfe.GFEOperationFailedException:"):
                return 1
            else:
                raise
 def _createJarray(self, availableTimes, numHours):
     from java.util import Date
     from com.raytheon.uf.common.time import DataTime
     import jep, time
     #Get a DataTime numHours from current time
     stTime = long(time.time()) * 1000
     stTime -= numHours * (60 * 60 * 1000)
     stDateTime = DataTime(Date(stTime))
     length = len(availableTimes)
     xdts = []
     for i in range(length):
         d = DataTime(availableTimes[length - 1 - i])
         if d.greaterThan(stDateTime):
             xdts.append(d)
         else:
             break
     sz = len(xdts)
     dts = jep.jarray(sz, DataTime)
     i = 0
     for d in xdts:
         dts[i] = d
         i += 1
     return dts
 def _createJarray(self, availableTimes, numHours):  
     from java.util import Date
     from com.raytheon.uf.common.time import DataTime
     import jep, time
     #Get a DataTime numHours from current time
     stTime = long(time.time()) * 1000
     stTime -= numHours * (60 * 60 * 1000)
     stDateTime = DataTime(Date(stTime))
     length = len(availableTimes)
     xdts = []
     for i in range(length) :
         d = DataTime(availableTimes[length-1-i])
         if d.greaterThan(stDateTime) :
             xdts.append(d)
         else :
              break
     sz = len(xdts)
     dts = jep.jarray(sz, DataTime)
     i = 0
     for d in xdts:
         dts[i] = d
         i += 1
     return dts
Beispiel #37
0
    def listFiles(self,
                  name,
                  extensions,
                  recursive,
                  filesOnly,
                  loctype=None,
                  loclevel=None,
                  locname=None):
        '''
        @param name: the name and path of the file
        @param extensions: a list of the file extensions to filter on
        @param recursive: whether or not to search through the directory recursively
        @param filesOnly: whether or not directories should be included in the list
        @param loctype: the localization type for which to get the file
        @param loclevel: the localization level for which to get the file
        @param locname: the name for which to get
        @return: a list of the file paths
        @summary: This method returns the list of fully qualified file paths for a 
        directory or a directory and its sub-directories
        '''
        contexts = self._getContext(loctype, loclevel, locname)
        extensionSize = len(extensions)
        extArr = jarray(extensionSize, String)
        for i in range(extensionSize):
            extArr[i] = String(extensions[i])

        if contexts is not None:
            jfiles = self.jpathManager.listFiles(contexts, name, extArr,
                                                 recursive, filesOnly)
        else:
            jfiles = self.jpathManager.listStaticFiles(name, extArr, recursive,
                                                       filesOnly)
        if jfiles is not None:
            files = []
            for file in jfiles:
                files.append(LocalizationFile(file))
            return files
    def check(self, filname):
        '''
        @summary: Public interface for verifying a localization file exists.
        @param fname: File path to file, below level/name path components.
        @return: boolean for whether file exists, may throw
                 LocalFileInstallerException for certain failures.
        '''
        self.__luc.setSubDirectory(filname)
        resp = None
        try:
            urm = UtilityRequestMessage()
            urmArray = jep.jarray(1, AbstractUtilityCommand)
            urmArray[0] = self.__luc
            urm.setCommands(urmArray)
            resp = self.route(urm, self.__service)
            respList = resp.getResponses()
            entries = respList[0].getEntries()
            if len(entries) == 1 and entries[0].getFileName() == filname:
                return True
        except ThriftClient.ThriftRequestException:
            raise LocalFileInstallerException(
                "getList: Error sending request to server")

        return False
Beispiel #39
0
 def _lockHazards(self):
     "Flag the hazards parm as being edited. Return the hazards parm and its grid."
     hazParm = self.getParm(MODEL, ELEMENT, LEVEL)
     startAbsTime = AbsTime(int(current().unixTime() /3600)*3600) 
     endAbsTime = startAbsTime + LOCK_HOURS() * HOUR_SECONDS()
     timeRange = TimeRange(startAbsTime, endAbsTime)
     
     inventory = self._getWEInventory(ELEMENT, timeRange, asJava=True)
     startTimes = jep.jarray(len(inventory), Date) 
     for trNum in range(len(inventory)):
         startTimes[trNum] = inventory[trNum].getStart()
     gridData = None
     try:
         # startParmEdit() refreshes the grids and sets up the times that endParmEdit() will lock.
         gridData = hazParm.startParmEdit(startTimes)
     except RuntimeError, runtimeErr:
         if runtimeErr.message is None:
             raise
         if runtimeErr.message.startswith("com.raytheon.viz.gfe.GFEOperationFailedException:"):
             self.statusBarMsg("There are conflicting locks.  " + \
                               "Please resolve these before adding any hazards", "S")
             hazParm = None
         else:
             raise
Beispiel #40
0
 def _lockHazards(self):
     "Flag the hazards parm as being edited. Return the hazards parm and its grid."
     hazParm = self.getParm(MODEL, ELEMENT, LEVEL)
     startAbsTime = AbsTime(int(current().unixTime() /3600)*3600) 
     endAbsTime = startAbsTime + LOCK_HOURS() * HOUR_SECONDS()
     timeRange = TimeRange(startAbsTime, endAbsTime)
     
     inventory = self._getWEInventory(ELEMENT, timeRange, asJava=True)
     startTimes = jep.jarray(len(inventory), Date) 
     for trNum in range(len(inventory)):
         startTimes[trNum] = inventory[trNum].getStart()
     gridData = None
     try:
         # startParmEdit() refreshes the grids and sets up the times that endParmEdit() will lock.
         gridData = hazParm.startParmEdit(startTimes)
     except RuntimeError, runtimeErr:
         if runtimeErr.message is None:
             raise
         if runtimeErr.message.startswith("com.raytheon.viz.gfe.GFEOperationFailedException:"):
             self.statusBarMsg("There are conflicting locks.  " + \
                               "Please resolve these before adding any hazards", "S")
             hazParm = None
         else:
             raise
Beispiel #41
0
 def test_iter(self):
     ar = jarray(20, JINT_ID, 0)
     for i in range(20):
         ar[i] = i
     for array_item, i in enumerate(ar):
         self.assertEqual(array_item, i)
Beispiel #42
0
 def testCharArrayCreation(self):
     NDArray = jep.findClass("jep.NDArray")
     with self.assertRaises(ValueError):
         NDArray(jep.jarray(4, jep.JCHAR_ID))
Beispiel #43
0
 def test_setitem_out_of_bounds_throws_exception(self):
     ar = jarray(1, JINT_ID, 0)
     with self.assertRaises(IndexError):
         ar[1] = 1234
Beispiel #44
0
 def test_int_setitem_wrong_type_throws_exception(self):
     ar = jarray(1, JINT_ID, 0)
     with self.assertRaises(TypeError):
         ar[0] = 'fail'
Beispiel #45
0
 def test_index_error(self):
     x = jep.jarray(3, Integer)
     try:
         i = x[5]
     except IndexError as ex:
         pass
Beispiel #46
0
 def test_integer_setitem_object_throws_exception(self):
     from java.lang import Integer, Object
     ar = jarray(1, Integer)
     t = Object()
     with self.assertRaises(TypeError):
         ar[0] = t
Beispiel #47
0
 def testCharArrayCreation(self):
     NDArray = jep.findClass("jep.NDArray")
     with self.assertRaises(ValueError):
         NDArray(jep.jarray(4, jep.JCHAR_ID))
Beispiel #48
0
 def test_slice_with_step_not_1_throws_exception(self):
     ar = jarray(10, JINT_ID, 0)
     with self.assertRaises(TypeError):
         ar[::-1]
     with self.assertRaises(TypeError):
         ar[::2]
Beispiel #49
0
 def test_object_setitem_None(self):
     from java.lang import Object
     ar = jarray(1, Object)
     t = None
     ar[0] = t
     self.assertEqual(ar[0], t)
Beispiel #50
0
 def close(self):
     array = jep.jarray(1, JavaFile)
     array[0] = self.file
     FileLocker.unlock(self.lockerObject, array)
     return super(File, self).close()
Beispiel #51
0
 def test_slice_with_step_not_1_throws_exception(self):
     ar = jarray(10, JINT_ID, 0)
     with self.assertRaises(TypeError):
         ar[::-1]
     with self.assertRaises(TypeError):
         ar[::2]
Beispiel #52
0
 def test_initialization(self):
     ar = jarray(1, JINT_ID, 7)
     self.assertEqual(ar[0], 7)
Beispiel #53
0
 def test_setitem(self):
     ar = jarray(1, JINT_ID, 0)
     ar[0] = 1234
     self.assertEqual(ar[0], 1234)
Beispiel #54
0
 def test_index_error(self):
     x = jep.jarray(3, Integer)
     try:
         i = x[5]
     except IndexError as ex:
         pass
Beispiel #55
0
 def test_slice_out_of_bounds_handled_cleanly(self):
     ar = jarray(10, JINT_ID, 0)
     self.assertEqual(len(ar[100:]), 0)
     self.assertEqual(len(ar[:100]), 10)
Beispiel #56
0
 def test_integer_setitem_int(self):
     from java.lang import Integer
     ar = jarray(1, Integer)
     t = 1
     ar[0] = t
     self.assertEqual(ar[0], t)
Beispiel #57
0
 def test_string_index_conversion(self):
     from java.lang import Object
     from java.lang import String
     ar = jarray(1, Object)
     ar[0] = String("String")
     self.assertEqual(ar[0], "String")
def jf_ja(x_type, *x_jo_list):  # (j)ava (a)rray with type
    fu_sz = len(x_jo_list)
    fu_ja = jep.jarray(fu_sz, x_type)
    for bu2_idx, bu2_it in enumerate(x_jo_list):
        fu_ja[bu2_idx] = x_jo_list[bu2_idx]
    return fu_ja
Beispiel #59
0
 def test_string_index_conversion(self):
     from java.lang import Object
     from java.lang import String
     ar = jarray(1, Object)
     ar[0] = String("String")
     self.assertEqual(ar[0], "String")
Beispiel #60
0
 def test_slice_out_of_bounds_handled_cleanly(self):
     ar = jarray(10, JINT_ID, 0)
     self.assertEqual(len(ar[100:]), 0)
     self.assertEqual(len(ar[:100]), 10)