Exemplo n.º 1
0
class LocatorEstimatesPoller(object):
    def __init__(self):
        self.listeners = []
        self.lastResult = {}
        self.locator = Locator()
        task.LoopingCall(self.poll).start(1)

    def poll(self):
        addrs = set(l.addr for l in self.listeners if l.addr)
        now = datetime.datetime.now(tzlocal())
        cutoff = (now - datetime.timedelta(seconds=60))
        
        for addr in addrs:
            d = {} # from: [(t, rssi)]
            for row in db.recentRssi(cutoff, addr):
                d.setdefault(row['from'], []).append((row['time'].timestamp, row['rssi']))

            for pts in d.values():
                pts.sort()
                smooth(pts)
            
            meas = Measurement(dict((k, v[-1][1]) for k, v in d.items()))
            nearest = [
                (dist, coord) for dist, coord in self.locator.nearestPoints(meas) if dist < 25
            ]
            if nearest:
                weightedCoord = self.locator.estimatePosition(nearest)
            else:
                weightedCoord = [-999, -999, -999]
            self.lastResult[addr] = {'nearest': nearest, 'weightedCoord': weightedCoord}
            
        for lis in self.listeners:
            lis.sendEvent(self.lastResult[addr])
Exemplo n.º 2
0
def locate_nearest():
    address = request.args.get('address', 'Austin, TX', type=str)
    page = request.args.get('page', 0, type=int)
    per_page = request.args.get('per_page', 10, type=int)
    locator = Locator("./data/geocoded_restaurants.json") 
    curr_location, nearest_locations = locator.nearest(address, page, per_page)
    return jsonify({"loc": curr_location, "results":[location[0] for location in nearest_locations]})
Exemplo n.º 3
0
	def __init__(self, config):
		self.ap_list = config["ap_properties"]
		self.poll_interval = config["monitoring_properties"]["poll_interval"]
		self._thread_pool = Pool(len(config["ap_properties"]))
		self._locator_queue = Queue()
		self._mode = config["method"]
		self._locator = Locator(self._locator_queue, config, self._mode)
Exemplo n.º 4
0
 def __init__(self, mapName, character):
     self.mapBuilder = MapBuilder(mapName)
     self.locator = Locator(mapName)
     self.trainingCycle = TrainingCycle(character, mapName)
     self.lootCycle = LootCycle(character, mapName)
     self.buff = Buff(character)
     self.startTime = time.time()
Exemplo n.º 5
0
def locate_nearest():
    address = request.args.get('address', 'Austin, TX', type=str)
    page = request.args.get('page', 0, type=int)
    per_page = request.args.get('per_page', 10, type=int)
    locator = Locator("/home/puppyplus/Projects/eater/data/geocoded_restaurants.json") 
    curr_location, nearest_locations = locator.nearest(address, page, per_page)
    return jsonify({"loc": curr_location, "results":[location[0] for location in nearest_locations]})
Exemplo n.º 6
0
 def _init_endpoint(self):
     locator = Locator()
     self.service_endpoint, _, service_api = locator.resolve(self.servicename, self._locator_host, self._locator_port)
     self._service_api = service_api
     # msgpack convert in list or tuple depend on version - make it tuple
     self.pipe = Pipe(tuple(self.service_endpoint), self.reconnect if self._try_reconnect else None)
     self.loop.bind_on_fd(self.pipe.fileno())
Exemplo n.º 7
0
    def __init__(self, driver):
        super().__init__(driver)
        self.go()

        locator = Locator(By.CSS_SELECTOR, "button#wzrk-cancel")
        button = BaseElement(self.driver, locator=locator)
        button.click_button()

        locator = Locator(By.CSS_SELECTOR, "button.Popup-button")
        button = BaseElement(self.driver, locator=locator)
        button.click_button()
Exemplo n.º 8
0
def main():
    app = QApplication(sys.argv)
    locator = Locator()
    locator.addCommandClass(CommandGotoLine)
    locator.addCommandClass(CommandOpen)
    locator.addCommandClass(CommandSaveAs)
    locator.show()
    return app.exec_()
