Exemple #1
0
Fichier : test.py Projet : tmc/eio
    def test_mkdir(self):
        def mkdir_cb(foo):
            print 'mkdir callback', foo
        
        d1 = 'test'
        d2 = 'test/eio-test-dir'

        # ensure dirs don't exist:
        if os.path.exists(d2):
            os.rmdir(d2)
        if os.path.exists(d1):
            os.rmdir(d1)

        self.assertFalse(os.path.exists(d1))
        eio.mkdir(d1, 0777, mkdir_cb)
        time.sleep(0.1)
        print 'poll', eio.poll()
        self.assertTrue(os.path.exists(d1))

        self.assertFalse(os.path.exists(d2))
        eio.mkdir(d2, 0777, mkdir_cb)
        time.sleep(2.1)
        print 'poll', eio.poll()
        self.assertTrue(os.path.exists(d2))
        
        eio.rmdir(d2)
        self.assertFalse(os.path.exists(d2))
        eio.rmdir(d1)
        self.assertFalse(os.path.exists(d1))
Exemple #2
0
    respipe = os.pipe()
#
#  printf ("eio_init ()\n");
    print 'eio_init ()'

#  if (eio_init (want_poll, done_poll)) abort ();
    if eio.init(want_poll, done_poll):
#    if eio.init():
        print 'init failed, aborting'
        os.abort()
#
#  do
#    {
#      /* avoid relative paths yourself(!) */
#      eio_mkdir ("eio-test-dir", 0777, 0, res_cb, "mkdir");
    r = eio.mkdir('eio-test-dir', 0777)
#      eio_nop (0, res_cb, "nop");
    eio.nop()
#      eio_stat ("eio-test-dir", 0, stat_cb, "stat");
    eio.stat('eio-test-dir', stat_callback)
#      eio_lstat ("eio-test-dir", 0, stat_cb, "stat");
    eio.lstat('eio-test-dir')
#      eio_open ("eio-test-dir/eio-test-file", O_RDWR | O_CREAT, 0777, 0, open_cb, "open");
    eio.open('eio-test-dir/eio-test-file', os.O_RDWR | os.O_CREAT, 0777, open_callback)
#      eio_symlink ("test", "eio-test-dir/eio-symlink", 0, res_cb, "symlink");
    eio.symlink('test', 'eio-test-dir/eio-symlink')
#      eio_mknod ("eio-test-dir/eio-fifo", S_IFIFO, 0, 0, res_cb, "mknod");
    eio.mknod('eio-test-dir/eio-fifo', stat.S_IFIFO, 0)
#      event_loop ();
    event_loop()
#