コード例 #1
0
    def listen(self):

        # integrate the ooxcb event handlers into the gobject mainloop.
        gobject.io_add_watch(
                self.display.get_file_descriptor(),
                gobject.IO_IN,
                self._ooxcb_callback)
コード例 #2
0
ファイル: tinyhttpserver.py プロジェクト: dmmartins/amsn2
    def __init__(self, backend, socket, peer, rules):
        self._backend = backend
        self._socket = socket
        self._socket.setblocking(0)
        self._peer = peer

        self._rbuf = ""
        self._wbuf = ""
        self._read = 0
        self._written = 0

        self._read_delimiter = "\r\n\r\n"
        self._bytes_to_read = 0
        self._rcb = self.on_headers

        self._is_alive = True

        self._rules = rules

        self._in_id = gobject.io_add_watch(socket.fileno(),
                             gobject.IO_IN | gobject.IO_PRI,
                             self.on_read)
        self._out_id = gobject.io_add_watch(self._socket.fileno(),
                             gobject.IO_OUT,
                             self.on_write)
        self._err_id = gobject.io_add_watch(self._socket.fileno(),
                             gobject.IO_ERR,
                             self.on_error)
        self._hup_id = gobject.io_add_watch(self._socket.fileno(),
                             gobject.IO_HUP,
                             self.on_hang_up)
コード例 #3
0
ファイル: base.py プロジェクト: Conectel/stoqdrivers
 def notify_read(self, func):
     """ This function can be called when the callsite must know when data
     is coming from the serial port.   It is necessary that a gobject main
     loop is already running before calling this method.
     """
     gobject.io_add_watch(self.get_port().fd, gobject.IO_IN,
                          lambda fd, cond: func(self, cond))
コード例 #4
0
ファイル: ggbg.py プロジェクト: hdon/ggbg
 def connect(self, addr):
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     gobject.io_add_watch(
         self.sock,
         gobject.IO_IN | gobject.IO_HUP,
         self.recv)
     print 'connect()', self.sock.connect(addr) # host, port
コード例 #5
0
ファイル: wicd-curses.py プロジェクト: cpyarger/wicd
def run():
    """ Run the UI. """
    global loop
    loop = gobject.MainLoop()

    ui.set_mouse_tracking()
    app = appGUI()

    # Connect signals and whatnot to UI screen control functions
    bus.add_signal_receiver(app.dbus_scan_finished, 'SendEndScanSignal',
                            'org.wicd.daemon.wireless')
    bus.add_signal_receiver(app.dbus_scan_started, 'SendStartScanSignal',
                            'org.wicd.daemon.wireless')
    # I've left this commented out many times.
    bus.add_signal_receiver(app.update_netlist, 'StatusChanged',
                            'org.wicd.daemon')
    # Update the connection status on the bottom every 2 s.
    gobject.timeout_add(2000, app.update_status)

    # Get input file descriptors and add callbacks to the ui-updating function
    fds = ui.get_input_descriptors()
    for fd in fds:
        gobject.io_add_watch(fd, gobject.IO_IN, app.call_update_ui)
    app.update_ui()
    loop.run()
コード例 #6
0
ファイル: samples.py プロジェクト: JonasNorling/nowplot
 def __init__(self, fd, separator):
     self.fd = fd
     self.count = 0
     self.prepend_timestamp = False
     self.prepend_count = False
     self.separator = separator
     gobject.io_add_watch(self.fd, gobject.IO_IN, self.parse_input)
コード例 #7
0
 def fetch():
     if not url.endswith('css'):
         fd = urllib.urlopen(url)
         gobject.io_add_watch(fd.fp, gobject.IO_IN, self.readable, stream)
     else:
         if stream:
             stream.close()