Exemplo n.º 9
0
    def startIPS():
        receiverThread = Receiver('receiver')
        collectorThread = Collector('collector')
        preprocessorThread = Preprocessor('preprocessor')

        receiverThread.start()
        collectorThread.start()
        preprocessorThread.start()

        spectrumLoader = SpectrumLoader()
        spectrumLoader.loadSpectrum()

        locatingThread = Locator('locating')
        locatingThread.start()
Exemplo n.º 10
0
    def get_datatype(self):
        """Returns the `Locator` identifying the datatype of the value.

        :rtype: `Locator`

        """
        return Locator(self.datatype)
Exemplo n.º 11
0
def CreateLocatorList(self):
    from locator import Locator
    locatorList = []
    locatorObjs = Locator.GetAllLocators()
    for loc in locatorObjs:
        locatorList.append((loc.GetName(), loc.GetName(), ''))

    return locatorList
Exemplo n.º 12
0
    def locator_value(self):
        """Returns the `Locator` representation of the value.

        :rtype: `Locator`

        """
        if self.datatype == XSD_ANY_URI:
            return Locator(self.value)
        raise TypeError('Value is not a Locator')
Exemplo n.º 13
0
    def startIPS():
        receiverThread = Receiver('receiver')
        collectorThread = Collector('collector')
        preprocessorThread = Preprocessor('preprocessor')

        receiverThread.start()
        collectorThread.start()
        preprocessorThread.start()

        spectrumLoader = SpectrumLoader()
        spectrumLoader.loadSpectrum()

        locationDictLoader = LocationDictLoader()
        locationDictLoader.loadLoactionDict()

        locator = Locator()
        while True:
            print(locator.getLoacatingMessage(), '\n')
Exemplo n.º 14
0
    def get_locator(self):
        """Returns the `Locator` that was used to create the topic map.

        Note: The returned locator represents the storage address of
        the topic map and implies no further semantics.

        :rtype: `Locator`

        """
        return Locator(self.iri)
Exemplo n.º 15
0
 def select_emirate(self):
     locator = Locator(
         By.CSS_SELECTOR,
         "#root > div > div.Base-content > div > div.Checkout-content > div.Delivery-signInAndShippingAddress > form > section.NewAddress > label:nth-child(5) > div > div > span"
     )
     element = BaseElement(self.driver, locator=locator)
     ActionChains(self.driver).move_to_element(element.web_element).click(
         element.web_element).send_keys(Keys.ARROW_DOWN).send_keys(
             Keys.ENTER).perform()
     time.sleep(10)
Exemplo n.º 16
0
    def create_locator (self, reference):
        """Returns a `Locator` instance representing the specified IRI
        `reference`.

        The specified IRI `reference` is assumed to be absolute.

        :param reference: a string which uses the IRI notation
        :type reference: String
        :rtype: `Locator`

        """
        return Locator(reference)
Exemplo n.º 17
0
    def create_variant (self, value, scope, datatype=None):
        """Creates a `Variant` of this topic name with the specified
        string `value` and `scope`.

        If `datatype` is None, the newly created `Variant` will have
        the datatype xsd:string.

        The newly created `Variant` will contain all themes from the
        parent name and the themes specified in `scope`.

        :param value: the string value or locator which represents an IRI
        :type value: string or `Locator`
        :param scope: list of themes
        :type scope: list of `Topic`s
        :rtype: `Variant`

        """
        if value is None:
            raise ModelConstraintException(self, 'The value may not be None')
        if not scope:
            raise ModelConstraintException(self, 'The scope may not be None')
        if type(scope) not in (type([]), type(())):
            scope = [scope]
        if scope == list(self.get_scope()):
            raise ModelConstraintException(
                self, 'The variant would be in the same scope as the parent')
        if datatype is None:
            if isinstance(value, Locator):
                datatype = Locator(XSD_ANY_URI)
            elif isinstance(value, str):
                datatype = Locator(XSD_STRING)
        if isinstance(value, Locator):
            value = value.to_external_form()
        variant = Variant(name=self, datatype=datatype.to_external_form(),
                          value=value, topic_map=self.topic_map)
        variant.save()
        for theme in scope:
            variant.scope.add(theme)
        return variant
