Esempio n. 1
0
    def stop(self):
        GObject.source_remove(self.watcher)
        if is_unix_socket(self.server_socket):
            unix_socket_path = self.server_socket.getsockname()
        else:
            unix_socket_path = None

        self.server_socket.shutdown(socket.SHUT_RDWR)
        self.server_socket.close()

        # clean up the socket file
        if unix_socket_path is not None:
            os.unlink(unix_socket_path)
Esempio n. 2
0
    def stop(self):
        GObject.source_remove(self.watcher)
        if is_unix_socket(self.server_socket):
            unix_socket_path = self.server_socket.getsockname()
        else:
            unix_socket_path = None

        self.server_socket.shutdown(socket.SHUT_RDWR)
        self.server_socket.close()

        # clean up the socket file
        if unix_socket_path is not None:
            os.unlink(unix_socket_path)
Esempio n. 3
0
    def enable_timeout(self):
        """Reactivate timeout mechanism."""
        if self.timeout <= 0:
            return

        self.disable_timeout()
        self.timeout_id = GObject.timeout_add_seconds(
            self.timeout, self.timeout_callback)
Esempio n. 4
0
    def enable_timeout(self):
        """Reactivate timeout mechanism."""
        if self.timeout <= 0:
            return

        self.disable_timeout()
        self.timeout_id = GObject.timeout_add_seconds(
            self.timeout, self.timeout_callback)
Esempio n. 5
0
    def enable_send(self):
        if self.send_id is not None:
            return

        try:
            self.send_id = GObject.io_add_watch(
                self._sock.fileno(),
                GObject.IO_OUT | GObject.IO_ERR | GObject.IO_HUP,
                self.send_callback)
        except socket.error as e:
            self.stop('Problem with connection: %s' % e)
Esempio n. 6
0
    def enable_send(self):
        if self.send_id is not None:
            return

        try:
            self.send_id = GObject.io_add_watch(
                self._sock.fileno(),
                GObject.IO_OUT | GObject.IO_ERR | GObject.IO_HUP,
                self.send_callback)
        except socket.error as e:
            self.stop('Problem with connection: %s' % e)
Esempio n. 7
0
    def make_taglist(self, tag, values):
        taglist = Gst.TagList.new_empty()

        for value in values:
            if isinstance(value, (GLib.Date, Gst.DateTime)):
                taglist.add_value(Gst.TagMergeMode.APPEND, tag, value)
                continue

            gobject_value = GObject.Value()
            if isinstance(value, bytes):
                gobject_value.init(GObject.TYPE_STRING)
                gobject_value.set_string(value)
            elif isinstance(value, int):
                gobject_value.init(GObject.TYPE_UINT)
                gobject_value.set_uint(value)
                gobject_value.init(GObject.TYPE_VALUE)
                gobject_value.set_value(value)
            else:
                raise TypeError
            taglist.add_value(Gst.TagMergeMode.APPEND, tag, gobject_value)

        return taglist
Esempio n. 8
0
 def set_value(tag, value):
     gobject_value = GObject.Value()
     gobject_value.init(GObject.TYPE_STRING)
     gobject_value.set_string(value)
     taglist.add_value(Gst.TagMergeMode.REPLACE, tag, gobject_value)
Esempio n. 9
0
    def disable_send(self):
        if self.send_id is None:
            return

        GObject.source_remove(self.send_id)
        self.send_id = None
Esempio n. 10
0
 def disable_recv(self):
     if self.recv_id is None:
         return
     GObject.source_remove(self.recv_id)
     self.recv_id = None
Esempio n. 11
0
 def disable_timeout(self):
     """Deactivate timeout mechanism."""
     if self.timeout_id is None:
         return
     GObject.source_remove(self.timeout_id)
     self.timeout_id = None
Esempio n. 12
0
 def register_server_socket(self, fileno):
     return GObject.io_add_watch(
         fileno,
         GObject.IO_IN,
         self.handle_connection)
Esempio n. 13
0
    def disable_send(self):
        if self.send_id is None:
            return

        GObject.source_remove(self.send_id)
        self.send_id = None
Esempio n. 14
0
 def disable_recv(self):
     if self.recv_id is None:
         return
     GObject.source_remove(self.recv_id)
     self.recv_id = None
Esempio n. 15
0
 def disable_timeout(self):
     """Deactivate timeout mechanism."""
     if self.timeout_id is None:
         return
     GObject.source_remove(self.timeout_id)
     self.timeout_id = None
Esempio n. 16
0
 def register_server_socket(self, fileno):
     return GObject.io_add_watch(
         fileno,
         GObject.IO_IN,
         self.handle_connection)