Exemplo n.º 1
0
    def start(self, dev=1):
        try:
            self.cam = vc.Device(dev)
            self.currentdevice = dev
        except vidcap.error:
            if dev == 0:
                utils.error("Could not start camera")
                return
            self.start(dev=0)
            return

        self.timer.start()
Exemplo n.º 2
0
    def start(self, dev=1):
        try:
            self.cam = vc.Device(dev)
            self.currentdevice = dev
        except vidcap.error:
            if dev == 0:
                utils.error("Could not start camera")
                return
            self.start(dev=0)
            return

        self.timer.start()
Exemplo n.º 3
0
    def start(self, dev=1):
        try:
            self.cam = vc.Device(dev)
            self.currentdevice = dev
        except vidcap.error:
            if dev == 0:
                utils.error("Could not start camera")
                raise CameraError("Could not start camera")
            self.start(dev=0)
            return


        roam.config.settings['camera'] = self.currentdevice
        self.timer.start()
Exemplo n.º 4
0
    def start(self, dev=1):
        try:
            self.cam = vc.Device(dev)
            try:
                width, height = self.camera_res
                self.cam.setResolution(int(width), int(height))
            except KeyError:
                pass
            self.currentdevice = dev
        except vidcap.error:
            if dev == 0:
                utils.error("Could not start camera")
                raise CameraError("Could not start camera")
            self.start(dev=0)
            return

        roam.config.settings['camera'] = self.currentdevice
        self.timer.start()
Exemplo n.º 5
0
    def start(self, dev=1):
        try:
            self.cam = vc.Device(dev)
            try:
                width, height = self.camera_res
                self.cam.setResolution(int(width), int(height))
            except KeyError:
                pass
            self.currentdevice = dev
        except vidcap.error:
            if dev == 0:
                utils.error("Could not start camera")
                raise CameraError("Could not start camera")
            self.start(dev=0)
            return

        roam.config.settings['camera'] = self.currentdevice
        self.timer.start()
Exemplo n.º 6
0
    def generate_info(self,
                      infoblock,
                      project,
                      layer,
                      mapkey,
                      feature,
                      countlabel=None,
                      lastresults=None):
        infoblockdef = project.info_query(infoblock, layer.name())
        isinfo1 = infoblock == "info1"

        if not infoblockdef:
            if isinfo1:
                infoblockdef = {}
                infoblockdef['type'] = 'feature'
            else:
                return None, []

        if isinfo1:
            caption = infoblockdef.get('caption', "Record")
        else:
            caption = infoblockdef.get('caption', "Related Record")

        results = []
        error = None
        infotype = infoblockdef.get('type', 'feature')
        if infotype == 'sql':
            try:
                queryresults = self.results_from_query(infoblockdef,
                                                       layer,
                                                       feature,
                                                       mapkey,
                                                       lastresults=lastresults)
                if isinfo1 and not queryresults:
                    # If there is no results from the query and we are a info 1 block we grab from the feature.
                    results.append(self.results_from_feature(feature))
                else:
                    results = queryresults
            except database.DatabaseException as ex:
                RoamEvents.raisemessage("Query Error", ex.message, 3)
                utils.error(ex.message)
                if not isinfo1:
                    error = "<b> Error: {} <b>".format(ex.msg)
                else:
                    results.append(self.results_from_feature(feature))

        elif infotype == 'feature':
            featuredata = self.results_from_feature(feature)
            excludedfields = infoblockdef.get('hidden', [])
            for field in excludedfields:
                try:
                    del featuredata[field]
                except KeyError:
                    pass
            results.append(featuredata)
        else:
            return None, []

        blocks = []
        for count, result in enumerate(results, start=1):
            if isinfo1 and count == 1:
                countblock = countblocktemplate.substitute(count=countlabel)
            else:
                countblock = ''

            fields = result.keys()
            attributes = result.values()
            rows = generate_rows(fields,
                                 attributes,
                                 imagepath=self.project.image_folder)
            try:
                caption = caption.format(**dict(zip(fields, attributes)))
            except KeyError:
                pass

            blocks.append(
                updateTemplate(
                    dict(ROWS=rows, HEADER=caption, CONTROLS=countblock),
                    infoblocktemplate))
        if error:
            return error, []

        return '<br>'.join(blocks), results