Exemplo n.º 18
0
class LocatorEstimatesPoller(object):
    def __init__(self):
        self.listeners = []
        self.lastResult = {}
        self.locator = Locator()
        task.LoopingCall(self.poll).start(1)

    def poll(self):
        addrs = set(l.addr for l in self.listeners if l.addr)
        now = datetime.datetime.now(tzlocal())
        cutoff = (now - datetime.timedelta(seconds=60))

        for addr in addrs:
            d = {}  # from: [(t, rssi)]
            for row in db.recentRssi(cutoff, addr):
                d.setdefault(row['from'], []).append(
                    (row['time'].timestamp, row['rssi']))

            for pts in d.values():
                pts.sort()
                smooth(pts)

            meas = Measurement(dict((k, v[-1][1]) for k, v in d.items()))
            nearest = [(dist, coord)
                       for dist, coord in self.locator.nearestPoints(meas)
                       if dist < 25]
            if nearest:
                weightedCoord = self.locator.estimatePosition(nearest)
            else:
                weightedCoord = [-999, -999, -999]
            self.lastResult[addr] = {
                'nearest': nearest,
                'weightedCoord': weightedCoord
            }

        for lis in self.listeners:
            lis.sendEvent(self.lastResult[addr])
Exemplo n.º 19
0
    def __init__(self, train_data, val_data, dataset_factory_name, model_dir, num_workers=None, checkpoint_dir=None,
                 epochs=10,
                 early_stopping_patience=10, checkpoint_frequency=1, grad_accumulation_steps=8, batch_size=8,
                 max_seq_len=512, learning_rate=0.00001, fine_tune=True):
        self.model_dir = model_dir
        self.fine_tune = fine_tune
        self.learning_rate = learning_rate
        self.checkpoint_frequency = checkpoint_frequency
        self.grad_accumulation_steps = grad_accumulation_steps
        self.early_stopping_patience = early_stopping_patience
        self.epochs = epochs
        self.checkpoint_dir = checkpoint_dir
        self.train_data = train_data
        self.val_data = val_data
        self.batch_size = batch_size
        self.dataset_factory = Locator().get(dataset_factory_name)

        self._max_seq_len = max_seq_len
        self.num_workers = num_workers or os.cpu_count() - 1
        if self.num_workers <= 0:
            self.num_workers = 0

        self._network = None
        self._train_dataloader = None
        self._train_dataset = None
        self._val_dataset = None
        self._val_dataloader = None
        self._trainer = None
        self._lossfunc = None
        self._optimiser = None
        self._label_mapper = None

        self._bert_model_name = "bert-base-cased"
        self._token_lower_case = False

        self._bert_config = None
        self._tokenisor = None
Exemplo n.º 20
0
    def create_name(self, value, name_type=None, scope=None, proxy=Name):
        """Creates a `Name` for this topic with the specified `value`,
        `type` and `scope`.

        If `name_type` is None, the created `Name` will have the default
        name type (a `Topic` with the subject identifier
        http://psi.topicmaps.org/iso13250/model/topic-name).

        If `scope` is None or an empty list, the name will be in the
        unconstrained scope.

        :param value: the string value of the name
        :type value: string
        :param name_type: the name type
        :type name_type: `Topic`
        :param scope: a list of themes
        :type scope: `Topic` or list of `Topic`s
        :param proxy: Django proxy model
        :type proxy: class
        :rtype: `Name`

        """
        if value is None:
            raise ModelConstraintException(self, 'The value may not be None')
        if name_type is None:
            name_type = self.topic_map.create_topic_by_subject_identifier(
                Locator('http://psi.topicmaps.org/iso13250/model/topic-name'))
        elif self.topic_map != name_type.topic_map:
            raise ModelConstraintException(
                self, 'The type is not from the same topic map')
        name = proxy(topic=self,
                     value=value,
                     topic_map=self.topic_map,
                     type=name_type)
        name.save()
        if scope is not None:
            if type(scope) not in (type([]), type(())):
                scope = [scope]
            for theme in scope:
                if self.topic_map != theme.topic_map:
                    raise ModelConstraintException(
                        self, 'The theme is not from the same topic map')
                name.scope.add(theme)
        return name