コード例 #8
0
ファイル: __init__.py プロジェクト: linnea-s/sepiida
 def connect(self, callback, errback):
     self._reqID = 0
     self.connected = False
     self.errback = errback
     
     cmd = ['ssh', '-o', 'ConnectTimeout=6', self.hostname, 'sepiida-connect']
     self._process = process = subprocess.Popen(cmd, shell=False,
                                      stdin=subprocess.PIPE,
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.PIPE,
                                      preexec_fn=os.setsid)
     sid1 = gobject.io_add_watch(process.stdout, gobject.IO_IN, self._readResponse)
     sid2 = gobject.io_add_watch(process.stdout, gobject.IO_ERR | gobject.IO_HUP, self._IOErr)
     self.sourceIDs = [sid1, sid2]
 
     def cbHello(server, data, error=''):
         if error:
             gobject.idle_add(errback, self, _('Not authorized'))
             self._process.wait()
             
             for sid in self.sourceIDs:
                 gobject.source_remove(sid)
         else:
             self.connected = True
             gobject.idle_add(callback, self)
     
     self._requests[self._reqID] = cbHello
コード例 #9
0
 def button_resume(widget):
     if self._tracing:
         return
     self._tracing = 1
     widget.set_label("Tracing ...")
     gobject.io_add_watch(self._tf, gobject.IO_IN, TrackFile)
     return
コード例 #10
0
def startserver(host, port, window):
    def on_fifo_data(fd, *args):
        sck = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)
        try:
            client, addr = sck.accept()
            client.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0))
            try:
                client.shutdown(socket.SHUT_RDWR)
            finally:
                client.close()
        except socket.error as err:
            pass
        toggle_visible(window)
        return True

    sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
    sck.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sck.bind((host, port))
    sck.listen(socket.SOMAXCONN)
    gobject.io_add_watch(sck.fileno(), gobject.IO_IN, on_fifo_data)

    sighandler = makesighandler(sck)
    signal.signal(signal.SIGQUIT, sighandler)
    signal.signal(signal.SIGTERM, sighandler)
    signal.signal(signal.SIGINT, sighandler)
    atexit.register(sighandler)
コード例 #11
0
ファイル: spydr.py プロジェクト: frigaut/yorick-spydr
   def __init__(self,spydrtop,spydr_showlower,spydr_dpi,spydr_showplugins):
      self.spydrtop = spydrtop
      self.spydr_showlower = spydr_showlower
      self.spydr_defaultdpi = spydr_dpi
      self.spydr_dpi = spydr_dpi
      self.spydr_showplugins = spydr_showplugins
      self.usercmd = 'STOP'

      # callbacks and glade UI

      self.glade = gtk.glade.XML(os.path.join(self.spydrtop,'spydr.glade'))
      self.window = self.glade.get_widget('window1')
      # handle destroy event
      if (self.window):
         self.window.connect('destroy', self.destroy)
      self.glade.signal_autoconnect(self)

      # set stdin non blocking, this will prevent readline to block
      fd = sys.stdin.fileno()
      flags = fcntl.fcntl(fd, fcntl.F_GETFL)
      fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)

      # add stdin to the event loop (yorick input pipe by spawn)
      gobject.io_add_watch(sys.stdin,gobject.IO_IN|gobject.IO_HUP,self.yo2py,None)

      # update parameters from yorick:
      #self.py2yo('gui_update')

      ebox = self.glade.get_widget('vbox3')
      ebox.connect('key-press-event',self.on_vbox3_key_press)

      # set size of graphic areas:
      self.drawingareas_size_allocate(spydr_dpi)

      self.pyk_debug=0
      self.win_init_done = 0
      self.currentdir=os.getcwd()
      self.currentsavedir=os.getcwd()
      self.imgroup=None
      self.current_image_menu=0
      self.current_image_saveas_name=None
      self.just_done_range=0
      self.next_to_all = 0

      if (spydr_showlower==0):
         if (spydr_dpi < 70):
            self.glade.get_widget('frame1').hide()
         if (spydr_dpi < 85):
            self.glade.get_widget('frame2').hide()
         self.glade.get_widget('table1').hide()
         self.glade.get_widget('drawingarea3').hide()
         self.glade.get_widget('togglelower').set_active(0)

      if (spydr_showplugins):
         self.glade.get_widget('plugins_pane').show()

      self.pyk_status_push(1,'Initializing...')

      # run
      gtk.main()
