Exemple #1
0
    def read(self, srv, req):
        if req.fid.qid.path not in self.files:
            raise py9p.ServerError("unknown file")

        f = self.files[req.fid.qid.path]
        if f.qid.type & py9p.QTDIR:
            req.ofcall.stat = []
            for x in f.children:
                req.ofcall.stat.append(x)
        elif f.name == 'sample1':
            if req.ifcall.offset == 0:
                buf = 'test\n'
                req.ofcall.data = buf[:req.ifcall.count]
            else:
                req.ofcall.data = ''
        elif f.name == 'sample2':
            buf = 'The time is now %s. thank you for asking.\n' % time.asctime(
                time.localtime(time.time()))
            if req.ifcall.offset > len(buf):
                req.ofcall.data = ''
            else:
                req.ofcall.data = buf[req.ifcall.offset:req.ifcall.offset +
                                      req.ifcall.count]

        srv.respond(req, None)
Exemple #2
0
 def open(self, srv, req):
     '''If we have a file tree then simply check whether the Qid matches
     anything inside. respond qid and iounit are set by protocol'''
     if req.fid.qid.path not in self.files:
         srv.respond(req, "unknown file")
     f = self.files[req.fid.qid.path]
     if (req.ifcall.mode & f.mode) != py9p.OREAD:
         raise py9p.ServerError("permission denied")
     srv.respond(req, None)
Exemple #3
0
    def read(self, srv, req):
        if not self.files.has_key(req.fid.qid.path):
            raise py9p.ServerError("unknown file")

        f = self.files[req.fid.qid.path]
        if f.qid.type & py9p.QTDIR:
            req.ofcall.stat = []
            for x in f.children:
                req.ofcall.stat.append(x)
        else:
            req.ofcall.data = ''

        srv.respond(req, None)
Exemple #4
0
    def read(self, srv, req):
        if req.fid.qid.path not in self.files:
            raise py9p.ServerError("unknown file")

        f = self.files[req.fid.qid.path]
        if f.qid.type & py9p.QTDIR:
            req.ofcall.stat = []
            for x in f.children:
                req.ofcall.stat.append(x)
        elif f.name == 'hello':
            if req.ifcall.offset == 0:
                buf = 'Hello World\n'
                req.ofcall.data = buf[:req.ifcall.count]
            else:
                req.ofcall.data = ''
        elif f.name == 'goodbye':
            if req.ifcall.offset == 0:
                buf = 'Goodbye and Goodnight\n'
                req.ofcall.data = buf[:req.ifcall.count]
            else:
                req.ofcall.data = ''

        srv.respond(req, None)
Exemple #5
0
 def stat(self, srv, req):
     if req.fid.qid.path not in self.files:
         raise py9p.ServerError("unknown file")
     req.ofcall.stat.append(self.files[req.fid.qid.path])
     srv.respond(req, None)