Ejemplo n.º 1
0
    def _pre_open(self, io_object):
        io_object.setblocking(False)
        channel = glib.IOChannel(io_object.fileno())
        channel.set_flags(channel.get_flags() | glib.IO_FLAG_NONBLOCK)
        channel.set_encoding(None)
        channel.set_buffered(False)

        self._transport = io_object
        self._channel = channel

        self._source_id = None
        self._source_condition = 0
        self._outgoing_queue = []
        AbstractClient._pre_open(self)
Ejemplo n.º 2
0
 def start(self, peer, buffersync):
     self._sock = mksock(peer)
     self._keepalive = KeepAlive(self._sock, peer, "data")
     ioc = glib.IOChannel(self._sock.fileno())
     self._ioc_sig = ioc.add_watch(glib.IO_IN, self._data)
     self._buffersync = buffersync
Ejemplo n.º 3
0
#Set flags to show Audio and Video but ignore Subtitles
flags = data.playbin2.get_property("flags")
flags |= (GstPlayFlags.GST_PLAY_FLAG_VIDEO | GstPlayFlags.GST_PLAY_FLAG_AUDIO)
flags &= ~GstPlayFlags.GST_PLAY_FLAG_TEXT
data.playbin2.set_property("flags", flags)

#Set connection speed. This will affect some internal decisions of playbin2
data.playbin2.set_property("connection_speed", 56)

#Add a bus watch, so we get notified when a message arrives
bus = data.playbin2.get_bus()
bus.add_watch(handle_message, data)

#Add a keyboard watch so we get notified of keystrokes
io_stdin = glib.IOChannel(sys.stdin.fileno())
io_stdin.add_watch(glib.IO_IN, handle_keyboard, data)

#Start playing
ret = data.playbin2.set_state(gst.STATE_PLAYING)
if (ret == gst.STATE_CHANGE_FAILURE):
    print >> sys.stderr, ("Unable to set pipeline to the playing state")
    exit(-1)

#Create a GLib Main Loop and set it to run
data.main_loop = gobject.MainLoop(None, False)
data.main_loop.run()

#Free resources
data.playbin2.set_state(gst.STATE_NULL)
Ejemplo n.º 4
0
                sys.argv[3])
            do_stat = True

        else:
            do_stat = False

        #creation de la socket
        sock_serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock_serv.bind((str(sys.argv[1]), int(sys.argv[2])))
        sock_serv.listen(1)

        print "En attente de joueur sur HOST:{0} PORT:{1}".format(
            sys.argv[1], sys.argv[2])

        #en attente d'un joueur
        (sock, address) = sock_serv.accept()

        #affichage de la magnifique interface graphique
        global bot
        tr = TrControllerClient(sock, address)
        tr.run()

        #gestion du multiprocessus: socket + gtk
        channel_sock = glib.IOChannel(sock.fileno())
        channel_sock.set_flags(channel_sock.get_flags()
                               | glib.IO_FLAG_NONBLOCK)
        channel_sock.add_watch(condition=glib.IO_IN, callback=handle_read_sock)

        #on envoie la sauce avec la boucle principale
        glib.MainLoop().run()
Ejemplo n.º 5
0
							redraw(data)

						return True
		print "@PROJECT_PRETTY_NAME@ @PROJECT_VERSION@"

		data = Data()
		fd = sys.stdin.fileno()
		old = termios.tcgetattr(fd)
		new = termios.tcgetattr(fd)
		new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
		termios.tcsetattr(fd, termios.TCSANOW, new)

		oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
		fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)

		io_stdin = glib.IOChannel(fd)
		io_stdin.add_watch(glib.IO_IN, handle_keyboard, data)

		try:
			erase_line()
			display_prompt()
			sys.stdout.flush()
			main_loop = gobject.MainLoop(None, False)
			main_loop.run()
		except KeyboardInterrupt:
			sys.exit()
		except:
			traceback.print_stack()
		finally:
			termios.tcsetattr(fd, termios.TCSAFLUSH, old)
			fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)