コード例 #12
0
ファイル: gyotoy.py プロジェクト: begemotv2718/Gyoto
    def __init__(self, gyotoytop):
        gobject.set_application_name("Gyotoy")
        gobject.set_prgname("Gyotoy")

        self.gyotoytop = gyotoytop
        self._pyk_blocked = 0
        self.length_unit = "geometrical"

        # read GUI definition
        self.glade = gtk.glade.XML(os.path.join(self.gyotoytop, "gyotoy.glade"))

        # handle destroy event (so that we can kill the window through window bar)
        self.window = self.glade.get_widget("window1")
        if self.window:
            self.window.connect("destroy", self.destroy)

        # autoconnect to callback functions
        # this will automatically connect the event handler "on_something_event"
        # to the here-defined function of the same name. This avoid defining a
        # long dictionary that serves the same purpose
        self.glade.signal_autoconnect(self)

        # set stdin non blocking, this will prevent readline to block
        # stdin is coming from yorick (yorick spawned this python process)
        fd = sys.stdin.fileno()
        flags = fcntl.fcntl(fd, fcntl.F_GETFL)
        fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)

        # ... and add stdin to the event loop (yorick input pipe by spawn)
        gobject.io_add_watch(sys.stdin, gobject.IO_IN | gobject.IO_HUP, self.yo2py, None)

        # run: realize the interface, start event management
        gtk.main()
コード例 #13
0
    def start_server(self):
        self.server_sock = bluetooth.BluetoothSocket (bluetooth.L2CAP)
        self.server_sock.bind(("",0x1001))
        self.server_sock.listen(1)

        gobject.io_add_watch(self.server_sock, 
                gobject.IO_IN, self.incoming_connection)
コード例 #14
0
ファイル: scons.py プロジェクト: jhasse/taluka
	def build(self):
		self.create() # change me
		
		self._bottom_panel.activate_item(self._panel)
		
#		docs = self._window.get_unsaved_documents()
#		for doc in docs:
#			if doc.get_uri() != None:
#				doc.save(0)

		self._panel.clear()

		cmdline = "scons -Q debug=1"
		self.pipe = subprocess.Popen(cmdline.split(" "), stdout=PIPE, stderr=PIPE, cwd=self._directory)
		
		gobject.io_add_watch(self.pipe.stdout,
		                     gobject.IO_IN | gobject.IO_HUP,
		                     self.on_output)
		gobject.io_add_watch(self.pipe.stderr,
		                     gobject.IO_IN | gobject.IO_HUP,
		                     self.on_output)

		self._firstError = True
		# Wait for the process to complete
		gobject.child_watch_add(self.pipe.pid, self.on_child_end)
コード例 #15
0
ファイル: uzbl_tabbed.py プロジェクト: Tanger/uzbl
    def _setup_fifo_watcher(self, fifo_socket):
        '''Open fifo socket fd and setup gobject IO_IN & IO_HUP watchers.
        Also log the creation of a fd and store the the internal
        self._watchers dictionary along with the filename of the fd.'''

        if fifo_socket in self._fifos.keys():
            fd, watchers = self._fifos[fifo_socket]
            os.close(fd)
            for watcherid in watchers.keys():
                gobject.source_remove(watchers[watcherid])
                del watchers[watcherid]

            del self._fifos[fifo_socket]
        
        # Re-open fifo and add listeners.
        fd = os.open(fifo_socket, os.O_RDONLY | os.O_NONBLOCK)
        watchers = {}
        self._fifos[fifo_socket] = (fd, watchers)
        watcher = lambda key, id: watchers.__setitem__(key, id)
        
        # Watch for incoming data.
        gid = gobject.io_add_watch(fd, gobject.IO_IN, self.main_fifo_read)
        watcher('main-fifo-read', gid)
        
        # Watch for fifo hangups.
        gid = gobject.io_add_watch(fd, gobject.IO_HUP, self.main_fifo_hangup)
        watcher('main-fifo-hangup', gid)
