Example #1
0
    def referenceframeupdate(self, event):
        self.log("Updating system vessel mapview coordinates", event, self.vesselmapview, lvl=verbose)
        self.log("Data:", event.data, lvl=verbose)
        frame = event.data["data"]
        if "GLL_lat" in frame and "GLL_lon" in frame:
            # pprint(frame['GLL_lat'])
            # pprint(self.vesselmapview._fields)
            coords = {"lat": float(frame["GLL_lat"]), "lng": float(frame["GLL_lon"]), "zoom": 10, "autoDiscover": False}
            self.vesselmapview.coords = coords
            self.vesselmapview.save()

            self.fireEvent(
                updatesubscriptions(uuid=self.vesselmapview.uuid, schema="mapview", data=self.vesselmapview), "hfosweb"
            )
Example #2
0
    def libraryrequest(self, event):
        self.log("Someone interacts with the library! Yay!", lvl=warn)
        try:
            book = None

            if event.action == "lend":
                book = objectmodels['book'].find_one({'uuid': event.data})
                if book.available:
                    book.available = False
                    book.status = "Lent"
                    book.statuschange = datetime.now().isoformat()
                    book.statusowner = str(event.user.uuid)
                    book.save()
                    self.log("Book successfully lent.")
                else:
                    self.log("Book can't be lent, it is not available!",
                             lvl=warn)
            elif event.action == "return":
                book = objectmodels['book'].find_one({'uuid': event.data})
                if not book.available:
                    book.available = True
                    book.status = "Available"
                    book.statuschange = datetime.now().isoformat()
                    book.statusowner = str(event.user.uuid)
                    book.save()
                    self.log("Book successfully returned.")
                else:
                    self.log("Book can't be lent, it is not available!",
                             lvl=warn)
            elif event.action == "augment":
                self._augmentBook('book', event.data, event.client)

            if book:
                self.fireEvent(
                    updatesubscriptions(uuid=book.uuid, schema='book',
                                        data=book))
        except Exception as e:
            self.log("Error during library handling: ", type(e), e,
                     lvl=critical, exc=True)