Exemplo n.º 21
0
    def create_occurrence (self, type, value, scope=None, datatype=None,
                           proxy=Occurrence):
        """Creates an `Occurrence` for this topic with the specified
        `type`, `value`, and `scope`.

        If `datatype` is not None, the newly created `Occurrence` will
        have the datatype specified by `datatype`.

        :param type: the occurrence type
        :type type: `Topic`
        :param value: the value of the occurrence
        :type value: String or `Locator`
        :param scope: optional list of themes
        :type scope: list of `Topic`s
        :param datatype: optional locator indicating the datatype of `value`
        :type datatype: `Locator`
        :param proxy: Django proxy model
        :type proxy: class
        :rtype: `Occurrence`
        
        """
        if type is None:
            raise ModelConstraintException(self, 'The type may not be None')
        if value is None:
            raise ModelConstraintException(self, 'The value may not be None')
        if datatype is None:
            if isinstance(value, Locator):
                datatype = Locator(XSD_ANY_URI)
            elif isinstance(value, float):
                datatype = Locator(XSD_FLOAT)
            elif isinstance(value, int):
                datatype = Locator(XSD_INT)
            elif isinstance(value, long):
                datatype = Locator(XSD_LONG)
            else:
                datatype = Locator(XSD_STRING)
        if self.topic_map != type.topic_map:
            raise ModelConstraintException(
                self, 'The type is not from the same topic map')
        occurrence = proxy(type=type, value=value,
                           datatype=datatype.to_external_form(),
                           topic=self, topic_map=self.topic_map)
        occurrence.save()
        if scope is not None:
            for theme in scope:
                if self.topic_map != theme.topic_map:
                    raise ModelConstraintException(
                        self, 'The theme is not from the same topic map')
                occurrence.scope.add(theme)
        return occurrence
Exemplo n.º 22
0
class LocatorNode():
    def __init__(self):
        rospy.init_node('locator_node')
        self.locator = Locator(rospy.get_param("~books_location"))
        self.service = rospy.Service('locate_book', book_locator,
                                     self.handle_requests)

    def handle_requests(self, req):
        print("Getting location request for " + str(req))
        location, orientation = self.locator.returnLocation(req.code)
        response = book_locatorResponse()
        response.floor = 4
        response.pose = Pose()
        response.pose.position = Point(location[0], location[1], location[2])
        response.pose.orientation = Quaternion(orientation[0], orientation[1],
                                               orientation[2], orientation[3])
        print(response)
        return response

    def spin_node(self):
        print("Locator node ready")
        rospy.spin()
Exemplo n.º 23
0
class Engine:

	def __init__(self, config):
		self.ap_list = config["ap_properties"]
		self.poll_interval = config["monitoring_properties"]["poll_interval"]
		self._thread_pool = Pool(len(config["ap_properties"]))
		self._locator_queue = Queue()
		self._mode = config["method"]
		self._locator = Locator(self._locator_queue, config, self._mode)

	def _fetch_probsup_dump(self, ap):
		client = SSHClient()
		client.set_missing_host_key_policy(AutoAddPolicy())
		try:
			client.connect(hostname=ap["ip_address"], port=ap["ssh_port"],
				           username=ap["login"], password=ap["password"], timeout=3)
		except (NoValidConnectionsError, timeout):
			return ""
		connect = client.invoke_shell()
		connect.send("wl -i %s probsup_dump\n" % ap["monitoring_interface"])
		while not connect.recv_ready():
			sleep(0.1)
		probsup_dump = connect.recv(50000).decode()
		connect.close()
		client.close()
		return probsup_dump

	def shutdown(self):
		self._thread_pool.close()
		self._thread_pool.join()
		self._locator.terminate()
		self._locator.join()

	def run(self):
		self._locator.start()
		while True:
			probsup_dumps = self._thread_pool.map(self._fetch_probsup_dump, self.ap_list)
			self._locator_queue.put(probsup_dumps)
			sleep(self.poll_interval)