コード例 #16
0
ファイル: output.py プロジェクト: Conservatory/quark
    def main(self):
        self.thread_lock = threading.Lock()
        self.shm_obj = None
        self.sem_obj = None

        self.soc = socket.fromfd(int(sys.argv[1]), msg.FAMILY, msg.TYPE)

        gobject.io_add_watch(self.soc.fileno(), gobject.IO_IN, self.handle_input)
        gobject.io_add_watch(self.soc.fileno(), gobject.IO_HUP, self.handle_hup)

        window = gtk.Window() #gtk.WINDOW_TOPLEVEL) 
        window.set_decorated(False)
        window.set_app_paintable(True)
        screen = window.get_screen()
        rgba = screen.get_rgba_colormap()
        window.set_colormap(rgba)

        window.set_title("Quark Web Browser Output")
        window.set_default_size(1100,710)
        #window.set_keep_above(True)
        window.set_decorated(False)
        window.connect("destroy", self.window_destroyed)
        window.connect('expose-event', self.expose)
        window.move(100,300)
        self.win = window
                
        window.show_all()

        (x,y,width,height,depth) = self.win.window.get_geometry()
        self.pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
        gtk.main()
コード例 #17
0
ファイル: ipc.py プロジェクト: osebelin/qtile
    def _receive(self, conn, cond, data):
        try:
            recv = conn.recv(4096)
        except socket.error as e:
            if er.errno in (errno.EAGAIN, errno.EINTR):
                return True
            raise
        else:
            if recv == '':
                gobject.source_remove(data['tag'])
                conn.close()
                return True

            data['buffer'] += recv
            if 'header' not in data and len(data['buffer']) >= HDRLEN:
                data['header'] = struct.unpack("!L", data['buffer'][:HDRLEN])
                data['buffer'] = data['buffer'][HDRLEN:]
            if 'header' in data:
                if len(data['buffer']) < data['header'][0]:
                    return True

            req = self._unpack_body(data['buffer'])
            data['result'] = self._pack_reply(self.handler(req))
            gobject.io_add_watch(conn, gobject.IO_OUT, self._send, data)
            return False
コード例 #18
0
ファイル: net.py プロジェクト: igoralmeida/remuco
 def __init__(self, sock, addr, clients, pinfo_msg, msg_handler_fn, c_type):
     
     self.__sock = sock
     self.__addr = addr
     self.__clients = clients
     self.__pinfo_msg = pinfo_msg
     self.__msg_handler_fn = msg_handler_fn
     self.__conn_type = c_type
     
     # client info
     self.info = ClientInfo()
     self.__psave = False
     
     # the following fields are used for iterative receiving on message data
     # see io_recv() and io_recv_buff()
     self.__rcv_buff_header = ReceiveBuffer()
     self.__rcv_buff_data = ReceiveBuffer()
     self.__rcv_msg_id = message.IGNORE
     self.__rcv_msg_size = 0
     
     self.__snd_buff = "" # buffer for outgoing data
     
     # source IDs for various events
     self.__sids = [
         gobject.io_add_watch(self.__sock, gobject.IO_IN, self.__io_recv),
         gobject.io_add_watch(self.__sock, gobject.IO_ERR, self.__io_error),
         gobject.io_add_watch(self.__sock, gobject.IO_HUP, self.__io_hup)
         ]
     self.__sid_out = 0
     
     log.debug("send 'hello' to %s" % self)
     
     self.send(ClientConnection.IO_HELLO)
コード例 #19
0
ファイル: socket_server.py プロジェクト: aoloe/shoebot
 def listener(self, sock, *args):
     '''Asynchronous connection listener. Starts a handler for each connection.'''
     self.conn, self.addr = self.sock.accept()
     print _("Connected")
     gobject.io_add_watch(self.conn, gobject.IO_IN, self.handler)
     self.conn.send(self.msg_banner())
     return True
