9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] webfs from Python
@ 2003-02-16 21:24 Moroo Jun
  0 siblings, 0 replies; 4+ messages in thread
From: Moroo Jun @ 2003-02-16 21:24 UTC (permalink / raw)
  To: 9fans

I tried to use webfs from Python. I wrote a little test script and try
to get web page, but fail.
Any suggestions?

cpu% cat web.py
import os

web = open("/mnt/web/clone","rw")
t=web.readlines()
id=int(t[0])
base=os.path.join("/mnt/web/%d" % id)
ctlfd=open(os.path.join(base,"ctl"),"rw")
ctlfd.write("url http://www.example.com/index.html")
bodyfd=open(os.path.join(base,"body"),"r")
t=bodyfd.read(),
print t
web.close()
cpu% python web.py
Traceback (most recent call last):
   File w.py:9, in ?
     bodyfd=open(os.path.join(base,"body"),"r")
IOError: [Errno 0] url is not yet set: '/mnt/web/0/body'



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] webfs from Python
  2003-02-16 21:20 ` Russ Cox
@ 2003-02-17 15:08   ` Moroo Jun
  0 siblings, 0 replies; 4+ messages in thread
From: Moroo Jun @ 2003-02-17 15:08 UTC (permalink / raw)
  To: 9fans

On 2003.02.17, at 06:20, Russ Cox wrote:
> perhaps you have to ctlfd.flush()

Thank you for advice.
This script get web page fine. webfs looks nice.

import os
web = open("/mnt/web/clone","rw")
t=web.readlines()
id=int(t[0])
base=os.path.join("/mnt/web/%d" % id)
ctlfd=open(os.path.join(base,"ctl"),"w")
ctlfd.write("url http://www.moroo.com/index.html")
ctlfd.flush()
bodyfd=open(os.path.join(base,"body"),"r")
t=bodyfd.read(),
print t
web.close()



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] webfs from Python
  2003-02-16 14:29 Moroo Jun
@ 2003-02-16 21:20 ` Russ Cox
  2003-02-17 15:08   ` Moroo Jun
  0 siblings, 1 reply; 4+ messages in thread
From: Russ Cox @ 2003-02-16 21:20 UTC (permalink / raw)
  To: 9fans

perhaps you have to ctlfd.flush()
in order to make the write go out?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [9fans] webfs from Python
@ 2003-02-16 14:29 Moroo Jun
  2003-02-16 21:20 ` Russ Cox
  0 siblings, 1 reply; 4+ messages in thread
From: Moroo Jun @ 2003-02-16 14:29 UTC (permalink / raw)
  To: 9fans

I tried to use webfs from Python. I wrote a little test script and try
to get web page, but fail.
Any suggestions?

cpu% cat web.py
import os

web = open("/mnt/web/clone","rw")
t=web.readlines()
id=int(t[0])
base=os.path.join("/mnt/web/%d" % id)
ctlfd=open(os.path.join(base,"ctl"),"rw")
ctlfd.write("url http://www.example.com/index.html")
bodyfd=open(os.path.join(base,"body"),"r")
t=bodyfd.read(),
print t
web.close()
cpu% python web.py
Traceback (most recent call last):
   File w.py:9, in ?
     bodyfd=open(os.path.join(base,"body"),"r")
IOError: [Errno 0] url is not yet set: '/mnt/web/0/body'




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-02-17 15:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-16 21:24 [9fans] webfs from Python Moroo Jun
  -- strict thread matches above, loose matches on Subject: below --
2003-02-16 14:29 Moroo Jun
2003-02-16 21:20 ` Russ Cox
2003-02-17 15:08   ` Moroo Jun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).