示例#1
0
    def openCapsule(TSCid=None, lat=None, lng=None, password=None, user=None):
        """
		openCapsule will assign the capsule is mode is not anonymous 
		and then will return to caller
		Is capsule is anonymous or already assigned, it will try to open it
		"""
        L.info("openCapsule Called")
        L.debug({
            'dumping parameters': '',
            'TSCid': TSCid,
            'lat': lat,
            'lng': lng,
            'pwd len': len(password) if password is not None else -1,
            'user': user
        })
        # capsule not found
        tsc = TimespaceCapsule.getByTSCid(TSCid)
        if tsc is None:
            return (TSCController.TSCCTRL_BADTSCID, None)
        # if not anonymous here we require a valid user.
        if not tsc.anonymous and tsc.user is None:
            if user is None:
                return (TSCController.TSCCTRL_BADUSER, None)
            L.info("TSC is not anonymous, binding ...")
            L.info(user)
            tsc.assignToUser(user)
            return (TSCController.TSCCTRL_ASSIGNED, None)

        # try to open
        L.info("try to disclose")
        response = tsc.disclose(lat=lat, lng=lng, user=user, password=password)
        return (TSCController.TSCCTRL_OK, response)
示例#2
0
    def radar(TSCid=None, lat=None, lng=None):
        """
		Return how meters are we far away the capsule.
		"""
        L.info("radar Called")
        L.debug({'TSCid': TSCid, 'lat': lat, 'lng': lng})
        tsc = TimespaceCapsule.getByTSCid(TSCid)
        if tsc is None:
            return (TSCController.TSCCTRL_BADTSCID, None)
        return (TSCController.TSCCTRL_OK, tsc.distance(lat, lng))
示例#3
0
	def radar( TSCid=None, lat=None, lng=None):
		"""
		Return how meters are we far away the capsule.
		"""
		L.info("radar Called")
		L.debug({
			'TSCid':TSCid, 
			'lat': lat, 
			'lng':lng
		})
		tsc = TimespaceCapsule.getByTSCid(TSCid)
		if tsc is None:
			return  (TSCController.TSCCTRL_BADTSCID, None)
		return (TSCController.TSCCTRL_OK, tsc.distance( lat, lng ))
示例#4
0
	def openCapsule(
			TSCid=None,
			lat=None,
			lng=None,
			password=None,
			user=None
		):
		"""
		openCapsule will assign the capsule is mode is not anonymous 
		and then will return to caller
		Is capsule is anonymous or already assigned, it will try to open it
		"""
		L.info("openCapsule Called")
		L.debug({
			'dumping parameters': '',
			'TSCid' : TSCid, 
			'lat' : lat,
			'lng' : lng, 
			'pwd len': len(password) if password is not None else -1,
			'user':user
		})
		# capsule not found
		tsc = TimespaceCapsule.getByTSCid(TSCid)
		if tsc is None:
			return (TSCController.TSCCTRL_BADTSCID, None)
		# if not anonymous here we require a valid user.
		if not tsc.anonymous and tsc.user is None:
			if user is None:
				return (TSCController.TSCCTRL_BADUSER, None)
			L.info("TSC is not anonymous, binding ...")
			L.info(user)
			tsc.assignToUser( user )
			return  (TSCController.TSCCTRL_ASSIGNED, None )
		
		# try to open
		L.info("try to disclose")
		response = tsc.disclose( 
						lat=lat,
						lng=lng,
						user=user,
						password=password
					)
		return ( TSCController.TSCCTRL_OK, response)
示例#5
0
	def searchCapsule(
			TSCid=None,
			seen=False,
			anonymous=True,
			notified=False,
			assigned=False,
			encrypt=False,
			user=None
		):
		"""
		Search a TSC depending on the given parameters, if tscid is 
		provided extra parameters are ignored.
		"""
		L.info("searchCapsule called ")
		L.debug({
			'Dumping paramters' : '',
			'anonymous' : anonymous, 
			'notified' : notified, 
			'assigned' : assigned, 
			'encrypt' : encrypt, 
			'user' : user 
		})
		
		# if TSCid is provided SEARCH only by TSCid.
		if TSCid is not None:
			L.info("TSCid is not None")
			tsc = TimespaceCapsule.getByTSCid( TSCid )
			tscList = [tsc] if tsc is not None else [] 
		else:
			# more elements
			tscList = TimespaceCapsule.getList( 
						user=user, 
						seenFlag=seen,
						assignedFlag=assigned,
						notifiedFlag=notified,
						encryptFlag=encrypt
					)
			
		items = [ tsc.toEndPointMessage() for tsc in tscList ]
		if any(items): 
			L.info( "No capsule found!")
		return ( TSCController.TSCCTRL_OK, items )
示例#6
0
    def searchCapsule(TSCid=None,
                      seen=False,
                      anonymous=True,
                      notified=False,
                      assigned=False,
                      encrypt=False,
                      user=None):
        """
		Search a TSC depending on the given parameters, if tscid is 
		provided extra parameters are ignored.
		"""
        L.info("searchCapsule called ")
        L.debug({
            'Dumping paramters': '',
            'anonymous': anonymous,
            'notified': notified,
            'assigned': assigned,
            'encrypt': encrypt,
            'user': user
        })

        # if TSCid is provided SEARCH only by TSCid.
        if TSCid is not None:
            L.info("TSCid is not None")
            tsc = TimespaceCapsule.getByTSCid(TSCid)
            tscList = [tsc] if tsc is not None else []
        else:
            # more elements
            tscList = TimespaceCapsule.getList(user=user,
                                               seenFlag=seen,
                                               assignedFlag=assigned,
                                               notifiedFlag=notified,
                                               encryptFlag=encrypt)

        items = [tsc.toEndPointMessage() for tsc in tscList]
        if any(items):
            L.info("No capsule found!")
        return (TSCController.TSCCTRL_OK, items)