コード例 #20
0
ファイル: output.py プロジェクト: UCSD-PL/kraken
 def handle_input(self, source, condition):
     #olog("handle_input:")
     m = self.message_handler.recv()
     if m[0] == message.RenderCompleted :
         # load a new shared memory
         #olog("display msg is received")
         shmid = int(m[1])
         if self.shm_obj <> None:
             if self.shm_obj.shmid == shmid :
                 self.redraw()
             else:
                 self.thread_lock.acquire()
                 try :
                     self.shm_obj.detach()
                     self.shm_obj = shm.memory(shmid)
                     self.sem_obj = shm.semaphore(shm.getsemid(shmid))
                     self.shm_obj.attach()
                 finally:
                     self.thread_lock.release()
         else :
             self.thread_lock.acquire()
             try :
                 self.shm_obj = shm.memory(shmid)
                 self.sem_obj = shm.semaphore(shm.getsemid(shmid))
                 self.shm_obj.attach()
             finally:
                 self.thread_lock.release()
     else :
         sys.stderr.write('invalid event type\n')
         sys.exit(1)
     gobject.io_add_watch(self.soc.fileno(), gobject.IO_IN, self.handle_input)
     return False
コード例 #21
0
	def listener(self, sock, *args):
		'''Asynchronous connection listener. Starts a handler for each connection.'''
		conn, addr = sock.accept()
		loggy.log( "Connected from " + str(conn.getsockname()))
		gobject.io_add_watch(conn, gobject.IO_IN, self.handler)
		conn.send('OK MPD 0.16.0\n')
		return True
コード例 #22
0
ファイル: widget_sky.py プロジェクト: dgratadour/yoga_ao
    def __init__(self, path=os.path.join(yoga_ao_top, "glade"), parent=None, py2yo=None):

        self.path = path

        self.gladefile = "widget_sky.glade"

        self.glade = gtk.glade.XML(os.path.join(path, self.gladefile), root="top")
        self.top = self.glade.get_widget("top")

        # handle destroy event
        if self.top:
            self.top.connect("destroy", self.destroy)

        self.glade.signal_autoconnect(self)

        if parent:
            parent.foreach(parent.remove)
            parent.add(self.top)

        # Do not open stdin event if not in standalone mode
        if not py2yo:
            # set stdin non blocking, this will prevent readline to block
            fd = sys.stdin.fileno()
            flags = fcntl.fcntl(fd, fcntl.F_GETFL)
            fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)

            # add stdin to the event loop (yorick input pipe by spawn)
            gobject.io_add_watch(sys.stdin, gobject.IO_IN | gobject.IO_HUP, self.yo2py, None)

        # self.glade.get_widget('expander1').set_expanded(0)
        # self.glade.get_widget('expander2').set_expanded(0)
        self.glade.get_widget("layer_select").set_active(0)
        self.glade.get_widget("target_select").set_active(0)
コード例 #23
0
    def run(self, args, input_data, auto_close, pickle=False):
        self.response_active = False
        self.auto_close = auto_close
        self.error_lines = []
        self.pickle = pickle

        for button in self.buttons:
            button.set_sensitive(False)

        #print >> sys.stderr, "ZEOBUILDER, spawn process"
        self.process = subprocess.Popen(
            args, bufsize=0, stdin=subprocess.PIPE,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE
        )
        if self.pickle:
            cPickle.dump(input_data, self.process.stdin, -1)
        else:
            self.process.stdin.write(input_data)
        self.process.stdin.close()

        #print >> sys.stderr, "ZEOBUILDER, add io_watch"
        self.event_sources = [
            gobject.io_add_watch(self.process.stdout, gobject.IO_IN, self._on_receive_out, priority=200),
            gobject.io_add_watch(self.process.stdout, gobject.IO_HUP, self._on_done, priority=200),
            gobject.io_add_watch(self.process.stderr, gobject.IO_IN, self._on_receive_err, priority=200),
        ]

        self.dialog.set_transient_for(context.parent_window)
        result = self.response_loop()
        self.dialog.hide()

        #print >> sys.stderr, "result", result
        return result
