예제 #1
0
    def start(self, request):
        logger.debug("Starting Pipeline {id}".format(id=self.id))
        self.request = request

        try:
            self.destination = Destination.create_instance(request)
        except:
            self.destination = None

        request["models"] = self.models

        self._add_default_parameters()

        self._gst_launch_string = string.Formatter().vformat(
            self.template, [], request)

        logger.debug(self._gst_launch_string)

        self.pipeline = Gst.parse_launch(self._gst_launch_string)

        self._add_element_parameters()
        self._add_tags()

        sink = self.pipeline.get_by_name("appsink")

        sink.set_property("emit-signals", True)
        sink.set_property('sync', False)
        sink.connect("new-sample", GStreamerPipeline.on_sample, self)

        bus = self.pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect("message", GStreamerPipeline.bus_call, self)

        self.pipeline.set_state(Gst.State.PLAYING)
        self.start_time = time.time()
예제 #2
0
파일: views.py 프로젝트: 16sheep/Catalog
def newDestination():
    newDestinationId = session.query(Destination).order_by(Destination.id.desc()).first()
    newDestinationId = newDestinationId.id + 1
    print login_session
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newDestination = Destination(name=request.form['name'],
                                     description=request.form['description'],
                                     image=request.form['image'],
                                     times=request.form['times'],
                                     phone=request.form['phone'],
                                     email=login_session['email'],
                                     user_id=login_session['user_id'])
        session.add(newDestination)
        session.commit()
        newAddress = Address(a_line_1=request.form['a_line_1'],
                             a_line_2=request.form['a_line_2'],
                             town=request.form['town'],
                             postcode=request.form['postcode'],
                             country=request.form['country'],
                             destination_id=newDestinationId)
        session.add(newAddress)
        session.commit()
        flash('New Destination %s Successfully Created' % newDestination.name)
        return redirect(url_for('showDestinations'))
    else:
        return render_template('newDestination.html')
예제 #3
0
    def test_create_instance(self):
        request = {"destination": {"type": "kafka"}}
        MockKafkaDestination = type("MockKafkaDestination", (object, ), {
            "__init__": lambda self, destination: None
        })
        Destination.destination_types['kafka'] = MockKafkaDestination

        result = Destination.create_instance(request)

        self.assertIsInstance(result, MockKafkaDestination)
예제 #4
0
    def test_create_instance_empty_request(self):
        request = None
        MockKafkaDestination = type("MockKafkaDestination", (object, ), {
            "__init__": lambda self, destination: None
        })
        Destination.destination_types['kafka'] = MockKafkaDestination
        logger = logging.get_logger('DestinationTypes', is_static=True)

        with self.assertLogs(logger=logger, level='DEBUG') as cm:
            result = Destination.create_instance(request)
        self.assertIn("Error", cm.output.pop())
예제 #5
0
    def start(self):
        logger.debug("Starting Pipeline {id}".format(id=self.id))

        try:
            self.destination = Destination.create_instance(self.request)
        except:
            self.destination = None

        self.request["models"] = self.models
        self._add_default_parameters()
        self._gst_launch_string = string.Formatter().vformat(
            self.template, [], self.request)
        logger.debug(self._gst_launch_string)
        self.pipeline = Gst.parse_launch(self._gst_launch_string)
        self._add_element_parameters()
        self._add_tags()
        self._add_default_models()
        sink = self.pipeline.get_by_name("appsink")

        if sink is not None:
            sink.set_property("emit-signals", True)
            sink.set_property('sync', False)
            sink.connect("new-sample", GStreamerPipeline.on_sample, self)
            self.avg_fps = 0

        src = self.pipeline.get_by_name("source")

        if src and sink:
            src_pad = src.get_static_pad("src")
            if (src_pad):
                src_pad.add_probe(Gst.PadProbeType.BUFFER,
                                  GStreamerPipeline.source_probe_callback,
                                  self)
            else:
                src.connect("pad-added",
                            GStreamerPipeline.source_pad_added_callback, self)
            sink_pad = sink.get_static_pad("sink")
            sink_pad.add_probe(Gst.PadProbeType.BUFFER,
                               GStreamerPipeline.appsink_probe_callback, self)

        bus = self.pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect("message", GStreamerPipeline.bus_call, self)
        splitmuxsink = self.pipeline.get_by_name("splitmuxsink")
        self._real_base = None

        if (splitmuxsink != None):
            splitmuxsink.connect("format-location-full",
                                 self.format_location_callback, None)

        self.pipeline.set_state(Gst.State.PLAYING)
        self.start_time = time.time()
예제 #6
0
 def __init__(self, id, config, models, request):
     self.config = config
     self.id = id
     self.pipeline = None
     self.request = request
     self.state = "QUEUED"
     self.frame_count = 0
     self.start_time = None
     self.stop_time = None
     self.avg_fps = 0
     self.destination = None
     try:
         self.destination = Destination.create_instance(self.request)
     except:
         self.destination = None
     self.request["models"] = models
     self._gst_launch_string = string.Formatter().vformat(
         config['template'], [], request)
예제 #7
0
파일: adddata.py 프로젝트: 16sheep/Catalog
# Create dummy users
User1 = User(name="Lily Cross", email="*****@*****.**")
session.add(User1)
session.commit()

User2 = User(name="Ray Hirsh", email="*****@*****.**")
session.add(User2)
session.commit()

# Destinations with attractions
destination1 = Destination(
    user_id=1,
    name="3 Tractors",
    description="Learn to drive a tractor and ride around our farm",
    image=
    "https://c.pxhere.com/photos/9f/65/farm_tractor_agricultural_equipment_machine_farmer_farming_agriculture-799939.jpg!d",
    times="Friday-Sunday 9am - 4pm",
    phone="7700 900077",
    email="*****@*****.**")

session.add(destination1)
session.commit()

address1 = Address(user_id=1,
                   a_line_1="Berry Shute",
                   a_line_2=None,
                   town="Newport",
                   postcode="PO30 3HA",
                   country="United Kingdom",
                   destination=destination1)