Exemplo n.º 24
0
 def add_to_bag(self):
     locator = Locator(By.CSS_SELECTOR, "button.AddToBag")
     return BaseElement(self.driver, locator=locator)
Exemplo n.º 25
0
from fdmanage import FDManager, FileFDReader, SocketFDReader, STDFDReader
from locator import Locator, SingletonError

#fr=FileFDReader('filecontent.txt')
#fr=SocketFDReader(('localhost', 62525))
fr = STDFDReader()

locator = Locator(fr)

locator.init()

# if a Locator dobject is created again, it would raise a singletonerror
"""
try:
	locator2=Locator(fr)
except SingletonError as exc:
	print(exc)
	exit()
"""

#fm=FDManager('new_content_filereader.txt')
#fm=FDManager('new_content_socketreader.txt')
fm = FDManager('new_content_stdreader.txt')

while True:
    num_read = fm.read()
    if not num_read:
        break
    fm.write()
    num_read = 0
Exemplo n.º 26
0
 def select_size(self):
     locator = Locator(By.CSS_SELECTOR, "span.Select-arrow-zone")
     element = BaseElement(self.driver, locator=locator)
     ActionChains(self.driver).move_to_element(element.web_element).click(
         element.web_element).send_keys(Keys.ENTER).perform()
Exemplo n.º 27
0
import discord
from os.path import join, dirname

from discord import Guild
from dotenv import load_dotenv

from locator import Locator

dotenv_path = join(dirname(__file__), '.auth')
load_dotenv(dotenv_path)

CLIENT_ID = os.environ.get("CLIENT_ID")
CLIENT_SECRET = os.environ.get("CLIENT_SECRET")
TOKEN = os.environ.get("TOKEN")

locator = Locator()
debug = False


class MyClient(discord.Client):
    def __init__(self, _debug=False):
        super(MyClient, self).__init__()
        self.debug = _debug

    async def on_ready(self):
        print('Logged in as')
        print(self.user.name)
        print(self.user.id)
        print('------')

    async def fun(self, message):
Exemplo n.º 28
0
 def __init__(self, filename):
     self.f = open(filename, 'wt')
     self.reader = Locator.get_instance().get_reader()
     self.buf = ''
Exemplo n.º 29
0
 def checkout(self):
     locator = Locator(By.CSS_SELECTOR, "button.CartTotal-secureCheckout")
     return BaseElement(self.driver, locator=locator)
Exemplo n.º 30
0
 def __init__(self):
     self.listeners = []
     self.lastResult = {}
     self.locator = Locator()
     task.LoopingCall(self.poll).start(1)
Exemplo n.º 31
0
 def _continue(self):
     locator = Locator(By.CSS_SELECTOR,
                       "button.ShippingInformationForm-submitButton")
     return BaseElement(self.driver, locator=locator)
Exemplo n.º 32
0
 def enter_street(self):
     locator = Locator(By.CSS_SELECTOR, "input#street")
     return BaseElement(self.driver, locator=locator)
Exemplo n.º 33
0
 def apartment(self):
     locator = Locator(By.CSS_SELECTOR, "input#additionalInformation")
     return BaseElement(self.driver, locator=locator)
Exemplo n.º 34
0
 def enter_area(self, area):
     locator = Locator(By.CSS_SELECTOR, "input[name = 'city']")
     element = BaseElement(self.driver, locator=locator)
     element.input_text(area)
     element.send_keys(Keys.TAB)
Exemplo n.º 35
0
 def enter_phone_number(self):
     locator = Locator(By.CSS_SELECTOR, "input#mobileNumber")
     return BaseElement(self.driver, locator=locator)
Exemplo n.º 36
0
 def __init__(self):
     rospy.init_node('locator_node')
     self.locator = Locator(rospy.get_param("~books_location"))
     self.service = rospy.Service('locate_book', book_locator,
                                  self.handle_requests)
Exemplo n.º 37
0
 def go_to_bag(self):
     locator = Locator(By.XPATH, "//div[text() = 'Bag']")
     return BaseElement(self.driver, locator=locator)