コード例 #24
0
    def run(self):
        signal.signal(signal.SIGINT, self.terminate)
        signal.signal(signal.SIGTERM, self.terminate)
        setproctitle.setproctitle('pulse_watcher')

        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        signals = (
            ('NewPlaybackStream', 'org.PulseAudio.Core1.{}',
                self.on_new_playback_stream),
            ('PlaybackStreamRemoved', 'org.PulseAudio.Core1.{}',
                self.on_playback_stream_removed),
            ('FallbackSinkUpdated', 'org.PulseAudio.Core1.{}',
                self.on_fallback_sink_updated),
            ('DeviceUpdated', 'org.PulseAudio.Core1.Stream.{}',
                self.on_device_updated),
        )
        self._connect(signals)
        self.update()
        self.default_sink = self.fallback_sink

        self.thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=1)

        mainloop = gobject.MainLoop()
        gobject.io_add_watch(
            self.message_queue._reader, gobject.IO_IN | gobject.IO_PRI,
            self._on_new_message)
        try:
            mainloop.run()
        except KeyboardInterrupt:
            pass
コード例 #25
0
    def __init__(self, server_address, RequestHandlerClass):
        SocketServer.TCPServer.__init__(self, server_address,
                                        RequestHandlerClass)
        self.socket.setblocking(0)  # Set nonblocking

        # Watch the listener socket for data
        gobject.io_add_watch(self.socket, gobject.IO_IN, self._handle_accept)
コード例 #26
0
ファイル: screen.py プロジェクト: UCSD-PL/kraken
  def main(self):
    self.thread_lock = threading.Lock()

    window = gtk.Window() #gtk.WINDOW_TOPLEVEL) 
    window.set_decorated(False)
    window.set_app_paintable(True)
    screen = window.get_screen()
    rgba = screen.get_rgba_colormap()
    window.set_colormap(rgba)
    
    window.set_title("Quark Web Browser Output")
    window.set_default_size(1100,710)
    window.set_decorated(False)
    window.connect("destroy", self.window_destroyed)
    window.connect('expose-event', self.expose)
    window.move(100,300)
    self.win = window
                
    window.show_all()

    (x,y,width,height,depth) = self.win.window.get_geometry()
    self.pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)

    msg.init()
    gobject.io_add_watch(msg.KCHAN.fileno(), gobject.IO_IN, self.handle_msgs)

    gtk.main()
コード例 #27
0
ファイル: loggergui.py プロジェクト: pombredanne/guilogger
def start(name):
    global logfilename, logfile, gui
    logfilename = name
    logfile = file(logfilename, "w")
    gobject.io_add_watch(sys.stdin, gobject.IO_IN, inputhandler)
    gui = GUI()
    gtk.main()
コード例 #28
0
ファイル: computerstatus.py プロジェクト: alon/misc
 def start_connecting(self):
     sock = socket.socket()
     sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     print "connecting.."
     sock.connect((HOST, PORT))
     print "connected"
     gobject.io_add_watch(sock, gobject.IO_IN, self.handler)
コード例 #29
0
ファイル: __init__.py プロジェクト: icgood/irssi-icon
 def _connect_local_socket(self):
     self._msg_sock = socket.socket(socket.AF_INET)
     self._msg_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self._msg_sock.bind(('127.0.0.1', 21693))
     self._msg_sock.listen(5)
     gobject.io_add_watch(self._msg_sock, gobject.IO_IN,
                          self._msg_sock_connection)
コード例 #30
0
ファイル: mixer.py プロジェクト: awgrover/LaureDrogoul_seesaw
def main():
    global vol,pipe
    pipe = None
    if sys.argv[1] == '1':
        pipe,vol = do_mic()
    elif sys.argv[1] == '2':
        pipe,vol = do_file()
        print "pipe %s vol %s" % (pipe,vol)
    else:
        print "what?"
        exit(1)

    print "initial volume: %s" % vol.get_property('volume')
    gobject.io_add_watch(sys.stdin, gobject.IO_IN, adjust_volume)

    # gtk.main()

    if sys.argv[1] == '1':
        gtk.main()

    loop = gobject.MainLoop()
    gobject.threads_init()
    bus = pipe.get_bus()
    while(1):
        msg = bus.poll(gst.MESSAGE_ANY, -1)
        if msg.type != gst.MESSAGE_STATE_CHANGED:
            # print msg.type
            pass
        if msg.type == gst.MESSAGE_EOS:
           # print "--- EOS"
           # pipe,vol = do_file()
           pipe.set_state(gst.STATE_READY)
           pipe.set_state(gst.STATE_PLAYING)
        pass