pynfs: python3 support plan: print -> print()
Subsystems (3)
PATCH 1/24 pynfs: python3 support plan: print -> print()
From: "Jianhong.Yin" <[email protected]>
'/print / {:lop /[^\\]$/! {N; b lop}; s/print /print(/; s/$/)/; }'
--- nfs4.0/lib/rpc/rpc.py | 56 +++---- nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py | 8 +- nfs4.0/nfs4acl.py | 2 +- nfs4.0/nfs4client.py | 14 +- nfs4.0/nfs4lib.py | 18 +-- nfs4.0/nfs4server.py | 168 ++++++++++----------- nfs4.0/nfs4state.py | 32 ++-- nfs4.0/servertests/environment.py | 14 +- nfs4.0/servertests/st_delegation.py | 6 +- nfs4.0/servertests/st_fslocations.py | 22 +-- nfs4.0/servertests/st_getattr.py | 10 +- nfs4.0/servertests/st_reboot.py | 2 +- nfs4.0/testserver.py | 30 ++-- nfs4.1/block.py | 8 +- nfs4.1/client41tests/ct_reboot.py | 10 +- nfs4.1/client41tests/environment.py | 4 +- nfs4.1/config.py | 10 +- nfs4.1/errorparser.py | 2 +- nfs4.1/locking.py | 6 +- nfs4.1/nfs4lib.py | 6 +- nfs4.1/nfs4proxy.py | 2 +- nfs4.1/nfs4server.py | 14 +- nfs4.1/server41tests/environment.py | 8 +- nfs4.1/server41tests/st_block.py | 24 +-- nfs4.1/server41tests/st_create_session.py | 6 +- nfs4.1/server41tests/st_debug.py | 10 +- nfs4.1/server41tests/st_destroy_session.py | 2 +- nfs4.1/server41tests/st_exchange_id.py | 4 +- nfs4.1/server41tests/st_getdevicelist.py | 14 +- nfs4.1/server41tests/st_secinfo_no_name.py | 2 +- nfs4.1/setup.py | 6 +- nfs4.1/testclient.py | 30 ++-- nfs4.1/testmod.py | 29 ++-- nfs4.1/testserver.py | 30 ++-- rpc/rpc.py | 4 +- setup.py | 4 +- showresults.py | 3 +- xdr/xdrgen.py | 34 ++--- 38 files changed, 329 insertions(+), 325 deletions(-)
nfs4.0/lib/rpc/rpc.py +28 -28
@@ -1,6 +1,6 @@ # rpc.py - based on RFC 1831 # -# Requires python 2.3 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for
@@ -230,7 +230,7 @@ class RPCClient(object): if why[0] == errno.EADDRINUSE: port += 1 else: - print "Could not use low port" + print("Could not use low port") return def getsocket(self):
@@ -326,13 +326,13 @@ class RPCClient(object): header, cred = self.get_call_header(xid, program, version, procedure) data = self.security.secure_data(data, cred) try: - if self.debug: print "send %i" % xid + if self.debug: print("send %i" % xid) self.socket.send_record(header + data) except socket.timeout: raise except socket.error, e: - print "Got error:", e - if self.debug: print "resend", xid + print("Got error:", e) + if self.debug: print("resend", xid) try: self.reconnect().send_record(header + data) except socket.error:
@@ -346,7 +346,7 @@ class RPCClient(object): # If xid not on list, return error. # Listen until get reply with given xid. Cache others received # on list. Return error if get one not on list. - if self.debug: print "listen", xid + if self.debug: print("listen", xid) list = self.get_outstanding_xids() if xid not in list: raise
@@ -361,8 +361,8 @@ class RPCClient(object): except socket.timeout: raise except socket.error, e: - print "Got error:", e - if self.debug: print "relisten", xid + print("Got error:", e) + if self.debug: print("relisten", xid) try: s = self.reconnect() s.send_record(list[xid].header + list[xid].data)
@@ -472,21 +472,21 @@ class Server(object): def run(self, debug=0): while 1: - if debug: print "%s: Calling poll" % self.name + if debug: print("%s: Calling poll" % self.name) res = self.p.poll() - if debug: print "%s: %s" % (self.name, res) + if debug: print("%s: %s" % (self.name, res)) for fd, event in res: if debug: - print "%s: Handling fd=%i, event=%x" % \ - (self.name, fd, event) + print("%s: Handling fd=%i, event=%x" % \ + (self.name, fd, event)) if event & select.POLLHUP: self.event_hup(fd) elif event & select.POLLNVAL: - if debug: print "%s: POLLNVAL for fd=%i" % (self.name, fd) + if debug: print("%s: POLLNVAL for fd=%i" % (self.name, fd)) self.p.unregister(fd) elif event & ~(select.POLLIN | select.POLLOUT): - print "%s: ERROR: event %i for fd %i" % \ - (self.name, event, fd) + print("%s: ERROR: event %i for fd %i" % \ + (self.name, event, fd)) self.event_error(fd) else: if event & select.POLLOUT:
@@ -534,9 +534,9 @@ class RPCServer(Server): csock, caddr = self.s.accept() csock.setblocking(0) if debug: - print "SERVER: got connection from %s, " \ + print("SERVER: got connection from %s, " \ "assigned to fd=%i" % \ - (csock.getpeername(), csock.fileno()) + (csock.getpeername(), csock.fileno())) self.p.register(csock, _readmask) cfd = csock.fileno() self.readbufs[cfd] = ''
@@ -550,7 +550,7 @@ class RPCServer(Server): Also responds to command codes sent as encoded integers """ - if debug: print "SERVER: In read event for %i" % fd + if debug: print("SERVER: In read event for %i" % fd) self.readbufs[fd] += data loop = True while loop:
@@ -566,7 +566,7 @@ class RPCServer(Server): if self.readbufs[fd]: loop = True # We've received data past last if last: - if debug: print "SERVER: Received record from %i" % fd + if debug: print("SERVER: Received record from %i" % fd) recv_data = ''.join(self.packetbufs[fd]) self.packetbufs[fd] = [] if len(recv_data) == 4:
@@ -579,14 +579,14 @@ class RPCServer(Server): self.p.register(fd, _bothmask) def event_write(self, fd, chunksize=2048, debug=0): - if debug: print "SERVER: In write event for %i" % fd + if debug: print("SERVER: In write event for %i" % fd) if self.writebufs[fd]: - if debug: print " writing from writebuf" + if debug: print(" writing from writebuf") count = self.sockets[fd].send(self.writebufs[fd]) self.writebufs[fd] = self.writebufs[fd][count:] # check if done? elif self.recordbufs[fd]: - if debug: print " writing from recordbuf" + if debug: print(" writing from recordbuf") data = self.recordbufs[fd][0] chunk = data[:chunksize] if len(data) > chunksize:
@@ -601,12 +601,12 @@ class RPCServer(Server): count = self.sockets[fd].send(self.writebufs[fd]) self.writebufs[fd] = self.writebufs[fd][count:] else: - if debug: print " done writing" + if debug: print(" done writing") self.p.register(fd, _readmask) def event_command(self, cfd, comm, debug=0): if debug: - print "SERVER: command = %i, cfd = %i" % (comm, cfd) + print("SERVER: command = %i, cfd = %i" % (comm, cfd)) if comm == 0: # Turn off server self.compute_reply = lambda x: None return '\0'*4
@@ -616,7 +616,7 @@ class RPCServer(Server): def event_close(self, fd, debug=0): if debug: - print "SERVER: closing %i" % fd + print("SERVER: closing %i" % fd) self.event_error(fd) def event_error(self, fd):
@@ -636,16 +636,16 @@ class RPCServer(Server): try: recv_msg = self.rpcunpacker.unpack_rpc_msg() except xdrlib.Error, e: - print "XDRError", e + print("XDRError", e) return if recv_msg.body.mtype != CALL: - print "Received a REPLY, expected a CALL" + print("Received a REPLY, expected a CALL") return # Check for reasons to deny the call call = recv_msg.body.cbody cred = call.cred flavor = cred.flavor - #print call + #print(call) reply_stat = MSG_ACCEPTED areply = rreply = None proc_response = ''
nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py +4 -4
@@ -204,7 +204,7 @@ class SecAuthGss(SecFlavor): p.done() d = gssapi.acceptSecContext(token, body.handle) if d["major"] == GSS_S_COMPLETE: - print "SUCCESS!" + print("SUCCESS!") class C(object): pass out = C()
@@ -223,11 +223,11 @@ class SecAuthGss(SecFlavor): else: out = hint_string(d) if out is not None: - print out + print(out) return rpc.GARBAGE_ARGS, '' else: # Stub - print "Unable to handle gss_proc==%i" % body.gss_proc + print("Unable to handle gss_proc==%i" % body.gss_proc) return rpc.GARBAGE_ARGS, '' def make_verf(self, data): """Verifier sent with each RPC call
@@ -374,7 +374,7 @@ class SecAuthGss(SecFlavor): p.reset() p.pack_uint(cred.seq_num) d = gssapi.verifyMIC(self.gss_context, p.get_buffer(), rverf.body) - #print "Verify(%i):"%cred.seq_num, show_major(d['major']), show_minor(d['minor']) + #print("Verify(%i):"%cred.seq_num, show_major(d['major']), show_minor(d['minor'])) else: pass
nfs4.0/nfs4acl.py +1 -1
@@ -214,6 +214,6 @@ def printableacl(acl): for ace in acl: out += "<type=%6s, flag=%2x, access=%8x, who=%s>\n" % \ (type_str[ace.type], ace.flag, ace.access_mask, ace.who) - #print "leaving printableacl with out = %s" % out + #print("leaving printableacl with out = %s" % out) return out
nfs4.0/nfs4client.py +7 -7
@@ -9,8 +9,8 @@ # import sys -if sys.hexversion < 0x02030000: - print "Requires python 2.3 or higher" +if sys.hexversion < 0x02070000: + print("Requires python 2.7 or higher") sys.exit(1) import os # Allow to be run stright from package root
@@ -22,7 +22,7 @@ import readline try: import readline except ImportError: - print "Module readline not available." + print("Module readline not available.") #else: # import rlcompleter # readline.parse_and_bind("tab: complete")
@@ -75,11 +75,11 @@ class PyShell(code.InteractiveConsole): return self.locals[attr] else: return getattr(inst, attr) - #print "\nCalled complete(%s, %i)" % (text, state) + #print("\nCalled complete(%s, %i)" % (text, state)) if text.startswith('.'): # XXX TODO - handle array indexing line = readline.get_line_buffer() - # print "Line: ", repr(line) + # print("Line: ", repr(line)) return None vars = text.split('.') base = vars[:-1]
@@ -88,7 +88,7 @@ class PyShell(code.InteractiveConsole): try: inst = eval('.'.join(base), self.locals) except: - print "\nFAIL" + print("\nFAIL") traceback.print_exc() return None else:
@@ -125,7 +125,7 @@ class PyShell(code.InteractiveConsole): def main(server): c = PyShell(server) c.interact("Try COMPOUND([PUTROOTFH()])") - print "Goodbye!" + print("Goodbye!") if __name__ == "__main__": main(sys.argv[1])
nfs4.0/nfs4lib.py +9 -9
@@ -1,7 +1,7 @@ #!/usr/bin/env python # nfs4lib.py - NFS4 library for Python # -# Requires python 2.3 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for
@@ -199,7 +199,7 @@ class CBServer(rpc.RPCServer): rpc.RPCServer.run(self) def handle_0(self, data, cred): - #print "*****CB received NULL******" + #print("*****CB received NULL******") if data != '': return rpc.GARBAGE_ARGS, '' else:
@@ -207,7 +207,7 @@ class CBServer(rpc.RPCServer): def handle_1(self, data, cred): """Deal with CB_COMPOUND""" - print "*****CB received COMPOUND******" + print("*****CB received COMPOUND******") self.nfs4unpacker.reset(data) ok, results, tag = self.O_CB_Compound() try:
@@ -245,7 +245,7 @@ class CBServer(rpc.RPCServer): # FIXME def O_CB_GetAttr(self, op, cbid): - print "******* CB_Getattr *******" + print("******* CB_Getattr *******") self.opcounts[OP_CB_GETATTR] += 1 if not self.curr_fh: return self.simple_status(NFS4ERR_NOFILEHANDLE)
@@ -254,7 +254,7 @@ class CBServer(rpc.RPCServer): # FIXME def O_CB_Recall(self, op, cbid): - print "******* CB_Recall (id=%i)********" % cbid + print("******* CB_Recall (id=%i)********" % cbid) self.opcounts[OP_CB_RECALL] += 1 if self.recall_funct.get(cbid, None) is not None: res = self.recall_funct[cbid](self.client, op, cbid)
@@ -301,7 +301,7 @@ class NFS4Client(rpc.RPCClient): self.cb_control.connect(('127.0.0.1', self.cb_server.port)) break except socket.error: - print "Waiting for Callback server to start" + print("Waiting for Callback server to start") def cb_command(self, comm): self.cb_control.sendall('\x80\x00\x00\x04\x00\x00\x00%s' % chr(comm))
@@ -327,7 +327,7 @@ class NFS4Client(rpc.RPCClient): minorversion=minorversion) if SHOW_TRAFFIC: print - print compoundargs + print(compoundargs) p = self.nfs4packer un_p = self.nfs4unpacker p.reset()
@@ -336,7 +336,7 @@ class NFS4Client(rpc.RPCClient): un_p.reset(res) res = un_p.unpack_COMPOUND4res() if SHOW_TRAFFIC: - print res + print(res) un_p.done() # Do some error checking
@@ -688,7 +688,7 @@ class NFS4Client(rpc.RPCClient): #expect = attrs.keys() #expect.sort() #if attrlist != expect: - # print "WARNING: OPENresok.attrset mismatches requested attrs" + # print("WARNING: OPENresok.attrset mismatches requested attrs") fhandle = res.resarray[-1].switch.switch.object stateid = res.resarray[-2].switch.switch.stateid rflags = res.resarray[-2].switch.switch.rflags
nfs4.0/nfs4server.py +84 -84
493 lines not on this page · raw message
nfs4.0/nfs4state.py +16 -16
@@ -244,14 +244,14 @@ class NFSServerState: See RFC 3530 sec 8.1.5 """ # This is getting too complicated. Should split off creation - #print " check_seqid: Entered" + #print(" check_seqid: Entered") if isinstance(obj, stateid4): mustexist = True try: info = self.__getinfo(obj, allownew=not mustexist) except ValueError, e: if mustexist: raise - #print " check_seqid: %s" % info + #print(" check_seqid: %s" % info) if info is None: # A reserved stateid raise NFS4Error(NFS4ERR_BAD_STATEID)
@@ -267,9 +267,9 @@ class NFSServerState: info.lastseqid = mod32(-1) return lastseq = info.lastseqid - #print " check_seqid: new: %s, last: %s" % (seqid, lastseq) + #print(" check_seqid: new: %s, last: %s" % (seqid, lastseq)) if lastseq == seqid: - print " ***REPLAY*** " + print(" ***REPLAY*** ") return info.cached_response if not info.confirmed and not open_confirm: # RFC 3530 sec 14.2.18
@@ -294,7 +294,7 @@ class NFSServerState: # FIXME - does this behave correctly for reserved stateids? return info.cached_response = (cfh, args, op) - #print " advance_seqid - went from: %s" % info.lastseqid + #print(" advance_seqid - went from: %s" % info.lastseqid) if args[0] not in [NFS4ERR_STALE_CLIENTID, NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID, NFS4ERR_BAD_SEQID, NFS4ERR_BADXDR, NFS4ERR_RESOURCE,
@@ -303,7 +303,7 @@ class NFSServerState: info.lastseqid = 0 else: info.lastseqid = mod32(info.lastseqid + 1) - #print " advance_seqid - to: %s" % info.lastseqid + #print(" advance_seqid - to: %s" % info.lastseqid) def confirm(self, fh, stateid): """Confirm an open"""
@@ -352,7 +352,7 @@ class NFSServerState: raise NFS4Error(NFS4ERR_BAD_STATEID) info = self.state[id].owner fh = self.__getfh(id) - #print "Close fh from id", fh.handle + #print("Close fh from id", fh.handle) # Remove locks from file and deal with associated lockowners for lockinfo in info.lockowners: if fh.handle in lockinfo.files:
@@ -412,7 +412,7 @@ class NFSServerState: except KeyError: if not allownew: raise ValueError, "File %s not open for %s" % (fh.name, info) - #print "Creating new id %i for fh %s" % (self.next_id, fh.handle) + #print("Creating new id %i for fh %s" % (self.next_id, fh.handle)) id = info.files[fh.handle] = self.next_id self.next_id += 1 self.state[id] = self.StateIDInfo(fh, info)
@@ -434,7 +434,7 @@ class NFSServerState: info = ownerdict[owner.clientid][owner.owner] except KeyError: if not allownew: raise ValueError, "Unknown owner %s" % str(owner) - #print "Creating new info" + #print("Creating new info") info = self.OwnerInfo(owner) if owner.clientid in ownerdict: ownerdict[owner.clientid][owner.owner] = info
@@ -853,14 +853,14 @@ class NFSFileState: list[i].type == list[i-1].type: list[i-1].end = list[i].end del list[i] - print list + print(list) def removeposixlock(self, list, type, start, end): """Removes lock from sorted list, splitting existing locks as necessary """ self.__removerange(list, start, end) list.sort() - print list + print(list) def __removerange(self, list, start, end): """Removes locks in given range, shrinking locks that half-overlap"""
@@ -1171,9 +1171,9 @@ class VirtualHandle(NFSFileHandle): try: nfs4acl.maps_to_posix(acl) except nfs4acl.ACLError, e: - print "*"*50 - print e - print "*"*50 + print("*"*50) + print(e) + print("*"*50) raise NFS4Error(NFS4ERR_INVAL) self.fattr4_acl = acl self.fattr4_mode = nfs4acl.acl2mode(acl)
@@ -1257,7 +1257,7 @@ class VirtualHandle(NFSFileHandle): # FRED - Note this currently does nothing - # - and should do nothing if link count is positive if self.fattr4_numlinks > 0: return - #print "destructing: %s" % repr(self) + #print("destructing: %s" % repr(self)) if self.fattr4_type == NF4DIR: for subfile in self.dirent.values(): subfile.destruct()
@@ -1324,7 +1324,7 @@ class VirtualHandle(NFSFileHandle): self.fattr4_change += 1 try: self.file.seek(offset) except MemoryError: - print "MemError, offset=%s, count=%s" % (str(offset), str(len(data))) + print("MemError, offset=%s, count=%s" % (str(offset), str(len(data)))) raise self.file.write(data) self.file.seek(0, 2) # Seek to eof
nfs4.0/servertests/environment.py +7 -7
@@ -1,7 +1,7 @@ # # environment.py # -# Requires python 2.3 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for
@@ -183,7 +183,7 @@ class Environment(testmod.Environment): path = tree + [name[type]] res = c.create_obj(path, type) if res.status != NFS4_OK: - print "WARNING - could not create /%s" % '/'.join(path) + print("WARNING - could not create /%s" % '/'.join(path)) c.init_connection() fh, stateid = c.create_confirm('maketree', tree + ['file'], deny=OPEN4_SHARE_DENY_NONE)
@@ -209,18 +209,18 @@ class Environment(testmod.Environment): def sleep(self, sec, msg=''): """Sleep for given seconds""" - print "Sleeping for %g seconds:" % sec, msg + print("Sleeping for %g seconds:" % sec, msg) time.sleep(sec) - print "Woke up" + print("Woke up") def serverhelper(self, args): """Perform a special operation on the server side (such as rebooting the server)""" if self.opts.serverhelper is None: - print "Manual operation required on server:" - print args + " and hit ENTER when done" + print("Manual operation required on server:") + print(args + " and hit ENTER when done") sys.stdin.readline() - print "Continuing with test" + print("Continuing with test") else: cmd = self.opts.serverhelper if self.opts.serverhelperarg:
nfs4.0/servertests/st_delegation.py +3 -3
@@ -22,7 +22,7 @@ class _handle_error(object): try: self.c.compound(ops) except Exception, e: - print "CALLBACK error in _recall:", e + print("CALLBACK error in _recall:", e) pass _lock.release()
@@ -34,7 +34,7 @@ def _recall(c, thisop, cbid): try: res = c.compound(ops) except Exception, e: - print "CALLBACK error in _recall:", e + print("CALLBACK error in _recall:", e) res = None _lock.release() if res is not None and res.status != NFS4_OK:
@@ -260,7 +260,7 @@ def testManyReaddeleg(t, env, funct=_recall, response=NFS4_OK): cbids.append(c.cbid) if not cbids: t.pass_warn("Could not get any read delegations") - print "Got %i out of %i read delegations" % (len(cbids), count) + print("Got %i out of %i read delegations" % (len(cbids), count)) # Cause them to be recalled fh2, stateid2 = _cause_recall(t, env) miss_count = 0
nfs4.0/servertests/st_fslocations.py +11 -11
@@ -20,7 +20,7 @@ def testReference(t, env): res = c.compound(ops) check(res, NFS4ERR_MOVED, "GETFH of path indicated by --usespecial") locs = c.do_getattr(FATTR4_FS_LOCATIONS, path) - print "After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs + print("After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs) def testReference2(t, env): """FSLOCATION test of referral node
@@ -33,7 +33,7 @@ def testReference2(t, env): c = env.c1 path = env.opts.usespecial locs = c.do_getattr(FATTR4_FS_LOCATIONS, path) - print "After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs + print("After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs) def testReference3(t, env): """FSLOCATION test of referral node
@@ -46,7 +46,7 @@ def testReference3(t, env): c = env.c1 path = env.opts.usespecial locs = c.do_getattr(FATTR4_FS_LOCATIONS, c.homedir) - print "After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs + print("After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs) def testAttr1a(t, env): """GETATTR with attributes should return _MOVED
@@ -104,10 +104,10 @@ def testAttr2b(t, env): attrlist = [FATTR4_SIZE, FATTR4_FILEHANDLE, FATTR4_RDATTR_ERROR, FATTR4_FSID] entries = c.do_readdir(path, attr_request=attrlist) moved = [e for e in entries if e.attrdict[FATTR4_RDATTR_ERROR] == NFS4ERR_MOVED] - print "RDATTR==MOVED for:", [e.name for e in moved] + print("RDATTR==MOVED for:", [e.name for e in moved]) for e in moved: if len(e.attrdict) != 2: - print e.attrdict + print(e.attrdict) t.fail("Expected 2 attrs returned for file %s, got %i" % (e.name, len(e.attrdict))) def testAttr3a(t, env):
@@ -137,7 +137,7 @@ def testAttr3b(t, env): entries = c.do_readdir(path, attr_request=attrlist) moved = [e for e in entries if e.name == env.opts.usespecial[-1]][0] if len(moved.attrdict) != 3: - print moved.attrdict + print(moved.attrdict) t.fail("Expected 3 attrs returned for file %s, got %i" % (moved.name, len(moved.attrdict))) def testAttr4a(t, env):
@@ -150,7 +150,7 @@ def testAttr4a(t, env): path = env.opts.usespecial attrlist = [FATTR4_SIZE, FATTR4_FILEHANDLE, FATTR4_RDATTR_ERROR, FATTR4_FSID, FATTR4_FS_LOCATIONS] d = c.do_getattrdict(path, attrlist) - print d + print(d) if len(d) != 3: t.fail("Expected 3 attrs returned, got %i" % len(d))
@@ -167,10 +167,10 @@ def testAttr4b(t, env): attrlist = [FATTR4_SIZE, FATTR4_FILEHANDLE, FATTR4_RDATTR_ERROR, FATTR4_FSID, FATTR4_FS_LOCATIONS] entries = c.do_readdir(path, attr_request=attrlist) moved = [e for e in entries if e.attrdict[FATTR4_RDATTR_ERROR] == NFS4ERR_MOVED] - print "RDATTR==MOVED for:", [e.name for e in moved] + print("RDATTR==MOVED for:", [e.name for e in moved]) for e in moved: if len(e.attrdict) != 3: - print e.attrdict + print(e.attrdict) t.fail("Expected 3 attrs returned for file %s, got %i" % (e.name, len(e.attrdict))) def testAttr5a(t, env):
@@ -183,7 +183,7 @@ def testAttr5a(t, env): path = env.opts.usespecial attrlist = [FATTR4_SIZE, FATTR4_FILEHANDLE, FATTR4_FSID, FATTR4_FS_LOCATIONS] d = c.do_getattrdict(path, attrlist) - print d + print(d) if len(d) != 2: t.fail("Expected 3 attrs returned, got %i" % len(d))
@@ -201,6 +201,6 @@ def testAttr5b(t, env): entries = c.do_readdir(path, attr_request=attrlist) moved = [e for e in entries if e.name == env.opts.usespecial[-1]][0] if len(moved.attrdict) != 2: - print moved.attrdict + print(moved.attrdict) t.fail("Expected 2 attrs returned for file %s, got %i" % (moved.name, len(moved.attrdict)))
nfs4.0/servertests/st_getattr.py +5 -5
@@ -486,7 +486,7 @@ def testFSLocations(t, env): check(res, [NFS4_OK, NFS4ERR_ATTRNOTSUPP], "GETATTR(fs_locations)") if res.status == NFS4ERR_ATTRNOTSUPP: t.fail_support("fs_locations not a supported attribute") - # print res.resarray[-1].obj_attributes + # print(res.resarray[-1].obj_attributes) def testLotsofGetattrsFile(t, env): """Send lots of getattrs
@@ -517,7 +517,7 @@ def testOwnerName(t, env): check(res, [NFS4_OK, NFS4ERR_ATTRNOTSUPP], "GETATTR(owner)") if res.status == NFS4ERR_ATTRNOTSUPP: t.fail_support("owner not a supported attribute") - # print res.resarray[-1].obj_attributes + # print(res.resarray[-1].obj_attributes) ####################################################
@@ -541,9 +541,9 @@ def testOwnerName(t, env): res = self.ncl.do_ops(ops) self.assert_OK(res) print - print "From Getattr / - ", res.resarray[-3].obj_attributes + print("From Getattr / - ", res.resarray[-3].obj_attributes) print - print "From Getattr /unix - ", res.resarray[-1].obj_attributes + print("From Getattr /unix - ", res.resarray[-1].obj_attributes) ops = [op.putrootfh()] attrmask = nfs4lib.list2bitmap(request)
@@ -561,6 +561,6 @@ def testOwnerName(t, env): if not entry.nextentry: self.fail("Could not find mountpoint /unix") entry = entry.nextentry[0] - print "From Readdir / - ", entry.attrs + print("From Readdir / - ", entry.attrs)
nfs4.0/servertests/st_reboot.py +1 -1
@@ -217,7 +217,7 @@ def testRootSquash(t, env): oldname = oldowner.split('@')[0] if oldname == 'root': t.fail_support("No root squashing detected") - print "Detected root squashing: root -> %s" % oldname + print("Detected root squashing: root -> %s" % oldname) # Wait for grace period to have *just* expired _waitForReboot(c, env)
nfs4.0/testserver.py +15 -15
@@ -27,7 +27,7 @@ import sys if sys.hexversion < 0x02050000: - print "Requires python 2.5 or higher" + print("Requires python 2.5 or higher") sys.exit(1) import os # Allow to be run stright from package root
@@ -217,16 +217,16 @@ def printflags(list): command_names = [s.lower()[3:].replace('_', '') \ for s in nfs_opnum4.values()] list.sort() - # First print command names + # First print(command names) print for s in list: if s in command_names: - print s + print(s) # Then everything else print for s in list: if s not in command_names: - print s + print(s) def main(): nfail = -1
@@ -251,14 +251,14 @@ def main(): codes = cdict.keys() codes.sort() for c in codes: - print c + print(c) sys.exit(0) if opt.showcodesflags: codes = cdict.keys() codes.sort() for c in codes: - print c, "FLAGS:", ', '.join(cdict[c].flags_list) + print(c, "FLAGS:", ', '.join(cdict[c].flags_list)) sys.exit(0) # Grab server info and set defaults
@@ -285,14 +285,14 @@ def main(): for attr in dir(opt): if attr.startswith('use') and attr != "usefh": path = getattr(opt, attr) - #print attr, path + #print(attr, path) if path is None: path = opt.path + ['tree', attr[3:]] else: # FIXME - have funct that checks path validity if path[0] != '/': p.error("Need to use absolute path for --%s" % attr) - # print path + # print(path) if path[-1] == '/' and attr != 'usedir': p.error("Can't use dir for --%s" %attr) try:
@@ -337,21 +337,21 @@ def main(): # Place tests in desired order tests.sort() # FIXME - add options for random sort - # Run the tests and save/print results + # Run the tests and save/print(results) try: env = environment.Environment(opt) env.init() except socket.gaierror, e: if e.args[0] == -2: - print "Unknown server '%s'" % opt.server - print sys.exc_info()[1] + print("Unknown server '%s'" % opt.server) + print(sys.exc_info()[1]) sys.exit(1) except Exception, e: - print "Initialization failed, no tests run." + print("Initialization failed, no tests run.") if not opt.maketree: - print "Perhaps you need to use the --maketree option" + print("Perhaps you need to use the --maketree option") raise - print sys.exc_info()[1] + print(sys.exc_info()[1]) sys.exit(1) if opt.outfile is not None: fd = file(opt.outfile, 'w')
@@ -371,7 +371,7 @@ def main(): fail = True nfail = testmod.printresults(tests, opt) if fail: - print "\nWARNING: could not clean testdir due to:\n%s\n" % str(e) + print("\nWARNING: could not clean testdir due to:\n%s\n" % str(e)) if opt.xmlout is not None: testmod.xml_printresults(tests, opt.xmlout)
nfs4.1/block.py +4 -4
@@ -159,7 +159,7 @@ class Simple(Volume): return pnfs_block_volume4(PNFS_BLOCK_VOLUME_SIMPLE, bv_simple_info=info) def resolve(self, i): - # print "resolve(%i) %r" % (i, self) + # print("resolve(%i) %r" % (i, self)) if i < 0 or i >= self._size: raise ValueError("Asked for %i of %i" % (i, self._size)) return (self, i)
@@ -186,8 +186,8 @@ class Slice(Volume): return pnfs_block_volume4(PNFS_BLOCK_VOLUME_SLICE, bv_slice_info=info) def resolve(self, i): - # print "resolve(%i) %r" % (i, self) - # print self.start, self._size, self.length + # print("resolve(%i) %r" % (i, self)) + # print(self.start, self._size, self.length) if i < 0 or i >= self._size: raise ValueError("Asked for %i of %i" % (i, self._size)) return self.volumes[0].resolve(self.start + i)
@@ -212,7 +212,7 @@ class Concat(Volume): return "Concat %i of %r" % (self.id, [v.id for v in self.volumes]) def resolve(self, i): - # print "resolve(%i) %r" % (i, self) + # print("resolve(%i) %r" % (i, self)) if i < 0 or i >= self._size: raise ValueError("Asked for %i of %i" % (i, self._size)) sum = 0
nfs4.1/client41tests/ct_reboot.py +5 -5
@@ -204,12 +204,12 @@ def testTwoValueSetupOrCleanup(t, env): echo "Messagetype value value" > $CONFIG/ops/<operation> """ - #print 'env.opts.useparams ', env.opts.useparams + #print('env.opts.useparams ', env.opts.useparams) if len(env.opts.useparams) != 4: - print 'TWO_VALUE_SETUP_OR_CLEANUP requires ' - print 'testclient.py --useparams' - print 'Example: --useparams=sequence:ERROR:NFS4ERR_SEQ_MISORDERED:50 ' - print 'which returns NFS4ERR_SEQ_MISORDERED every 50th sequence op' + print('TWO_VALUE_SETUP_OR_CLEANUP requires ') + print('testclient.py --useparams') + print('Example: --useparams=sequence:ERROR:NFS4ERR_SEQ_MISORDERED:50 ') + print('which returns NFS4ERR_SEQ_MISORDERED every 50th sequence op') fail("Bad Input to test") operation = env.opts.useparams[0]
nfs4.1/client41tests/environment.py +2 -2
@@ -1,7 +1,7 @@ # # environment.py # -# Requires python 2.3 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for
@@ -144,7 +144,7 @@ class Environment(testmod.Environment): path = os.path.join(self.root, "config", "ops", opname) fd = open(path, "w") fd.write(data) - print "wait for leasetime: ", lease[1], "seconds" + print("wait for leasetime: ", lease[1], "seconds") fd.close() time.sleep(int(lease[1]))
nfs4.1/config.py +5 -5
@@ -49,23 +49,23 @@ def _opline(value): message-type of error has this form: "ERROR NFS4ERR_code ceiling" new message types and more values can be added """ - print '**************** OPLINE typevalue ', type(value) + print('**************** OPLINE typevalue ', type(value)) if type(value) is str: l = value.strip().split() elif type(value) is list: l = value else: - print ' OPLINE type ', type(value) + print(' OPLINE type ', type(value)) raise TypeError, 'Only type list or str accepted' if l[0] == "ERROR": if not len(l) == 3: - print ' OPLINE length ', len + print(' OPLINE length ', len) raise ValueError("ERROR messages only accepts 3 entries") - print 'OPLINE len ', len(l) + print('OPLINE len ', len(l)) value = [l[0], _statcode(l[1]), int(l[2])] else: raise ValueError("Only message-type ERROR accepted") - print '**************** OPLINE return ', value + print('**************** OPLINE return ', value) return value ###################################################
nfs4.1/errorparser.py +1 -1
@@ -112,7 +112,7 @@ class ErrorParser(): except IndexError: # function functions = Errors() func = getattr(functions, random.choice(err.function)) - print func + print(func) if callable(func): func(opname, arg, env)
nfs4.1/locking.py +3 -3
@@ -32,7 +32,7 @@ def _collect_acq_data(suffix=""): def _deco(acquire): def wrapper(self): suf = ("" if not suffix else "_%s" % suffix) - print "ACQUIRE%s tried for lock %s" % (suf.upper(), self.name) + print("ACQUIRE%s tried for lock %s" % (suf.upper(), self.name)) t = threading.currentThread() try: t.locks[self.name] = "waiting%s" % suf
@@ -40,7 +40,7 @@ def _collect_acq_data(suffix=""): t.locks = {self.name: "waiting%s" % suf} acquire(self) t.locks[self.name] = "holding%s" % suf - print "ACQUIRE%s succeeded for lock %s" % (suf.upper(), self.name) + print("ACQUIRE%s succeeded for lock %s" % (suf.upper(), self.name)) return wrapper return _deco
@@ -49,7 +49,7 @@ def _collect_rel_data(suffix=""): def _deco(release): def wrapper(self, *args, **kwargs): suf = ("" if not suffix else "_%s" % suffix) - print "RELEASE%s lock %s" % (suf.upper(), self.name) + print("RELEASE%s lock %s" % (suf.upper(), self.name)) t = threading.currentThread() t.locks[self.name] = "released%s" % suf release(self, *args, **kwargs)
nfs4.1/nfs4lib.py +3 -3
@@ -208,7 +208,7 @@ class FancyNFS4Packer(NFS4Packer): """Change simple list of entry4 into strange chain structure""" out = [] for e in data.entries[::-1]: - # print "handle", e + # print("handle", e) # This reverses the direction of the list, so start with reversed out = [xdrdef.nfs4_type.entry4(e.cookie, e.name, e.attrs, out)] # Must not modify original data structure
@@ -297,10 +297,10 @@ def bitmap2list(bitmap): def printhex(str, pretty=True): """Print string as hex digits""" if pretty: - print "".join(["%02x " % ord(c) for c in str]) + print("".join(["%02x " % ord(c) for c in str])) else: # Can copy/paste this string - print "".join(["\\x%02x" % ord(c) for c in str]) + print("".join(["\\x%02x" % ord(c) for c in str])) def str_xor(a, b): """xor two string which represent binary data"""
nfs4.1/nfs4proxy.py +1 -1
@@ -69,7 +69,7 @@ class NFS4Proxy(rpc.Server): while True: try: server_address = (self.dserver, self.dport) - print server_address + print(server_address) pipe = self.connect(server_address) except: traceback.print_exc(file=sys.stdout)
nfs4.1/nfs4server.py +7 -7
@@ -521,7 +521,7 @@ class SummaryOutput: print_summary_line = True if summary_line != self._last or role != self._last_role: if self._last and self._repeat_count: - print " (repeated %u times)" % self._repeat_count + print(" (repeated %u times)" % self._repeat_count) self._last = summary_line self._repeat_count = 0 else:
@@ -530,11 +530,11 @@ class SummaryOutput: if self._last_role != role: print - print role + print(role) self._last_role = role if print_summary_line: - print summary_line + print(summary_line) ##################################################
@@ -613,7 +613,7 @@ class NFS4Server(rpc.Server): Note that order matters, since the mount hides anything beneath it. """ - print "Mounting %r on %r" % (fs.fsid, path) + print("Mounting %r on %r" % (fs.fsid, path)) # Find directory object on which to mount fs dir = self.root principal = nfs4lib.NFS4Principal("root", system=True)
@@ -1964,14 +1964,14 @@ class NFS4Server(rpc.Server): calls.append(call) if arg.dir & xdrdef.sctrl_const.DIR_REPLY: replies.append(reply) - #print calls - #print replies + #print(calls) + #print(replies) grabres = xdrdef.sctrl_type.GRABres(calls, replies) return xdrdef.sctrl_const.CTRLSTAT_OK, \ xdrdef.sctrl_type.resdata_t(arg.ctrlop, grab = grabres) def ctrl_illegal(self, arg): - #print "ILLEGAL" + #print("ILLEGAL") return xdrdef.sctrl_const.CTRLSTAT_ILLEGAL, xdrdef.sctrl_type.resdata_t(arg.ctrlop) def op_setclientid(self, arg, env):
nfs4.1/server41tests/environment.py +4 -4
@@ -1,7 +1,7 @@ # # environment.py # -# Requires python 2.3 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for
@@ -225,10 +225,10 @@ class Environment(testmod.Environment): """Perform a special operation on the server side (such as rebooting the server)""" if self.opts.serverhelper is None: - print "Manual operation required on server:" - print args + " and hit ENTER when done" + print("Manual operation required on server:") + print(args + " and hit ENTER when done") sys.stdin.readline() - print "Continuing with test" + print("Continuing with test") else: cmd = self.opts.serverhelper if self.opts.serverhelperarg:
nfs4.1/server41tests/st_block.py +12 -12
@@ -22,14 +22,14 @@ def testStateid1(t, env): # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid - print open_stateid + print(open_stateid) ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0, 8192, 8192, open_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid - print lo_stateid + print(lo_stateid) if lo_stateid.seqid != 1: # From draft23 12.5.2 "The first successful LAYOUTGET processed by # the server using a non-layout stateid as an argument MUST have the
@@ -43,7 +43,7 @@ def testStateid1(t, env): res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid - print lo_stateid + print(lo_stateid) if lo_stateid.seqid != i + 2: # From draft23 12.5.3 "After the layout stateid is established, # the server increments by one the value of the "seqid" in each
@@ -63,7 +63,7 @@ def testStateid2(t, env): # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid - print open_stateid + print(open_stateid) ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0, 8192, 8192, open_stateid, 0xffff)]
@@ -71,7 +71,7 @@ def testStateid2(t, env): check(res) # Get layout 2 lo_stateid1 = res.resarray[-1].logr_stateid - print lo_stateid1 + print(lo_stateid1) ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 8192, 8192, 8192, lo_stateid1, 0xffff)]
@@ -79,14 +79,14 @@ def testStateid2(t, env): check(res) # Get layout 3 (merge of prior two) lo_stateid2 = res.resarray[-1].logr_stateid - print lo_stateid2 + print(lo_stateid2) ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0, 2*8192, 2*8192, lo_stateid2, 0xffff)] res = sess.compound(ops) check(res) lo_stateid3 = res.resarray[-1].logr_stateid - print lo_stateid3 + print(lo_stateid3) # lo_stateid3.seqid = 3 # BUG - work around emc problem # Parse opaque to get info for commit # STUB not very general
@@ -122,7 +122,7 @@ def testEmptyCommit(t, env): # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid - print open_stateid + print(open_stateid) ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0, 8192, 8192, open_stateid, 0xffff)]
@@ -130,14 +130,14 @@ def testEmptyCommit(t, env): check(res) # Get layout 2 lo_stateid1 = res.resarray[-1].logr_stateid - print lo_stateid1 + print(lo_stateid1) ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 8192, 8192, 8192, lo_stateid1, 0xffff)] res = sess.compound(ops) check(res) lo_stateid2 = res.resarray[-1].logr_stateid - print lo_stateid2 + print(lo_stateid2) # Parse opaque to get info for commit # STUB not very general layout = res.resarray[-1].logr_layout[-1]
@@ -183,7 +183,7 @@ def testSplitCommit(t, env): # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid - print open_stateid + print(open_stateid) ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0, 2*8192, 2*8192, open_stateid, 0xffff)]
@@ -191,7 +191,7 @@ def testSplitCommit(t, env): check(res) lo_stateid1 = res.resarray[-1].logr_stateid - print lo_stateid1 + print(lo_stateid1) # Parse opaque to get info for commit # STUB not very general layout = res.resarray[-1].logr_layout[-1]
nfs4.1/server41tests/st_create_session.py +3 -3
@@ -310,7 +310,7 @@ def testRdmaArray2(t, env): xid = c.compound_async(ops, checks=False) try: res = c.listen(xid) - print res + print(res) except RPCAcceptError, e: if e.stat == GARBAGE_ARGS: # Legitimate return
@@ -339,7 +339,7 @@ def testCallbackProgram(t, env): cb_occurred = threading.Event() transient = 0x40000004 def mycheck(prog): - print "Got call using prog=0x%x" % prog + print("Got call using prog=0x%x" % prog) cb_occurred.prog = prog cb_occurred.set() return True;
@@ -366,7 +366,7 @@ def testCallbackVersion(t, env): cb_occurred = threading.Event() transient = 0x40000000 def mycheck(low, hi, vers): - print "Got call using version=%i" % vers + print("Got call using version=%i" % vers) cb_occurred.low = low cb_occurred.hi = hi cb_occurred.vers = vers
nfs4.1/server41tests/st_debug.py +5 -5
@@ -31,7 +31,7 @@ def testSupported2(t, env): owner, how, claim) res = sess2.compound(env.home + [open_op]) # STUB - since we are not handling callback, deleg_return never gets done - print res + print(res) check(res) fh2 = res.resarray[-1].object stateid2 = res.resarray[-2].stateid
@@ -55,16 +55,16 @@ def testReadWrite(t, env): owner, how, claim) fh_op = op.putrootfh() res = sess1.compound([fh_op, open_op, op.getfh()]) # OPEN - print res + print(res) check(res) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid stateid.seqid = 0 res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, "write test data")]) - print res + print(res) check(res) res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) - print res + print(res) check(res) res = close_file(sess1, fh, stateid=stateid) check(res)
@@ -95,7 +95,7 @@ def testDeadlock(t, env): for xid in xids: res = sess1.listen(xid) check(res) - print res + print(res) res = close_file(sess1, fh, stateid=stateid) check(res)
nfs4.1/server41tests/st_destroy_session.py +1 -1
@@ -109,7 +109,7 @@ def testDestroy3(t, env): check(res) fh = res.resarray[-1].object deleg = res.resarray[-2].delegation - print "OPEN fh =", repr(fh) + print("OPEN fh =", repr(fh)) if deleg.delegation_type == OPEN_DELEGATE_NONE: fail("Could not get delegation") recall.happened = False
nfs4.1/server41tests/st_exchange_id.py +2 -2
@@ -91,7 +91,7 @@ def testSSV(t, env): # This should fail if not using GSS? What about E_ID? res = sess.set_ssv('\x5a' * c.protect.context.ssv_len) - print res + print(res) def testNoImplId(t, env): """Do a simple EXCHANGE_ID w/o setting client impl_id
@@ -118,7 +118,7 @@ def testLongArray(t, env): xid = c.compound_async(ops, checks=False) try: res = c.listen(xid) - print res + print(res) except RPCAcceptError, e: if e.stat == GARBAGE_ARGS: # Legitimate return
nfs4.1/server41tests/st_getdevicelist.py +7 -7
@@ -28,7 +28,7 @@ def testGetDevList(t, env): check(res) # STUB - check block stuff dev_list = res.resarray[-1].gdlr_deviceid_list - print dev_list + print(dev_list) def testGetDevInfo(t, env): """Check devlist
@@ -60,7 +60,7 @@ def testGetDevInfo(t, env): p.reset(res.resarray[-1].da_addr_body) decode = p.unpack_pnfs_block_deviceaddr4() p.done() - print decode + print(decode) ## def xxxtestLayout(t, env):
@@ -110,7 +110,7 @@ def testGetLayout(t, env): p = BlockUnpacker(layout.loc_body) opaque = p.unpack_pnfs_block_layout4() p.done() - print opaque + print(opaque) def testEMCGetLayout(t, env): """Verify layout handling
@@ -142,7 +142,7 @@ def testEMCGetLayout(t, env): p = BlockUnpacker(layout.loc_body) opaque = p.unpack_pnfs_block_layout4() p.done() - print opaque + print(opaque) def testLayoutReturnFile(t, env): """
@@ -257,9 +257,9 @@ def testLayoutCommit(t, env): p = BlockUnpacker(layout.loc_body) opaque = p.unpack_pnfs_block_layout4() p.done() - print opaque + print(opaque) final_extent = opaque.blo_extents[-1] - print final_extent + print(final_extent) if final_extent.bex_state != PNFS_BLOCK_INVALID_DATA: fail("Expected INVALID_DATA in extent") # LAYOUTCOMMIT
@@ -276,6 +276,6 @@ def testLayoutCommit(t, env): layoutupdate4(LAYOUT4_BLOCK_VOLUME, p.get_buffer()))] res = sess.compound(ops) check(res) - print res + print(res)
nfs4.1/server41tests/st_secinfo_no_name.py +1 -1
@@ -32,7 +32,7 @@ def testSupported2(t, env): # GETFH after do a SECINFO_NO_NAME should get error NFS4ERR_NOFILEHANDLE res = sess.compound([op.putrootfh(), op.secinfo_no_name(0), op.getfh()]) - print res + print(res) check(res, NFS4ERR_NOFILEHANDLE) def testSupported3(t, env):
nfs4.1/setup.py +3 -3
@@ -31,10 +31,10 @@ class build_py(_build_py): self.build_module(module, module_file, package) def expand_xdr(self, dir): - print "expand = %r" % dir + print("expand = %r" % dir) cwd = os.getcwd() xdrdir = os.path.join(cwd, dir, 'xdrdef') - print "xdrdir = %r" % xdrdir + print("xdrdir = %r" % xdrdir) if os.path.exists(xdrdir): try: os.chdir(xdrdir)
@@ -47,7 +47,7 @@ class build_py(_build_py): os.remove("parser.out") os.remove("parsetab.py") except: - print "Remove parse* failed" + print("Remove parse* failed") finally: os.chdir(cwd)
nfs4.1/testclient.py +15 -15
@@ -24,7 +24,7 @@ import use_local # HACK so don't have to rebuild constantly import sys if sys.hexversion < 0x02050000: - print "Requires python 2.5 or higher" + print("Requires python 2.5 or higher") sys.exit(1) import os
@@ -197,16 +197,16 @@ def printflags(list): command_names = [s.lower()[3:].replace('_', '') \ for s in nfs_opnum4.values()] list.sort() - # First print command names + # First print(command names) print for s in list: if s in command_names: - print s + print(s) # Then everything else print for s in list: if s not in command_names: - print s + print(s) def main(): p = OptionParser("%prog SERVER:/PATH [options] flags|testcodes\n"
@@ -228,16 +228,16 @@ def main(): codes = cdict.keys() codes.sort() for c in codes: - print c + print(c) sys.exit(0) # Grab server info and set defaults if not args: p.error("Need a server") url = args.pop(0) - print "url", url + print("url", url) opt.path = nfs4lib.path_components(url) - print "Set opt.path", opt.path + print("Set opt.path", opt.path) # Check --use* options are valid for attr in dir(opt):
@@ -245,14 +245,14 @@ def main(): opt.useparams = parse_useparams(opt.useparams) elif attr.startswith('use') and attr != "usefh": path = getattr(opt, attr) - #print attr, path + #print(attr, path) if path is None: path = opt.path + ['tree', attr[3:]] else: # FIXME - have funct that checks path validity if path[0] != '/': p.error("Need to use absolute path for --%s" % attr) - # print path + # print(path) if path[-1] == '/' and attr != 'usedir': p.error("Can't use dir for --%s" %attr) try:
@@ -297,20 +297,20 @@ def main(): # Place tests in desired order tests.sort() # FIXME - add options for random sort - # Run the tests and save/print results + # Run the tests and save/print(results) try: env = environment.Environment(opt) env.init() except socket.gaierror, e: if e.args[0] == -2: - print "Unknown server '%s'" % opt.server + print("Unknown server '%s'" % opt.server) sys.exit(1) except Exception, e: - print "Initialization failed, no tests run." + print("Initialization failed, no tests run.") if not opt.maketree: - print "Perhaps you need to use the --maketree option" + print("Perhaps you need to use the --maketree option") raise - print sys.exc_info()[1] + print(sys.exc_info()[1]) sys.exit(1) if opt.outfile is not None: fd = file(opt.outfile, 'w')
@@ -330,7 +330,7 @@ def main(): fail = True testmod.printresults(tests, opt) if fail: - print "\nWARNING: could not clean testdir due to:\n%s\n" % str(e) + print("\nWARNING: could not clean testdir due to:\n%s\n" % str(e)) if __name__ == "__main__": main()
nfs4.1/testmod.py +15 -14
@@ -6,6 +6,7 @@ # Copyright (C) 2004 University of Michigan, Center for # Information Technology Integration # +from __future__ import print_function from __future__ import with_statement import nfs4lib import re
@@ -212,11 +213,11 @@ class Test(object): def run(self, environment, verbose=False): """Run self.runtest, storing result""" - #print "*********Running test %s (%s)" % (self.name, self.code) + #print("*********Running test %s (%s)" % (self.name, self.code)) self.result = self._run_result start_time = time.time() if verbose: - print repr(self) + print(repr(self)) try: environment.startUp() self.runtest(self, environment)
@@ -245,7 +246,7 @@ class Test(object): self.time_taken = stop_time - start_time if verbose: - print repr(self) + print(repr(self)) class Environment(object): """Base class for a test environment"""
@@ -419,8 +420,8 @@ def printresults(tests, opts, file=None): count = [0] * 6 for t in tests: if not hasattr(t, "result"): - print dir(t) - print t.__dict__ + print(dir(t)) + print(t.__dict__) raise if t.result == TEST_NOTRUN: count[NOTRUN] += 1
@@ -434,7 +435,7 @@ def printresults(tests, opts, file=None): count[WARN] += 1 elif t.result == TEST_PASS: count[PASS] += 1 - print >> file, "*"*50 + print("*"*50, file=file) for t in tests: if t.result == TEST_NOTRUN: continue
@@ -448,16 +449,16 @@ def printresults(tests, opts, file=None): continue if (not opts.showfail) and t.result == TEST_FAIL: continue - print >> file, t.display(0,0) - print >> file, "*"*50 + print(t.display(0,0), file=file) + print("*"*50, file=file) if count[NOTRUN]: - print >> file, "Tests interrupted! Only %i tests run" % \ - sum(count[SKIP:]) + print("Tests interrupted! Only %i tests run" % \ + sum(count[SKIP:]), file=file) else: - print >> file, "Command line asked for %i of %i tests" % \ - (sum(count[SKIP:]), len(tests)) - print >> file, "Of those: %i Skipped, %i Failed, %i Warned, %i Passed" % \ - (count[SKIP], count[FAIL], count[WARN], count[PASS]) + print("Command line asked for %i of %i tests" % \ + (sum(count[SKIP:]), len(tests)), file=file) + print("Of those: %i Skipped, %i Failed, %i Warned, %i Passed" % \ + (count[SKIP], count[FAIL], count[WARN], count[PASS]), file=file) return count[FAIL] def xml_printresults(tests, file_name, suite='all'):
nfs4.1/testserver.py +15 -15
@@ -28,7 +28,7 @@ import use_local # HACK so don't have to rebuild constantly import sys if sys.hexversion < 0x02050000: - print "Requires python 2.5 or higher" + print("Requires python 2.5 or higher") sys.exit(1) import os
@@ -196,16 +196,16 @@ def printflags(list): command_names = [s.lower()[3:].replace('_', '') \ for s in nfs_opnum4.values()] list.sort() - # First print command names + # First print(command names) print for s in list: if s in command_names: - print s + print(s) # Then everything else print for s in list: if s not in command_names: - print s + print(s) def main(): p = OptionParser("%prog SERVER:/PATH [options] flags|testcodes\n"
@@ -229,14 +229,14 @@ def main(): codes = cdict.keys() codes.sort() for c in codes: - print c + print(c) sys.exit(0) if opt.showcodesflags: codes = cdict.keys() codes.sort() for c in codes: - print c, "FLAGS:", ', '.join(cdict[c].flags_list) + print(c, "FLAGS:", ', '.join(cdict[c].flags_list)) sys.exit(0) # Grab server info and set defaults
@@ -257,14 +257,14 @@ def main(): for attr in dir(opt): if attr.startswith('use') and attr != "usefh": path = getattr(opt, attr) - #print attr, path + #print(attr, path) if path is None: path = opt.path + ['tree', attr[3:]] else: # FIXME - have funct that checks path validity if path[0] != '/': p.error("Need to use absolute path for --%s" % attr) - # print path + # print(path) if path[-1] == '/' and attr != 'usedir': p.error("Can't use dir for --%s" %attr) try:
@@ -316,21 +316,21 @@ def main(): # Place tests in desired order tests.sort() # FIXME - add options for random sort - # Run the tests and save/print results + # Run the tests and save/print(results) try: env = environment.Environment(opt) env.init() except socket.gaierror, e: if e.args[0] == -2: - print "Unknown server '%s'" % opt.server - print sys.exc_info()[1] + print("Unknown server '%s'" % opt.server) + print(sys.exc_info()[1]) sys.exit(1) except Exception, e: - print "Initialization failed, no tests run." + print("Initialization failed, no tests run.") if not opt.maketree: - print "Perhaps you need to use the --maketree option" + print("Perhaps you need to use the --maketree option") raise - print sys.exc_info()[1] + print(sys.exc_info()[1]) sys.exit(1) if opt.outfile is not None: fd = file(opt.outfile, 'w')
@@ -350,7 +350,7 @@ def main(): fail = True testmod.printresults(tests, opt) if fail: - print "\nWARNING: could not clean testdir due to:\n%s\n" % str(e) + print("\nWARNING: could not clean testdir due to:\n%s\n" % str(e)) if opt.xmlout is not None: testmod.xml_printresults(tests, opt.xmlout)
rpc/rpc.py +2 -2
@@ -878,8 +878,8 @@ class ConnectionHandler(object): def listen(self, pipe, xid): # STUB - should be overwritten by subclass header, data = pipe.listen(xid) - print "HEADER", header - print "DATA", repr(data) + print("HEADER", header) + print("DATA", repr(data)) #################################################
setup.py +3 -1
@@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function + from distutils.core import setup import sys
@@ -19,7 +21,7 @@ def setup(*args, **kwargs): cwd = os.getcwd() command = " ".join(sys.argv) for dir in DIRS: - print "\n\nMoving to %s" % dir + print("\n\nMoving to %s" % dir ) os.chdir(join(cwd, dir)) os.system("python %s" % command) os.chdir(cwd)
showresults.py +2 -1
@@ -1,13 +1,14 @@ #!/usr/bin/env python # showresults.py - redisplay results from nfsv4 server tester output file # -# Requires python 2.3 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for # Information Technology Integration # +from __future__ import print_function # Allow to be run stright from package root if __name__ == "__main__":
xdr/xdrgen.py +17 -17
@@ -300,7 +300,7 @@ def t_linecomment(t): t.lexer.lineno += 1 def t_error(t): - print "Illegal character %s at %d type %s" % (repr(t.value[0]), t.lexer.lineno, t.type) + print("Illegal character %s at %d type %s" % (repr(t.value[0]), t.lexer.lineno, t.type)) t.lexer.skip(1) # Build the lexer
@@ -371,7 +371,7 @@ def p_optional_value(t): if msg: global error_occurred error_occurred = True - print "ERROR - %s near line %i" % (msg, t.lineno(1)) + print("ERROR - %s near line %i" % (msg, t.lineno(1))) def p_type_def_1(t): '''type_def : TYPEDEF declaration SEMI'''
@@ -382,7 +382,7 @@ def p_type_def_1(t): if d.type == 'void': global error_occurred error_occurred = True - print "ERROR - can't use void in typedef at line %i" % lineno + print("ERROR - can't use void in typedef at line %i" % lineno) return d.lineno = lineno if id_unique(d.id, d.type, lineno):
@@ -560,11 +560,11 @@ def p_enum_constant(t): # We have a name instead of a constant, make sure it is defined if value not in name_dict: error_occurred = True - print "ERROR - can't derefence %s at line %s" % (value, lineno) + print("ERROR - can't derefence %s at line %s" % (value, lineno)) elif not isinstance(name_dict[value], const_info): error_occurred = True - print "ERROR - reference to %s at line %s is not a constant" %\ - (value, lineno) + print("ERROR - reference to %s at line %s is not a constant" %\ + (value, lineno)) else: info.positive = name_dict[value].positive t[0] = [info]
@@ -586,9 +586,9 @@ def p_error(t): global error_occurred error_occurred = True if t: - print "Syntax error at '%s' (lineno %d)" % (t.value, t.lineno) + print("Syntax error at '%s' (lineno %d)" % (t.value, t.lineno)) else: - print "Syntax error: unexpectedly hit EOF" + print("Syntax error: unexpectedly hit EOF") # # RPC specific routines follow
@@ -596,7 +596,7 @@ def p_error(t): def p_program_def(t): '''program_def : PROGRAM ID LBRACE version_def version_def_list RBRACE EQUALS constant SEMI''' - print "Ignoring program %s = %s" % (t[2], t[8]) + print("Ignoring program %s = %s" % (t[2], t[8])) global name_dict id = t[2] value = t[8]
@@ -666,8 +666,8 @@ def id_unique(id, name, lineno): if id in name_dict: global error_occurred error_occurred = True - print "ERROR - %s definition %s at line %s conflicts with %s" % \ - (name, id, lineno, name_dict[id]) + print("ERROR - %s definition %s at line %s conflicts with %s" % \ + (name, id, lineno, name_dict[id])) return False else: return True
@@ -1391,7 +1391,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False): global use_filters, allow_attr_passthrough use_filters = filters allow_attr_passthrough = pass_attrs - print "Input file is", infile + print("Input file is", infile) # Create output file names (without .py) global constants_file, types_file, packer_file
@@ -1399,8 +1399,8 @@ def run(infile, filters=True, pass_attrs=True, debug=False): constants_file = name_base + "_const" types_file = name_base + "_type" packer_file = name_base + "_pack" - print "Will use output files %s.py, %s.py, and %s.py" % \ - (constants_file, types_file, packer_file) + print("Will use output files %s.py, %s.py, and %s.py" % \ + (constants_file, types_file, packer_file)) # Parse the input data with yacc global name_dict
@@ -1414,7 +1414,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False): if error_occurred: print - print "Error occurred, did not write output files" + print("Error occurred, did not write output files") return 1 comment_string = "# Generated by rpcgen.py from %s on %s\n" % \
@@ -1433,7 +1433,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False): type_list = name_dict.values() type_list.sort() for value in type_list: - #print value + #print(value) output = value.const_output() if output is not None: #const_fd.write("# **** %s ****\n" % value.id)
@@ -1465,7 +1465,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False): # if __name__ == "__main__": if len(sys.argv) < 2: - print "Usage: %s <filename>" % sys.argv[0] + print("Usage: %s <filename>" % sys.argv[0]) sys.exit(1) run(sys.argv[1])
Signature · 1 line
2.17.1
PATCH 2/24 pynfs: python3 support plan: exec -> exec()
From: "Jianhong.Yin" <[email protected]>
'/exec / {:loop /[^\\]$/! {N; b loop}; s/exec /exec(/; s/$/)/; }'
--- nfs4.1/nfs4commoncode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
nfs4.1/nfs4commoncode.py +2 -2
@@ -190,8 +190,8 @@ class %(CompoundState)s(object): ''' # Create normal code -exec code_str % _d +exec(code_str % _d) # Create callback code -exec code_str % _cb_d +exec(code_str % _cb_d)
Signature · 1 line
2.17.1
PATCH 3/24 pynfs: python3 support plan: "except E,e:" -> "except E as e:"
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
s/except *([^,]+), *([^ ]+):/except \1 as \2:/
--- nfs4.0/lib/rpc/rpc.py | 8 +++--- nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py | 2 +- nfs4.0/nfs4server.py | 32 +++++++++++------------ nfs4.0/nfs4state.py | 8 +++--- nfs4.0/servertests/st_compound.py | 4 +-- nfs4.0/servertests/st_create.py | 2 +- nfs4.0/servertests/st_delegation.py | 4 +-- nfs4.0/servertests/st_gss.py | 28 ++++++++++---------- nfs4.0/servertests/st_link.py | 2 +- nfs4.0/servertests/st_lookup.py | 6 ++--- nfs4.0/servertests/st_readdir.py | 6 ++--- nfs4.0/servertests/st_remove.py | 4 +-- nfs4.0/servertests/st_rename.py | 6 ++--- nfs4.0/testserver.py | 8 +++--- nfs4.1/config.py | 2 +- nfs4.1/fs.py | 4 +-- nfs4.1/nfs4client.py | 6 ++--- nfs4.1/nfs4server.py | 24 ++++++++--------- nfs4.1/server41tests/st_compound.py | 2 +- nfs4.1/server41tests/st_create_session.py | 2 +- nfs4.1/server41tests/st_exchange_id.py | 2 +- nfs4.1/server41tests/st_lookup.py | 4 +-- nfs4.1/testclient.py | 8 +++--- nfs4.1/testmod.py | 8 +++--- nfs4.1/testserver.py | 8 +++--- rpc/rpc.py | 16 ++++++------ rpc/rpclib.py | 4 +-- rpc/security.py | 8 +++--- 28 files changed, 109 insertions(+), 109 deletions(-)
nfs4.0/lib/rpc/rpc.py +4 -4
@@ -226,7 +226,7 @@ class RPCClient(object): try: sock.bind(('', port)) return - except socket.error, why: + except socket.error as why: if why[0] == errno.EADDRINUSE: port += 1 else:
@@ -330,7 +330,7 @@ class RPCClient(object): self.socket.send_record(header + data) except socket.timeout: raise - except socket.error, e: + except socket.error as e: print("Got error:", e) if self.debug: print("resend", xid) try:
@@ -360,7 +360,7 @@ class RPCClient(object): reply = self.socket.recv_record() except socket.timeout: raise - except socket.error, e: + except socket.error as e: print("Got error:", e) if self.debug: print("relisten", xid) try:
@@ -635,7 +635,7 @@ class RPCServer(Server): self.rpcunpacker.reset(recv_data) try: recv_msg = self.rpcunpacker.unpack_rpc_msg() - except xdrlib.Error, e: + except xdrlib.Error as e: print("XDRError", e) return if recv_msg.body.mtype != CALL:
nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py +1 -1
@@ -18,7 +18,7 @@ class SecAuthSys(SecFlavor): p.pack_uint(gid) p.pack_array(gids, p.pack_uint) self.cred = p.get_buffer() - except Error, e: + except Error as e: raise SecError("Packing error: %s", str(e)) self.uid = uid self.gid = gid
nfs4.0/nfs4server.py +16 -16
@@ -227,7 +227,7 @@ class NFS4Server(rpc.RPCServer): raise NFS4Error(NFS4ERR_NOFILEHANDLE) print(" CLOSE fh", self.curr_fh.handle) self.state.close(stateid) - except NFS4Error, e: + except NFS4Error as e: self.state.advance_seqid(stateid, op, (e.code,)) return simple_error(e.code) # Return a garbage state id
@@ -269,7 +269,7 @@ class NFS4Server(rpc.RPCServer): attrset = self.curr_fh.create(op.opcreate.objname, op.opcreate.objtype, attrs) new_cinfo = self.curr_fh.fattr4_change self.curr_fh = self.curr_fh.lookup(op.opcreate.objname) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code) cin4 = change_info4(before=old_cinfo, after=new_cinfo, atomic=1) c4resok = CREATE4resok(cinfo=cin4, attrset = attrset)
@@ -290,7 +290,7 @@ class NFS4Server(rpc.RPCServer): return simple_error(NFS4ERR_NOFILEHANDLE) attrs = nfs4lib.bitmap2list(op.opgetattr.attr_request) attrvals = self.curr_fh.get_attributes(attrs) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code) garesok = GETATTR4resok(attrvals) return simple_error(NFS4_OK, garesok)
@@ -351,7 +351,7 @@ class NFS4Server(rpc.RPCServer): self.state.new_lockowner(op.oplock.locker.open_owner) stateid = self.state.lock(self.curr_fh, owner, op.oplock.locktype, op.oplock.offset, op.oplock.length) - except NFS4Error, e: + except NFS4Error as e: if op.oplock.locker.new_lock_owner: # FIXME - a bug? compare with replay=check_seqid() above self.state.advance_seqid(openstateid, op, (e.code,))
@@ -376,7 +376,7 @@ class NFS4Server(rpc.RPCServer): self.state.testlock(self.curr_fh, op.oplockt.owner, op.oplockt.locktype, op.oplockt.offset, op.oplockt.length) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code, e.lock_denied) return simple_error(NFS4_OK)
@@ -393,7 +393,7 @@ class NFS4Server(rpc.RPCServer): raise NFS4Error(NFS4ERR_NOFILEHANDLE) sid = self.state.unlock(self.curr_fh, stateid, op.oplocku.locktype, op.oplocku.offset, op.oplocku.length) - except NFS4Error, e: + except NFS4Error as e: self.state.advance_seqid(stateid, op, (e.code,)) return simple_error(e.code) self.state.advance_seqid(stateid, op, (NFS4_OK, sid), self.curr_fh)
@@ -438,7 +438,7 @@ class NFS4Server(rpc.RPCServer): if FATTR4_RDATTR_ERROR in attrreq: return simple_error(NFS4ERR_INVAL) attrvals = self.curr_fh.get_attributes(attrreq.keys(), ignore=False) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code) if attrvals == attrreq: return simple_error(NFS4ERR_SAME)
@@ -524,7 +524,7 @@ class NFS4Server(rpc.RPCServer): # 'existing' now points to a valid file, so check and set shares sid, flags = self.state.open(existing, owner, op.opopen.share_access, op.opopen.share_deny) - except NFS4Error, e: + except NFS4Error as e: print("Open error") self.state.advance_seqid(owner, op, (e.code,)) return simple_error(e.code)
@@ -560,7 +560,7 @@ class NFS4Server(rpc.RPCServer): if self.curr_fh.get_type() != NF4REG: raise NFS4Error(NFS4ERR_INVAL) sid = self.state.confirm(self.curr_fh, stateid) - except NFS4Error, e: + except NFS4Error as e: self.state.advance_seqid(stateid, op, (e.code,)) return simple_error(e.code) oc4resok = OPEN_CONFIRM4resok(sid)
@@ -583,7 +583,7 @@ class NFS4Server(rpc.RPCServer): sid = self.state.downgrade(self.curr_fh, stateid, op.opopen_downgrade.share_access, op.opopen_downgrade.share_deny) - except NFS4Error, e: + except NFS4Error as e: self.state.advance_seqid(stateid, op, (e.code,)) return simple_error(e.code) od4resok = OPEN_DOWNGRADE4resok(sid)
@@ -626,7 +626,7 @@ class NFS4Server(rpc.RPCServer): offset, count) read_data = self.curr_fh.read(offset, count) print(" READ DATA: len=%i" % len(read_data)) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code) if len(read_data) < count: read_eof = 1
@@ -693,7 +693,7 @@ class NFS4Server(rpc.RPCServer): d4 = dirlist4(e4, eof=0) else: d4 = dirlist4(e4, eof=1) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code) rdresok = READDIR4resok(cookieverf=verifier, reply=d4) return simple_error(NFS4_OK, rdresok)
@@ -777,7 +777,7 @@ class NFS4Server(rpc.RPCServer): def op_renew(self, op): try: self.state.renew(op.oprenew.clientid) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code) return simple_error(NFS4_OK)
@@ -830,7 +830,7 @@ class NFS4Server(rpc.RPCServer): self.state.check_write(self.curr_fh, op.opsetattr.stateid, offset, length) attrset = self.curr_fh.set_attributes(attrdict) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code, e.attrs) return simple_error(NFS4_OK, attrset)
@@ -908,7 +908,7 @@ class NFS4Server(rpc.RPCServer): if FATTR4_RDATTR_ERROR in attrreq: return simple_error(NFS4ERR_INVAL) attrvals = self.curr_fh.get_attributes(attrreq.keys(), ignore=False) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code) if attrvals == attrreq: return simple_error(NFS4_OK)
@@ -935,7 +935,7 @@ class NFS4Server(rpc.RPCServer): offset, len(data)) count = self.curr_fh.write(offset, data) print(" wrote %i bytes" % count) - except NFS4Error, e: + except NFS4Error as e: return simple_error(e.code) w4resok = WRITE4resok(count, FILE_SYNC4, self.state.write_verifier) return simple_error(NFS4_OK, w4resok)
nfs4.0/nfs4state.py +4 -4
@@ -249,7 +249,7 @@ class NFSServerState: mustexist = True try: info = self.__getinfo(obj, allownew=not mustexist) - except ValueError, e: + except ValueError as e: if mustexist: raise #print(" check_seqid: %s" % info) if info is None:
@@ -286,7 +286,7 @@ class NFSServerState: # RFC 3530 sec 8.1.5 try: info = self.__getinfo(owner) - except (ValueError, NFS4Error): + except (ValueError as NFS4Error): # An unknown owner, do nothing return if info is None:
@@ -1132,7 +1132,7 @@ class VirtualHandle(NFSFileHandle): except AttributeError: # Otherwise, just set the variable setattr(self, name, attrdict[attr]) - except NFS4Error, e: + except NFS4Error as e: # Note attributes set so far in any error that occurred e.attrs = mapping(ret_list) raise
@@ -1170,7 +1170,7 @@ class VirtualHandle(NFSFileHandle): if POSIXACL: try: nfs4acl.maps_to_posix(acl) - except nfs4acl.ACLError, e: + except nfs4acl.ACLError as e: print("*"*50) print(e) print("*"*50)
nfs4.0/servertests/st_compound.py +2 -2
@@ -82,7 +82,7 @@ def testUndefined(t, env): try: res = c.compound([nfs_argop4(argop=opnum)]) check(res, NFS4ERR_OP_ILLEGAL, "Sent illegal op=%i" % opnum) - except RPCError, e: + except RPCError as e: t.fail("COMPOUND with illegal op=%i got %s, " "expected NFS4ERR_OP_ILLEGAL" % (opnum,e)) finally:
@@ -106,6 +106,6 @@ def testLongCompound(t, env): "COMPOUND with len=%i argarry" % (3*count)) if res.status == NFS4ERR_RESOURCE: return - except RPCError, e: + except RPCError as e: t.fail("COMPOUND with len=%i argarry got %s, " "expected NFS4ERR_RESOURCE" % (3*count, e))
nfs4.0/servertests/st_create.py +1 -1
@@ -290,5 +290,5 @@ def testLongName(t, env): (x, rejected_names_create) = self.try_file_names(creator=self.create_via_create) self.failIf(rejected_names_open != rejected_names_create, "CREATE does not obey OPEN naming policy") - except SkipException, e: + except SkipException as e: self.skip(e)
nfs4.0/servertests/st_delegation.py +2 -2
@@ -21,7 +21,7 @@ class _handle_error(object): _lock.acquire() try: self.c.compound(ops) - except Exception, e: + except Exception as e: print("CALLBACK error in _recall:", e) pass _lock.release()
@@ -33,7 +33,7 @@ def _recall(c, thisop, cbid): _lock.acquire() try: res = c.compound(ops) - except Exception, e: + except Exception as e: print("CALLBACK error in _recall:", e) res = None _lock.release()
nfs4.0/servertests/st_gss.py +14 -14
@@ -109,11 +109,11 @@ def testInconsistentGssSeqnum(t, env): try: res = c.compound([op.putrootfh()]) e = "operation erroneously suceeding" - except rpc.RPCAcceptError, e: + except rpc.RPCAcceptError as e: if e.stat == rpc.GARBAGE_ARGS: # This is correct response return - except Exception, e: + except Exception as e: pass t.fail("Using inconsistent gss_seq_nums in header and body of message " "should return GARBAGE_ARGS, instead got %s" % e)
@@ -138,11 +138,11 @@ def testBadVerfChecksum(t, env): try: res = c.compound([op.putrootfh()]) e = "peration erroneously suceeding" - except rpc.RPCDeniedError, e: + except rpc.RPCDeniedError as e: if e.stat == rpc.AUTH_ERROR and e.astat == rpc.RPCSEC_GSS_CREDPROBLEM: # This is correct response return - except Exception, e: + except Exception as e: pass t.fail("Using bad verifier checksum in header " "should return RPCSEC_GSS_CREDPROBLEM, instead got %s" % e)
@@ -174,11 +174,11 @@ def testBadDataChecksum(t, env): try: res = c.compound([op.putrootfh()]) e = "operation erroneously suceeding" - except rpc.RPCAcceptError, e: + except rpc.RPCAcceptError as e: if e.stat == rpc.GARBAGE_ARGS: # This is correct response return - except Exception, e: + except Exception as e: pass t.fail("Using bad data checksum for body of message " "should return GARBAGE_ARGS, instead got %s" % e)
@@ -214,11 +214,11 @@ def testBadVersion(t, env): try: res = c.compound([op.putrootfh()]) e = "operation erroneously suceeding" - except rpc.RPCDeniedError, e: + except rpc.RPCDeniedError as e: if e.stat == rpc.AUTH_ERROR and e.astat == rpc.AUTH_BADCRED: # This is correct response e = None - except Exception, e: + except Exception as e: pass if e is not None: t.fail("Using bad gss version number %i "
@@ -241,11 +241,11 @@ def testHighSeqNum(t, env): try: res = c.compound([op.putrootfh()]) e = "operation erroneously suceeding" - except rpc.RPCDeniedError, e: + except rpc.RPCDeniedError as e: if e.stat == rpc.AUTH_ERROR and e.astat == rpc.RPCSEC_GSS_CTXPROBLEM: # This is correct response return - except Exception, e: + except Exception as e: pass t.fail("Using gss_seq_num over MAXSEQ " "should return RPCSEC_GSS_CTXPROBLEM, instead got %s" % e)
@@ -279,11 +279,11 @@ def testBadProcedure(t, env): try: res = c.compound([op.putrootfh()]) e = "operation erroneously suceeding" - except rpc.RPCDeniedError, e: + except rpc.RPCDeniedError as e: if e.stat == rpc.AUTH_ERROR and e.astat == rpc.AUTH_BADCRED: # This is correct response e = None - except Exception, e: + except Exception as e: pass if e is not None: t.fail("Using bad gss procedure number %i "
@@ -321,11 +321,11 @@ def testBadService(t, env): try: res = c.compound([op.putrootfh()]) e = "operation erroneously suceeding" - except rpc.RPCDeniedError, e: + except rpc.RPCDeniedError as e: if e.stat == rpc.AUTH_ERROR and e.astat == rpc.AUTH_BADCRED: # This is correct response e = None - except Exception, e: + except Exception as e: pass if e is not None: t.fail("Using bad gss service number %i "
nfs4.0/servertests/st_link.py +1 -1
@@ -264,6 +264,6 @@ def testDots(t, env): (x, rejected_names_link) = self.try_file_names(creator=self.create_via_link) self.failIf(rejected_names_open != rejected_names_link, "LINK does not obey OPEN naming policy") - except SkipException, e: + except SkipException as e: self.skip(e)
nfs4.0/servertests/st_lookup.py +3 -3
@@ -312,7 +312,7 @@ def testBadOpaque(t, env): res = c.compound([op.putrootfh(), op.lookup("setlength=0xcccccccc")]) e = "operation erroneously suceeding" check(res, NFS4ERR_BADXDR) - except rpc.RPCAcceptError, e: + except rpc.RPCAcceptError as e: if e.stat == rpc.GARBAGE_ARGS: # This is correct response return
@@ -336,7 +336,7 @@ def testBadOpaque(t, env): # Saved files for LOOKUP try: (accepted_names, rejected_names) = self.try_file_names(0) - except SkipException, e: + except SkipException as e: self.skip(e) # Ok, lets try LOOKUP on all accepted names
@@ -363,7 +363,7 @@ def testBadOpaque(t, env): try: (accepted_names, rejected_names) = self.try_file_names() - except SkipException, e: + except SkipException as e: self.skip(e) # Ok, lets try LOOKUP on all rejected names
nfs4.0/servertests/st_readdir.py +3 -3
@@ -272,7 +272,7 @@ def testUnaccessibleDirAttrs(t, env): try: (accepted_names, rejected_names) = self.try_file_names(remove_files=0) - except SkipException, e: + except SkipException as e: self.skip(e) fh = self.do_rpc(self.ncl.do_getfh, self.tmp_dir)
@@ -309,11 +309,11 @@ def testUnaccessibleDirAttrs(t, env): try: (accepted_names, rejected_names) = self.small_try_file_names(remove_files=0) - except SkipException, e: + except SkipException as e: self.skip(e) try: self.clean_dir(self.tmp_dir) - except SkipException, e: + except SkipException as e: self.fail(e) def small_try_file_names(self, remove_files=1, creator=None):
nfs4.0/servertests/st_remove.py +2 -2
@@ -274,7 +274,7 @@ def testNotEmpty(t, env): # Save files for REMOVE try: (accepted_names, rejected_names) = self.try_file_names(remove_files=0) - except SkipException, e: + except SkipException as e: self.skip(e) # Ok, lets try REMOVE on all accepted names
@@ -299,7 +299,7 @@ def testNotEmpty(t, env): self.init_connection() try: (accepted_names, rejected_names) = self.try_file_names() - except SkipException, e: + except SkipException as e: self.skip(e) # Ok, lets try REMOVE on all rejected names
nfs4.0/servertests/st_rename.py +3 -3
@@ -534,7 +534,7 @@ def testLinkRename(t, env): (x, rejected_names_rename) = self.try_file_names(creator=self.create_via_rename) self.failIf(rejected_names_open != rejected_names_rename, "RENAME does not obey OPEN naming policy") - except SkipException, e: + except SkipException as e: self.skip(e) def testValidNames(t, env):
@@ -550,7 +550,7 @@ def testLinkRename(t, env): # Saved files for try: (accepted_names, rejected_names) = self.try_file_names(remove_files=0) - except SkipException, e: + except SkipException as e: self.skip(e) # Ok, lets try RENAME on all accepted names
@@ -573,7 +573,7 @@ def testLinkRename(t, env): try: (accepted_names, rejected_names) = self.try_file_names() - except SkipException, e: + except SkipException as e: self.skip(e) # Ok, lets try RENAME on all rejected names
nfs4.0/testserver.py +4 -4
@@ -297,7 +297,7 @@ def main(): p.error("Can't use dir for --%s" %attr) try: path = unixpath2comps(path) - except Exception, e: + except Exception as e: p.error(e) setattr(opt, attr, [comp for comp in path if comp])
@@ -341,12 +341,12 @@ def main(): try: env = environment.Environment(opt) env.init() - except socket.gaierror, e: + except socket.gaierror as e: if e.args[0] == -2: print("Unknown server '%s'" % opt.server) print(sys.exc_info()[1]) sys.exit(1) - except Exception, e: + except Exception as e: print("Initialization failed, no tests run.") if not opt.maketree: print("Perhaps you need to use the --maketree option")
@@ -367,7 +367,7 @@ def main(): try: fail = False env.finish() - except Exception, e: + except Exception as e: fail = True nfail = testmod.printresults(tests, opt) if fail:
nfs4.1/config.py +1 -1
@@ -74,7 +74,7 @@ class ConfigLine(object): def _set_value(self, value): try: self._value = self.verify(value) - except ConfigAction, e: + except ConfigAction as e: e.name = self.name e.value = value raise
nfs4.1/fs.py +2 -2
@@ -323,7 +323,7 @@ class FSObject(object): base = self.meta try: setattr(base, name, attrs[attr]) - except NFS4Error, e: + except NFS4Error as e: # Note attributes set so far in any error that occurred e.attrs = bitmap raise
@@ -747,7 +747,7 @@ class ConfigObj(FSObject): return try: self.configline.value = lines[0] - except ConfigAction, e: + except ConfigAction as e: if e.name == "reboot": self.fs.server.reboot() except:
nfs4.1/nfs4client.py +3 -3
@@ -161,7 +161,7 @@ class NFS4Client(rpc.Client, rpc.Server): env.results.cache.results)) env.cache.data = p.get_buffer() env.cache.valid.set() - except NFS4Replay, e: + except NFS4Replay as e: log_cb.info("Replay...waiting for valid data") e.cache.valid.wait() log_cb.info("Replay...sending data")
@@ -183,7 +183,7 @@ class NFS4Client(rpc.Client, rpc.Server): return env try: self.check_utf8str_cs(args.tag) - except NFS4Errror, e: + except NFS4Errror as e: env.results.set_empty_return(e.status, "Invalid utf8 tag") return env # Handle the individual operations
@@ -202,7 +202,7 @@ class NFS4Client(rpc.Client, rpc.Server): try: # Otherwise, call the function result = funct(arg, env) - except NFS4Error, e: + except NFS4Error as e: # XXX NOTE this only works for error returns that # include no data. Must ensure others (eg setattr) # catch error themselves to encode properly.
nfs4.1/nfs4server.py +12 -12
@@ -350,7 +350,7 @@ class ClientRecord(object): state.delete() # STUB - what about LAYOUT? # STUB - config whether DELEG OK or not - except StandardError, e: + except StandardError as e: log_41.exception("Ignoring problem during state removal") self.state = {} self.lastused = time.time()
@@ -721,7 +721,7 @@ class NFS4Server(rpc.Server): env.results.cache.results)) env.cache.data = p.get_buffer() env.cache.valid.set() - except NFS4Replay, e: + except NFS4Replay as e: log_41.info("Replay...waiting for valid data") e.cache.valid.wait() log_41.info("Replay...sending data")
@@ -808,7 +808,7 @@ class NFS4Server(rpc.Server): return env try: self.check_utf8str_cs(args.tag) - except NFS4Errror, e: + except NFS4Errror as e: env.results.set_empty_return(e.status, "Invalid utf8 tag") return env # Handle the individual operations
@@ -828,7 +828,7 @@ class NFS4Server(rpc.Server): try: # Otherwise, call the function result = funct(arg, env) - except NFS4Error, e: + except NFS4Error as e: # XXX NOTE this only works for error returns that # include no data. Must ensure others (eg setattr) # catch error themselves to encode properly.
@@ -876,7 +876,7 @@ class NFS4Server(rpc.Server): # We have a session. Check for injected errors try: self.check_opsconfig(env, "sequence") - except NFS4Error, e: + except NFS4Error as e: self.error_set_session(session, arg.sa_sessionid, e.status) # Check connection binding
@@ -962,7 +962,7 @@ class NFS4Server(rpc.Server): self.cb_null(session.cb_prog, connection, credinfo=None) flags |= CREATE_SESSION4_FLAG_CONN_BACK_CHAN cb_channel.connections.append(connection) - except rpc.RPCError, e: + except rpc.RPCError as e: log_41.warn("cb_null failed with %r, no backchannel created", e) # STUB: backchannel is down: set sequence bits, disable layouts, etc. pass
@@ -1604,7 +1604,7 @@ class NFS4Server(rpc.Server): finally: state.mark_done_writing() return encode_status(NFS4_OK, bitmap) - except NFS4Error, e: + except NFS4Error as e: # SETATTR failure does not encode just status return encode_status(e.status, e.attrs)
@@ -1702,7 +1702,7 @@ class NFS4Server(rpc.Server): if FATTR4_RDATTR_ERROR in attrreq: raise NFS4Error(NFS4ERR_INVAL) attrvals = self.get_attributes(env.cfh, attrreq.keys(), ignore=False) - except NFS4Error, e: + except NFS4Error as e: return encode_status(e.code) if attrvals == attrreq: return encode_status(NFS4ERR_SAME)
@@ -1717,7 +1717,7 @@ class NFS4Server(rpc.Server): if FATTR4_RDATTR_ERROR in attrreq: raise NFS4Error(NFS4ERR_INVAL) attrvals = self.get_attributes(env.cfh, attrreq.keys(), ignore=False) - except NFS4Error, e: + except NFS4Error as e: return encode_status(e.code) if attrvals != attrreq: return encode_status(NFS4ERR_NOT_SAME)
@@ -1806,7 +1806,7 @@ class NFS4Server(rpc.Server): with find_state(env, arg.lock_stateid, allow_0=False) as state: state.add_lock(arg.locktype, arg.offset, end) stateid = state.get_id() - except NFS4Error, e: + except NFS4Error as e: return encode_status(e.status, denied=e.lock_denied) l4resok = LOCK4resok(stateid) return encode_status(NFS4_OK, l4resok)
@@ -1820,7 +1820,7 @@ class NFS4Server(rpc.Server): with env.cfh.state: env.cfh.state.test_lock(env.session.client, arg.owner.owner, arg.locktype, arg.offset, end) - except NFS4Error, e: + except NFS4Error as e: return encode_status(e.status, denied=e.lock_denied) return encode_status(NFS4_OK)
@@ -1904,7 +1904,7 @@ class NFS4Server(rpc.Server): return_on_close = False res = LAYOUTGET4resok(return_on_close, entry.get_id(), [layout]) return encode_status(NFS4_OK, res) - except NFS4Error, e: + except NFS4Error as e: # LAYOUTGET failure does not encode just status if e.status == NFS4ERR_LAYOUTTRYLATER: return encode_status(e.status, None, False)
nfs4.1/server41tests/st_compound.py +1 -1
@@ -118,7 +118,7 @@ def testUndefined(t, env): check(res, NFS4ERR_OP_ILLEGAL) if res.resarray[-1].resop != OP_ILLEGAL: t.fail('Server echoed invalid opcode: Should return OP_ILLEGAL') - except RPCAcceptError, e: + except RPCAcceptError as e: if e.stat == GARBAGE_ARGS: pass else:
nfs4.1/server41tests/st_create_session.py +1 -1
@@ -311,7 +311,7 @@ def testRdmaArray2(t, env): try: res = c.listen(xid) print(res) - except RPCAcceptError, e: + except RPCAcceptError as e: if e.stat == GARBAGE_ARGS: # Legitimate return return
nfs4.1/server41tests/st_exchange_id.py +1 -1
@@ -119,7 +119,7 @@ def testLongArray(t, env): try: res = c.listen(xid) print(res) - except RPCAcceptError, e: + except RPCAcceptError as e: if e.stat == GARBAGE_ARGS: # Legitimate return return
nfs4.1/server41tests/st_lookup.py +2 -2
@@ -360,7 +360,7 @@ if 0: # Saved files for LOOKUP try: (accepted_names, rejected_names) = self.try_file_names(0) - except SkipException, e: + except SkipException as e: self.skip(e) # Ok, lets try LOOKUP on all accepted names
@@ -387,7 +387,7 @@ if 0: try: (accepted_names, rejected_names) = self.try_file_names() - except SkipException, e: + except SkipException as e: self.skip(e) # Ok, lets try LOOKUP on all rejected names
nfs4.1/testclient.py +4 -4
@@ -257,7 +257,7 @@ def main(): p.error("Can't use dir for --%s" %attr) try: path = nfs4lib.path_components(path) - except Exception, e: + except Exception as e: p.error(e) setattr(opt, attr, [comp for comp in path if comp])
@@ -301,11 +301,11 @@ def main(): try: env = environment.Environment(opt) env.init() - except socket.gaierror, e: + except socket.gaierror as e: if e.args[0] == -2: print("Unknown server '%s'" % opt.server) sys.exit(1) - except Exception, e: + except Exception as e: print("Initialization failed, no tests run.") if not opt.maketree: print("Perhaps you need to use the --maketree option")
@@ -326,7 +326,7 @@ def main(): try: fail = False env.finish() - except Exception, e: + except Exception as e: fail = True testmod.printresults(tests, opt) if fail:
nfs4.1/testmod.py +4 -4
@@ -226,19 +226,19 @@ class Test(object): environment.clean_clients() except KeyboardInterrupt: raise - except TestException, e: + except TestException as e: self.result = Result(e.type, e, sys.exc_info()) - except StandardError, e: + except StandardError as e: if verbose: print_exc() self.result = Result(TEST_FAIL, '', sys.exc_info()) self.result.msg = self.result.tb[-1] - except Exception, e: + except Exception as e: self.result = Result(TEST_FAIL, e, sys.exc_info()) self.result.msg = self.result.tb[-1] try: environment.shutDown() - except StandardError, e: + except StandardError as e: self.result = Result(TEST_FAIL, '', sys.exc_info()) self.result.msg = self.result.tb[-1]
nfs4.1/testserver.py +4 -4
@@ -269,7 +269,7 @@ def main(): p.error("Can't use dir for --%s" %attr) try: path = nfs4lib.path_components(path) - except Exception, e: + except Exception as e: p.error(e) setattr(opt, attr, [comp for comp in path if comp])
@@ -320,12 +320,12 @@ def main(): try: env = environment.Environment(opt) env.init() - except socket.gaierror, e: + except socket.gaierror as e: if e.args[0] == -2: print("Unknown server '%s'" % opt.server) print(sys.exc_info()[1]) sys.exit(1) - except Exception, e: + except Exception as e: print("Initialization failed, no tests run.") if not opt.maketree: print("Perhaps you need to use the --maketree option")
@@ -346,7 +346,7 @@ def main(): try: fail = False env.finish() - except Exception, e: + except Exception as e: fail = True testmod.printresults(tests, opt) if fail:
rpc/rpc.py +8 -8
@@ -169,7 +169,7 @@ class Alarm(object): self._s.setblocking(0) try: self._s.connect(address) - except socket.error, e: + except socket.error as e: if e.args[0] in [EINPROGRESS, EWOULDBLOCK]: # address has not yet called accept, since this is done in a # single thread, so get "op in progress error". When the
@@ -330,7 +330,7 @@ class Pipe(object): raise RuntimeError try: count = self._s.send(self._write_buf) - except socket.error, e: + except socket.error as e: log_p.error("flush_pipe got exception %s" % str(e)) return True # This is to stop retries self._write_buf = self._write_buf[count:]
@@ -513,13 +513,13 @@ class ConnectionHandler(object): for fd in w: try: self._event_write(fd) - except socket.error, e: + except socket.error as e: self._event_close(fd) for fd in r: if fd in self.listeners: try: self._event_connect_incoming(fd) - except socket.error, e: + except socket.error as e: self._event_close(fd) elif fd == self._alarm_poll.fileno(): commands = self._alarm_poll.recv(self.rsize)
@@ -527,7 +527,7 @@ class ConnectionHandler(object): data = self._alarm.pop() try: switch[c](data) - except socket.error, e: + except socket.error as e: self._event_close(fd) else: try:
@@ -557,7 +557,7 @@ class ConnectionHandler(object): s.setblocking(0) else: csock, caddr = s.accept() - except socket.error, e: + except socket.error as e: log_p.error("accept() got error %s" % str(e)) return csock.setblocking(0)
@@ -700,7 +700,7 @@ class ConnectionHandler(object): # Silently drop the request self._notify_drop() return - except rpclib.RPCFlowContol, e: + except rpclib.RPCFlowContol as e: body, data = e.body() except Exception: log_t.warn("Unexpected exception", exc_info=True)
@@ -832,7 +832,7 @@ class ConnectionHandler(object): try: s.bind(('', using)) return - except socket.error, why: + except socket.error as why: if why[0] == errno.EADDRINUSE: using += 1 if port < 1024 <= using:
rpc/rpclib.py +2 -2
@@ -33,7 +33,7 @@ class RPCDeniedReply(RPCFlowContol): else: # Something has gone haywire rreply = rejected_reply(AUTH_ERROR, astat=AUTH_FAILED) - except Exception, e: + except Exception as e: log.critical("Oops, encountered bug", exc_info=True) rreply = rejected_reply(AUTH_ERROR, astat=AUTH_FAILED) return reply_body(MSG_DENIED, rreply=rreply), ''
@@ -52,7 +52,7 @@ class RPCUnsuccessfulReply(RPCFlowContol): data = rpc_reply_data(self.stat) if self.stat == PROG_MISMATCH: data.mismatch_info = rpc_mismatch_info(*self.statdata) - except Exception, e: + except Exception as e: log.critical("Oops, encountered bug", exc_info=True) data = rpc_reply_data(SYSTEM_ERR) areply = accepted_reply(NULL_CRED, data)
rpc/security.py +4 -4
@@ -379,7 +379,7 @@ class AuthGss(AuthNone): else: # Can't get here, but doesn't hurt log_gss.error("Unknown service %i for RPCSEC_GSS" % cred.service) - except gssapi.Error, e: + except gssapi.Error as e: log_gss.warn("unsecure_data: gssapi call returned %s" % e.name) raise rpclib.RPCUnsuccessfulReply(GARBAGE_ARGS) return data
@@ -413,7 +413,7 @@ class AuthGss(AuthNone): else: # Can't get here, but doesn't hurt log_gss.error("Unknown service %i for RPCSEC_GSS" % cred.service) - except gssapi.Error, e: + except gssapi.Error as e: # XXX What now? log_gss.warn("secure_data: gssapi call returned %s" % e.name) raise
@@ -449,7 +449,7 @@ class AuthGss(AuthNone): data = self.partially_packed_header(xid, body) try: qop = self._get_context(body.cred.body.handle).verifyMIC(data, body.verf.body) - except gssapi.Error, e: + except gssapi.Error as e: log_gss.warn("Verifier checksum failed verification with %s" % e.name) return False
@@ -522,7 +522,7 @@ class AuthGss(AuthNone): context = self._get_context(cred.body.handle) try: token = context.accept(token) - except gssapi.Error, e: + except gssapi.Error as e: log_gss.debug("RPCSEC_GSS_INIT failed (%s, %i)!" % (e.name, e.minor)) res = rpc_gss_init_res('', e.major, e.minor, 0, '')
Signature · 1 line
2.17.1
PATCH 4/24 pynfs: python3 support plan: "raise E, args:" -> "raise E(args)"
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
'/raise / { :loop /[^\\]$/! {N; b loop};
s/\<raise *([[:alnum:]]+), *(.+)$/raise \1(\2)/; s/%sraise *([[:alnum:]]+), *([^"]+)\\n"/%sraise \1(\2)\\n"/; }'
--- nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py | 52 +++++++++++++-------------- nfs4.0/nfs4state.py | 28 +++++++-------- nfs4.1/config.py | 2 +- nfs4.1/nfs4state.py | 4 +-- xdr/xdrgen.py | 22 ++++++------ 5 files changed, 54 insertions(+), 54 deletions(-)
nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py +26 -26
@@ -127,8 +127,8 @@ class SecAuthGss(SecFlavor): self.gss_seq_num = 0 d = gssapi.importName("nfs@%s" % client.remotehost) if d['major'] != gssapi.GSS_S_COMPLETE: - raise SecError, "gssapi.importName returned: %s" % \ - show_major(d['major']) + raise SecError("gssapi.importName returned: %s" % \ + show_major(d['major'])) name = d['name'] # We need to send NULLPROCs with token from initSecContext good_major = [gssapi.GSS_S_COMPLETE, gssapi.GSS_S_CONTINUE_NEEDED]
@@ -141,11 +141,11 @@ class SecAuthGss(SecFlavor): major = d['major'] context = d['context'] if major not in good_major: - raise SecError, "gssapi.initSecContext returned: %s" % \ - show_major(major) + raise SecError("gssapi.initSecContext returned: %s" % \ + show_major(major)) if (major == gssapi.GSS_S_CONTINUE_NEEDED) and \ (reply_major == gssapi.GSS_S_COMPLETE): - raise SecError, "Unexpected GSS_S_COMPLETE from server" + raise SecError("Unexpected GSS_S_COMPLETE from server") token = d['token'] if reply_major != gssapi.GSS_S_COMPLETE: # FRED - sec 5.2.2 of RFC 2203 mentions possibility that
@@ -161,13 +161,13 @@ class SecAuthGss(SecFlavor): up.done() reply_major = res.gss_major if reply_major not in good_major: - raise SecError, "Server returned: %s" % \ - show_major(reply_major) + raise SecError("Server returned: %s" % \ + show_major(reply_major)) self.init = 2 reply_token = res.gss_token if major == gssapi.GSS_S_COMPLETE: if reply_major != gssapi.GSS_S_COMPLETE: - raise SecError, "Unexpected COMPLETE from client" + raise SecError("Unexpected COMPLETE from client") break self.gss_context = context self.gss_handle = res.handle
@@ -240,8 +240,8 @@ class SecAuthGss(SecFlavor): d = gssapi.getMIC(self.gss_context, data) major = d['major'] if major != gssapi.GSS_S_COMPLETE: - raise SecError, "gssapi.getMIC returned: %s" % \ - show_major(major) + raise SecError("gssapi.getMIC returned: %s" % \ + show_major(major)) return opaque_auth(RPCSEC_GSS, d['token']) def _make_cred_gss(self, handle, service, gss_proc=RPCSEC_GSS_DATA, seq=0):
@@ -266,8 +266,8 @@ class SecAuthGss(SecFlavor): data = p.get_buffer() + data d = gssapi.getMIC(self.gss_context, data) if d['major'] != gssapi.GSS_S_COMPLETE: - raise SecError, "gssapi.getMIC returned: %s" % \ - show_major(d['major']) + raise SecError("gssapi.getMIC returned: %s" % \ + show_major(d['major'])) p.reset() p.pack_opaque(data) p.pack_opaque(d['token'])
@@ -280,14 +280,14 @@ class SecAuthGss(SecFlavor): data = p.get_buffer() + data d = gssapi.wrap(self.gss_context, data) if d['major'] != gssapi.GSS_S_COMPLETE: - raise SecError, "gssapi.wrap returned: %s" % \ - show_major(d['major']) + raise SecError("gssapi.wrap returned: %s" % \ + show_major(d['major'])) p.reset() p.pack_opaque(d['msg']) data = p.get_buffer() else: # Not really necessary, should have already raised XDRError - raise SecError, "Unknown service %i for RPCSEC_GSS" % gss_cred.service + raise SecError("Unknown service %i for RPCSEC_GSS" % gss_cred.service) return data def unsecure_data(self, data, cred):
@@ -305,14 +305,14 @@ class SecAuthGss(SecFlavor): p.done() d = gssapi.verifyMIC(self.gss_context, data, checksum) if d['major'] != gssapi.GSS_S_COMPLETE: - raise SecError, "gssapi.verifyMIC returned: %s" % \ - show_major(d['major']) + raise SecError("gssapi.verifyMIC returned: %s" % \ + show_major(d['major'])) p.reset(data) seqnum = p.unpack_uint() if seqnum != gss_cred.seq_num: - raise SecError, \ + raise SecError(\ "Mismatched seqnum in reply: got %i, expected %i" % \ - (seqnum, gss_cred.seq_num) + (seqnum, gss_cred.seq_num)) data = p.get_buffer()[p.get_position():] elif gss_cred.service == rpc_gss_svc_privacy: # data = opaque[wrap([gss_seq_num+data])]
@@ -322,18 +322,18 @@ class SecAuthGss(SecFlavor): p.done() d = gssapi.unwrap(self.gss_context, data) if d['major'] != gssapi.GSS_S_COMPLETE: - raise SecError, "gssapi.unwrap returned %s" % \ - show_major(d['major']) + raise SecError("gssapi.unwrap returned %s" % \ + show_major(d['major'])) p.reset(d['msg']) seqnum = p.unpack_uint() if seqnum != gss_cred.seq_num: - raise SecError, \ + raise SecError(\ "Mismatched seqnum in reply: got %i, expected %i" % \ - (seqnum, self.gss_cred.seq_num) + (seqnum, self.gss_cred.seq_num)) data = p.get_buffer()[p.get_position():] else: # Not really necessary, should have already raised XDRError - raise SecError, "Unknown service %i for RPCSEC_GSS" % gss_cred.service + raise SecError("Unknown service %i for RPCSEC_GSS" % gss_cred.service) return data def _gss_cred_from_opaque_auth(self, auth):
@@ -361,8 +361,8 @@ class SecAuthGss(SecFlavor): p.pack_uint(i) d = gssapi.getMIC(self.gss_context, p.get_buffer()) if d['major'] != gssapi.GSS_S_COMPLETE: - raise SecError, "gssapi.getMIC returned: %s" % \ - show_major(d['major']) + raise SecError("gssapi.getMIC returned: %s" % \ + show_major(d['major'])) return opaque_auth(RPCSEC_GSS, d['token']) def check_verf(self, rverf, cred):
nfs4.0/nfs4state.py +14 -14
@@ -146,7 +146,7 @@ class NFSServerState: def addentry(self, entry): if not isinstance(entry, self.CacheEntry): - raise TypeError, "Bad entry: %s" % str(entry) + raise TypeError("Bad entry: %s" % str(entry)) if self.exists(x=entry.x) or self.exists(c=entry.c): raise "Bad Cache" self.list.append(entry)
@@ -200,7 +200,7 @@ class NFSServerState: elif isinstance(owner, lock_owner4): self.openid = openid else: - raise TypeError, "Passed in owner = %s" % str(owner) + raise TypeError("Passed in owner = %s" % str(owner)) # An owner is confirmed with OpenConfirm, a lock by sending stateid self.confirmed = False self.owner = owner
@@ -323,7 +323,7 @@ class NFSServerState: Conflict will raise NFS4Error. """ if not isinstance(owner, open_owner4): - raise TypeError, "Owner was given as %s" % str(owner) + raise TypeError("Owner was given as %s" % str(owner)) info = self.__getinfo(owner) if not info.confirmed: # Remove any pending open (RFC 3530 sec 14.2.18)
@@ -380,7 +380,7 @@ class NFSServerState: def __state2id(self, stateid, checkseq=False): """Translate nfs4 stateid to internal id""" if not isinstance(stateid, stateid4): - raise TypeError, "State was given as %s" % str(stateid) + raise TypeError("State was given as %s" % str(stateid)) # Check for special stateids if stateid.seqid==0 and stateid.other==chr(0)*12: return 0
@@ -407,11 +407,11 @@ class NFSServerState: info = self.__owner2info(owner, allownew) try: if fh is None: - raise ValueError, "File is None" + raise ValueError("File is None") return info.files[fh.handle] except KeyError: if not allownew: - raise ValueError, "File %s not open for %s" % (fh.name, info) + raise ValueError("File %s not open for %s" % (fh.name, info)) #print("Creating new id %i for fh %s" % (self.next_id, fh.handle)) id = info.files[fh.handle] = self.next_id self.next_id += 1
@@ -428,12 +428,12 @@ class NFSServerState: elif isinstance(owner, lock_owner4): ownerdict = self.lockowners else: - raise TypeError, "Gave owner as %s" % str(owner) + raise TypeError("Gave owner as %s" % str(owner)) self.__check_clientid(owner.clientid) try: info = ownerdict[owner.clientid][owner.owner] except KeyError: - if not allownew: raise ValueError, "Unknown owner %s" % str(owner) + if not allownew: raise ValueError("Unknown owner %s" % str(owner)) #print("Creating new info") info = self.OwnerInfo(owner) if owner.clientid in ownerdict:
@@ -694,8 +694,8 @@ class NFSFileState: self.start = start self.end = end if start < 0 or end < start: - raise ValueError, "Bad values for start and end (%s, %s)" % \ - (start, end) + raise ValueError("Bad values for start and end (%s, %s)" % \ + (start, end)) def __repr__(self): if self.type & 1: str = "READ"
@@ -1478,7 +1478,7 @@ class DirList: for x in self.list: if x.name == name: return x.fh - raise KeyError, "Invalid key %s" % name + raise KeyError("Invalid key %s" % name) def __setitem__(self, name, fh): """Allows self[name] = fh"""
@@ -1499,18 +1499,18 @@ class DirList: if x.name == name: self.list.remove(x) return - raise KeyError, "Invalid key %s" % name + raise KeyError("Invalid key %s" % name) def getcookie(self, name): for x in self.list: if x.name == name: return x.cookie - raise KeyError, "Invalid key %s" % name + raise KeyError("Invalid key %s" % name) def readdir(self, cookie): """Returns DirEnt list containing all entries larger than cookie""" if cookie < 0 or cookie > self.__lastcookie: - raise IndexError, "Invalid cookie %i" % cookie + raise IndexError("Invalid cookie %i" % cookie) i = None for x in self.list: if x.cookie > cookie:
nfs4.1/config.py +1 -1
@@ -56,7 +56,7 @@ def _opline(value): l = value else: print(' OPLINE type ', type(value)) - raise TypeError, 'Only type list or str accepted' + raise TypeError('Only type list or str accepted') if l[0] == "ERROR": if not len(l) == 3: print(' OPLINE length ', len)
nfs4.1/nfs4state.py +2 -2
@@ -99,8 +99,8 @@ class ByteLock(object): self.start = start self.end = end if start < 0 or end < start: - raise ValueError, "Bad values for start and end (%s, %s)" % \ - (start, end) + raise ValueError("Bad values for start and end (%s, %s)" % \ + (start, end)) def __repr__(self): str = ("WRITE" if self.iswrite else "READ")
xdr/xdrgen.py +11 -11
@@ -819,7 +819,7 @@ class Info(object): (prefix, self.id) if self.len is not None: limit = "%sif len(data) > %s:\n" \ - "%s%sraise XDRError, 'array length too long'\n" %\ + "%s%sraise XDRError('array length too long')\n" %\ (prefix, self.fullname(self.len), prefix, varindent) array = limit + array else:
@@ -846,7 +846,7 @@ class Info(object): (prefix, newdata, self.id) if self.len is not None: limit = "%sif len(%s) > %s:\n" \ - "%s%sraise XDRError, 'array length too long'\n" %\ + "%s%sraise XDRError('array length too long')\n" %\ (prefix, newdata, self.fullname(self.len), prefix, indent) array += limit newdata = 'data'
@@ -858,7 +858,7 @@ class Info(object): prefix, data, subheader, array = self._array_pack(prefix, data) varlist = ["const.%s" % l.id for l in self.body] check = "%sif self.check_enum and %s not in [%s]:\n" \ - "%s%sraise XDRError, 'value=%%s not in enum %s' %% %s\n" % \ + "%s%sraise XDRError('value=%%s not in enum %s' %% %s)\n" % \ (prefix, data, ', '.join(varlist), prefix, indent, self.id, data) pack = check + "%sself.pack_int(%s)\n" % (prefix, data)
@@ -868,7 +868,7 @@ class Info(object): prefix, data, subheader, array = self._array_unpack(prefix, data) varlist = ["const.%s" % l.id for l in self.body] check = "%sif self.check_enum and %s not in [%s]:\n" \ - "%s%sraise XDRError, 'value=%%s not in enum %s' %% %s\n" % \ + "%s%sraise XDRError('value=%%s not in enum %s' %% %s)\n" % \ (prefix, data, ', '.join(varlist), prefix, indent, self.id, data) unpack = "%s%s = self.unpack_int()\n" % (prefix, data)
@@ -908,7 +908,7 @@ class Info(object): if default != []: pack += default[0].packout(prefix + indent, data) else: - pack += "%s%sraise XDRError, 'bad switch=%%s' %% %s.%s\n" % \ + pack += "%s%sraise XDRError('bad switch=%%s' %% %s.%s)\n" % \ (prefix, indent, data, switch.id) return subheader + pack + array
@@ -950,7 +950,7 @@ class Info(object): ## (prefix, indent, data, data, default[0].id) ## unpack += arm else: - unpack += "%s%sraise XDRError, 'bad switch=%%s' %% %s.%s\n" % \ + unpack += "%s%sraise XDRError('bad switch=%%s' %% %s.%s)\n" % \ (prefix, indent, data, switch.id) return subheader + unpack + array
@@ -1220,7 +1220,7 @@ class type_info(Info): def packout(self, prefix='', data='data'): check = "%sif %s.%s is None:\n" \ - "%s%sraise TypeError, '%s.%s == None'\n" % \ + "%s%sraise TypeError('%s.%s == None')\n" % \ (prefix, data, self.id, prefix, indent, data, self.id) if self.type == 'void': return prefix + 'pass\n'
@@ -1279,8 +1279,8 @@ class type_info(Info): limit = '' else: limit = "%sif len(%s) > %s and self.check_array:\n" \ - "%s%sraise XDRError, " \ - "'array length too long for %s'\n" % \ + "%s%sraise XDRError(" \ + "'array length too long for %s')\n" % \ (prefix, data, self.fullname(self.len), prefix, indent, data) if self.fixed: fixchar = 'f'
@@ -1303,8 +1303,8 @@ class type_info(Info): limit = '' else: limit = "%sif len(%s) > %s and self.check_array:\n" \ - "%s%sraise XDRError, " \ - "'array length too long for %s'\n" % \ + "%s%sraise XDRError(" \ + "'array length too long for %s')\n" % \ (prefix, data, self.fullname(self.len), prefix, indent, data) if self.fixed: fixchar = 'f'
Signature · 1 line
2.17.1
PATCH 5/24 pynfs: python3 support plan: remove suffix 'L' of long integer
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
s/(0x[[:xdigit:]]+)L\>/\1/g
s/(\<[[:digit:]]+)L\>/\1/g
--- nfs4.0/lib/rpc/rpc.py | 14 +++++++------- nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py | 2 +- nfs4.0/nfs4lib.py | 8 ++++---- nfs4.0/nfs4server.py | 6 +++--- nfs4.0/nfs4state.py | 4 ++-- nfs4.0/servertests/environment.py | 2 +- nfs4.0/servertests/st_commit.py | 8 ++++---- nfs4.1/client41tests/environment.py | 2 +- nfs4.1/dataserver.py | 2 +- nfs4.1/fs.py | 2 +- nfs4.1/nfs4client.py | 2 +- nfs4.1/nfs4lib.py | 10 +++++----- nfs4.1/nfs4server.py | 4 ++-- nfs4.1/server41tests/environment.py | 4 ++-- nfs4.1/server41tests/st_debug.py | 2 +- nfs4.1/testmod.py | 2 +- rpc/rpc.py | 8 ++++---- 17 files changed, 41 insertions(+), 41 deletions(-)
nfs4.0/lib/rpc/rpc.py +7 -7
@@ -157,9 +157,9 @@ def _recv_record(self): while not last: rec_mark = self.recv_all(4) count = struct.unpack('>L', rec_mark)[0] - last = count & 0x80000000L + last = count & 0x80000000 if last: - count &= 0x7fffffffL + count &= 0x7fffffff data += self.recv_all(count) return data
@@ -171,7 +171,7 @@ def _send_record(self, data, chunksize=2048): chunk = data[i:i+chunksize] i += chunksize if i >= dlen: - last = 0x80000000L + last = 0x80000000 mark = struct.pack('>L', last | len(chunk)) self.sendall(mark + chunk)
@@ -202,7 +202,7 @@ class RPCClient(object): self._rpcunpacker = {t : rpc_pack.RPCUnpacker('')} self.default_prog = program self.default_vers = version - self.xid = 0L + self.xid = 0 self._xidlist = {} if sec_list is None: sec_list = [SecAuthNone()]
@@ -558,8 +558,8 @@ class RPCServer(Server): str = self.readbufs[fd] if len(str) >= 4: packetlen = struct.unpack('>L', str[0:4])[0] - last = 0x80000000L & packetlen - packetlen &= 0x7fffffffL + last = 0x80000000 & packetlen + packetlen &= 0x7fffffff if len(str) >= 4 + packetlen: self.packetbufs[fd].append(str[4:4 + packetlen]) self.readbufs[fd] = str[4 + packetlen:]
@@ -593,7 +593,7 @@ class RPCServer(Server): last = 0 self.recordbufs[fd][0] = data[chunksize:] else: - last = 0x80000000L + last = 0x80000000 del self.recordbufs[fd][0] mark = struct.pack('>L', last | len(chunk)) self.writebufs[fd] = (mark + chunk)
nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py +1 -1
@@ -72,7 +72,7 @@ def show_major(m): """Return string corresponding to major code""" if m == 0: return gss_major_codes[0] - call = m & 0xff000000L + call = m & 0xff000000 routine = m & 0xff0000 supp = m & 0xffff out = []
nfs4.0/nfs4lib.py +4 -4
@@ -93,7 +93,7 @@ class FancyNFS4Packer(nfs4_pack.NFS4Packer): def filter_bitmap4(self, data): out = [] while data: - out.append(data & 0xffffffffL) + out.append(data & 0xffffffff) data >>= 32 return out
@@ -108,7 +108,7 @@ class FancyNFS4Packer(nfs4_pack.NFS4Packer): class FancyNFS4Unpacker(nfs4_pack.NFS4Unpacker): def filter_bitmap4(self, data): """Put bitmap into single long, instead of array of 32bit chunks""" - out = 0L + out = 0 shift = 0 for i in data: out |= (long(i) << shift)
@@ -1006,9 +1006,9 @@ def fattr2dict(obj): def list2bitmap(list): """Construct a bitmap from a list of bit numbers""" - mask = 0L + mask = 0 for bit in list: - mask |= 1L << bit + mask |= 1 << bit return mask def bitmap2list(bitmap):
nfs4.0/nfs4server.py +3 -3
@@ -475,7 +475,7 @@ class NFS4Server(rpc.RPCServer): e = verify_name(filename) if e: raise NFS4Error(e) # At this point we know it is CLAIM_NULL with valid filename and cfh - attrset = 0L + attrset = 0 ci_old = self.curr_fh.fattr4_change if op.opopen.openhow.opentype == OPEN4_CREATE: print(" CREATING FILE.")
@@ -812,13 +812,13 @@ class NFS4Server(rpc.RPCServer): print(" CURRENT FILEHANDLE: %s" % repr(self.curr_fh)) print(op.opsetattr.obj_attributes) if not self.curr_fh: - return simple_error(NFS4ERR_NOFILEHANDLE, 0L) + return simple_error(NFS4ERR_NOFILEHANDLE, 0) try: attrdict = op.opsetattr.obj_attributes if FATTR4_SIZE in attrdict: # This counts as a write, so must do some checking if self.curr_fh.get_type() != NF4REG: - return simple_error(NFS4ERR_BAD_STATEID, 0L) + return simple_error(NFS4ERR_BAD_STATEID, 0) oldsize = self.curr_fh.fattr4_size newsize = attrdict[FATTR4_SIZE] if oldsize <= newsize:
nfs4.0/nfs4state.py +2 -2
@@ -26,7 +26,7 @@ POSIXLOCK = True # If True, allow locks to be split/joined automatically POSIXACL = True # If True, forces acls to follow posix mapping rules class NFS4Error(Exception): - def __init__(self, code, msg=None, attrs=0L, lock_denied=None): + def __init__(self, code, msg=None, attrs=0, lock_denied=None): self.code = code self.name = nfsstat4[code] if msg is None:
@@ -384,7 +384,7 @@ class NFSServerState: # Check for special stateids if stateid.seqid==0 and stateid.other==chr(0)*12: return 0 - if stateid.seqid==0xffffffffL and stateid.other==chr(0xff)*12: + if stateid.seqid==0xffffffff and stateid.other==chr(0xff)*12: return 1 # Check for self consistency if stateid.other[:4] != self.instance:
nfs4.0/servertests/environment.py +1 -1
@@ -119,7 +119,7 @@ class Environment(testmod.Environment): self.filedata = "This is the file test data." self.linkdata = "/etc/X11" self.stateid0 = stateid4(0, '') - self.stateid1 = stateid4(0xffffffffL, '\xff'*12) + self.stateid1 = stateid4(0xffffffff, '\xff'*12) def _get_security(self, opts): if opts.security == 'none':
nfs4.0/servertests/st_commit.py +4 -4
@@ -42,7 +42,7 @@ def testCommitOffsetMax1(t, env): DEPEND: MKFILE CODE: CMT1c """ - _commit(t, env.c1, 0xffffffffffffffffL, statlist=[NFS4_OK, NFS4ERR_INVAL]) + _commit(t, env.c1, 0xffffffffffffffff, statlist=[NFS4_OK, NFS4ERR_INVAL]) def testCommitOffsetMax2(t, env): """COMMIT
@@ -51,7 +51,7 @@ def testCommitOffsetMax2(t, env): DEPEND: MKFILE CODE: CMT1d """ - _commit(t, env.c1, 0xfffffffffffffffeL, statlist=[NFS4_OK, NFS4ERR_INVAL]) + _commit(t, env.c1, 0xfffffffffffffffe, statlist=[NFS4_OK, NFS4ERR_INVAL]) def testCommitCount1(t, env): """COMMIT
@@ -69,7 +69,7 @@ def testCommitCountMax(t, env): DEPEND: MKFILE CODE: CMT1f """ - _commit(t, env.c1, 0, 0xffffffffL) + _commit(t, env.c1, 0, 0xffffffff) def testLink(t, env): """COMMIT
@@ -159,5 +159,5 @@ def testCommitOverflow(t, env): fh, stateid = c.create_confirm(t.code) res = c.write_file(fh, _text, 0, stateid, how=UNSTABLE4) check(res, msg="WRITE with how=UNSTABLE4") - res = c.commit_file(fh, 0xfffffffffffffff0L, 64) + res = c.commit_file(fh, 0xfffffffffffffff0, 64) check(res, NFS4ERR_INVAL, "COMMIT with offset + count overflow")
nfs4.1/client41tests/environment.py +1 -1
@@ -373,7 +373,7 @@ def clean_dir(sess, path): res = sess.compound(ops) check(res, msg="Trying to remove %s" % repr(e.name)) -def do_readdir(sess, file, cookie=0, cookieverf='', attrs=0L, +def do_readdir(sess, file, cookie=0, cookieverf='', attrs=0, dircount=4096, maxcount=4096): # Since we may not get whole directory listing in one readdir request, # loop until we do. For each request result, create a flat list
nfs4.1/dataserver.py +1 -1
@@ -206,7 +206,7 @@ class DataServer41(DataServer): def get_size(self, fh): ops = [op4.putfh(fh), - op4.getattr(1L << const4.FATTR4_SIZE)] + op4.getattr(1 << const4.FATTR4_SIZE)] res = self._execute(ops) attrdict = res.resarray[-1].obj_attributes return attrdict.get(const4.FATTR4_SIZE, 0)
nfs4.1/fs.py +1 -1
@@ -306,7 +306,7 @@ class FSObject(object): # STUB - need to check principal, and set owner/group if needed log_o.log(5, "FSObject.set_attrs(%r)" % attrs) info = nfs4lib.attr_info - bitmap = 0L + bitmap = 0 try: for attr in attrs: if self.fs.fattr4_supported_attrs & attr == 0:
nfs4.1/nfs4client.py +1 -1
@@ -611,7 +611,7 @@ sha256 = '`\x86H\x01e\x03\x04\x02\x01' binding_opts = conn_binding4args(True, ["gibberish", sha256]) fore_attrs = channel_attrs4(4096,4096,4096,128,8,[]) cb_sec= callback_sec_parms4(0) -C.compound([C.create_session_op(0,1,0L,0,binding_opts, fore_attrs, fore_attrs,123,[cb_sec])]) +C.compound([C.create_session_op(0,1,0,0,binding_opts, fore_attrs, fore_attrs,123,[cb_sec])]) """ """ SEQUENCE
nfs4.1/nfs4lib.py +5 -5
@@ -194,7 +194,7 @@ class FancyNFS4Packer(NFS4Packer): def filter_bitmap4(self, data): out = [] while data: - out.append(data & 0xffffffffL) + out.append(data & 0xffffffff) data >>= 32 return out
@@ -217,7 +217,7 @@ class FancyNFS4Packer(NFS4Packer): class FancyNFS4Unpacker(NFS4Unpacker): def filter_bitmap4(self, data): """Put bitmap into single long, instead of array of 32bit chunks""" - out = 0L + out = 0 shift = 0 for i in data: out |= (long(i) << shift)
@@ -276,9 +276,9 @@ def fattr2dict(obj): def list2bitmap(list): """Construct a bitmap from a list of bit numbers""" - mask = 0L + mask = 0 for bit in list: - mask |= 1L << bit + mask |= 1 << bit return mask def bitmap2list(bitmap):
@@ -565,7 +565,7 @@ def attr_name(bitnum): return bitnum2attr.get(bitnum, "unknown_%r" % bitnum) class NFS4Error(Exception): - def __init__(self, status, attrs=0L, lock_denied=None, tag=None, check_msg=None): + def __init__(self, status, attrs=0, lock_denied=None, tag=None, check_msg=None): self.status = status self.name = xdrdef.nfs4_const.nfsstat4[status] if check_msg is None:
nfs4.1/nfs4server.py +2 -2
@@ -212,7 +212,7 @@ class ClientList(object): def __init__(self): self._data = {} self.lock = Lock("ClientList") - self._nextid = 0L + self._nextid = 0 def __getitem__(self, key): return self._data.get(key)
@@ -1381,7 +1381,7 @@ class NFS4Server(rpc.Server): def open_claim_null(self, arg, env): """Simulated switch function from op_open that handles CLAIM_NULL""" - bitmask = 0L + bitmask = 0 # cfh holds dir, claim.file holds name if not env.cfh.isdir: raise NFS4Error(NFS4ERR_NOTDIR)
nfs4.1/server41tests/environment.py +2 -2
@@ -139,7 +139,7 @@ class Environment(testmod.Environment): self.filedata = "This is the file test data." self.linkdata = "/etc/X11" self.stateid0 = stateid4(0, '') - self.stateid1 = stateid4(0xffffffffL, '\xff'*12) + self.stateid1 = stateid4(0xffffffff, '\xff'*12) log.info("Created client to %s, %i" % (opts.server, opts.port))
@@ -429,7 +429,7 @@ def clean_dir(sess, path): res = sess.compound(ops) check(res, msg="Trying to remove %s" % repr(e.name)) -def do_readdir(sess, file, cookie=0, cookieverf='', attrs=0L, +def do_readdir(sess, file, cookie=0, cookieverf='', attrs=0, dircount=4096, maxcount=4096): # Since we may not get whole directory listing in one readdir request, # loop until we do. For each request result, create a flat list
nfs4.1/server41tests/st_debug.py +1 -1
@@ -89,7 +89,7 @@ def testDeadlock(t, env): def ops(i): return [op.putfh(fh), op.write(stateid, i*1000, UNSTABLE4, chr(97+i)*100), - op.getattr(42950721818L) + op.getattr(42950721818) ] xids = [sess1.compound_async(ops(i), slot=i) for i in range(4)] for xid in xids:
nfs4.1/testmod.py +1 -1
@@ -374,7 +374,7 @@ def createtests(testdir): # Reduce doc string info into format easier to work with used_codes = {} flag_dict = {} - bit = 1L + bit = 1 for t in tests: ## if not t.flags_list: ## raise RuntimeError("%s has no flags" % t.fullname)
rpc/rpc.py +4 -4
@@ -265,8 +265,8 @@ class Pipe(object): # We don't even have the packet length yet, wait for more data break packetlen = struct.unpack('>L', buf[0:4])[0] - last = 0x80000000L & packetlen - packetlen &= 0x7fffffffL + last = 0x80000000 & packetlen + packetlen &= 0x7fffffff packetlen += 4 # Include size of record mark if len(buf) < packetlen: # We don't have a full packet yet, wait for more data
@@ -310,7 +310,7 @@ class Pipe(object): chunk = record[i: i + count] i += count if i >= dlen: - last = 0x80000000L + last = 0x80000000 mark = struct.pack('>L', last | len(chunk)) out += mark + chunk return out
@@ -351,7 +351,7 @@ class RpcPipe(Pipe): Pipe.__init__(self, *args, **kwargs) self._pending = {} # {xid:defer} self._lock = threading.Lock() # Protects fields below - self._xid = random.randint(0, 0x7fffffffL) + self._xid = random.randint(0, 0x7fffffff) self.set_active() def _get_xid(self):
Signature · 1 line
2.17.1
PATCH 6/24 pynfs: python3 support plan: octal literal 0644 -> 0o644
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
s/\<0([0-9]{3})\>/0o\1/g
s/\<0([0-9]{2})\>/0o\1/g
--- nfs4.0/nfs4acl.py | 8 ++++---- nfs4.0/nfs4lib.py | 10 +++++----- nfs4.0/nfs4state.py | 4 ++-- nfs4.0/servertests/st_close.py | 4 ++-- nfs4.0/servertests/st_create.py | 2 +- nfs4.0/servertests/st_delegation.py | 2 +- nfs4.0/servertests/st_lock.py | 2 +- nfs4.0/servertests/st_locku.py | 2 +- nfs4.0/servertests/st_lookup.py | 10 +++++----- nfs4.0/servertests/st_open.py | 18 +++++++++--------- nfs4.0/servertests/st_read.py | 4 ++-- nfs4.0/servertests/st_readdir.py | 8 ++++---- nfs4.0/servertests/st_reboot.py | 4 ++-- nfs4.0/servertests/st_setattr.py | 18 +++++++++--------- nfs4.0/servertests/st_write.py | 16 ++++++++-------- nfs4.1/client41tests/environment.py | 8 ++++---- nfs4.1/dataserver.py | 6 +++--- nfs4.1/fs.py | 2 +- nfs4.1/nfs4client.py | 2 +- nfs4.1/server41tests/environment.py | 14 +++++++------- nfs4.1/server41tests/st_lookup.py | 4 ++-- 21 files changed, 74 insertions(+), 74 deletions(-)
nfs4.0/nfs4acl.py +4 -4
@@ -66,9 +66,9 @@ def mode2acl(mode, dir=False): """Translate a 3-digit octal mode into a posix compatible acl""" if dir: modes = DMODES else: modes = MODES - owner = modes[(mode & 0700)//0100] | FLAG_ALL | FLAG_OWN - group = modes[(mode & 0070)//010] | FLAG_ALL - other = modes[(mode & 0007)] | FLAG_ALL + owner = modes[(mode & 0o700)//0o100] | FLAG_ALL | FLAG_OWN + group = modes[(mode & 0o070)//0o10] | FLAG_ALL + other = modes[(mode & 0o007)] | FLAG_ALL return [ nfsace4(ALLOWED, 0, owner, "OWNER@"), nfsace4(DENIED, 0, negate(owner), "OWNER@"),
@@ -102,7 +102,7 @@ def acl2mode(acl): for key in perms: if perms[key] is None: perm[keys] = 0 - return perms["OWNER@"]*0100 + perms["GROUP@"]*010 + perms["EVERYONE@"] + return perms["OWNER@"]*0o100 + perms["GROUP@"]*0o10 + perms["EVERYONE@"] def maps_to_posix(acl): """Raises ACLError if acl does not map to posix """
nfs4.0/nfs4lib.py +5 -5
@@ -463,7 +463,7 @@ class NFS4Client(rpc.RPCClient): return self.compound(ops) def open(self, owner, name=None, type=OPEN4_NOCREATE, - mode=UNCHECKED4, attrs={FATTR4_MODE:0644}, verf=None, + mode=UNCHECKED4, attrs={FATTR4_MODE:0o644}, verf=None, access=OPEN4_SHARE_ACCESS_READ, deny=OPEN4_SHARE_DENY_WRITE, claim_type=CLAIM_NULL, deleg_type=None, deleg_cur_info=None):
@@ -568,7 +568,7 @@ class NFS4Client(rpc.RPCClient): for e in entries: # We separate setattr and remove to avoid an inode locking bug ops = [op4.putfh(fh), op4.lookup(e.name)] - ops += [op4.setattr(stateid, {FATTR4_MODE:0755})] + ops += [op4.setattr(stateid, {FATTR4_MODE:0o755})] res = self.compound(ops) check_result(res, "Making sure %s is writable" % repr(e.name)) ops = [op4.putfh(fh), op4.remove(e.name)]
@@ -589,7 +589,7 @@ class NFS4Client(rpc.RPCClient): d = self.do_getattrdict([], [FATTR4_LEASE_TIME]) return d[FATTR4_LEASE_TIME] - def create_obj(self, path, type=NF4DIR, attrs={FATTR4_MODE:0755}, + def create_obj(self, path, type=NF4DIR, attrs={FATTR4_MODE:0o755}, linkdata="/etc/X11"): if __builtins__['type'](path) is str: path = self.homedir + [path]
@@ -613,7 +613,7 @@ class NFS4Client(rpc.RPCClient): ops += [op4.rename(oldpath[-1], newpath[-1])] return self.compound(ops) - def create_file(self, owner, path=None, attrs={FATTR4_MODE: 0644}, + def create_file(self, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_WRITE, mode=UNCHECKED4, verifier=None,
@@ -702,7 +702,7 @@ class NFS4Client(rpc.RPCClient): return (fhandle, stateid) - def create_confirm(self, owner, path=None, attrs={FATTR4_MODE: 0644}, + def create_confirm(self, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_WRITE, mode=GUARDED4):
nfs4.0/nfs4state.py +2 -2
@@ -953,7 +953,7 @@ class VirtualHandle(NFSFileHandle): if self.fattr4_type == NF4DIR: self.dirent = DirList() - self.fattr4_mode = 0755 + self.fattr4_mode = 0o755 if self.fattr4_type == NF4REG: self.file = StringIO.StringIO() self.state = NFSFileState()
@@ -987,7 +987,7 @@ class VirtualHandle(NFSFileHandle): self.fattr4_maxname = 128 # Are these enforced? self.fattr4_maxread = 1000 # Are these enforced? self.fattr4_maxwrite = 1000 # Are these enforced? - self.fattr4_mode = 0644 # Currently no access restrictions enforced + self.fattr4_mode = 0o644 # Currently no access restrictions enforced self.fattr4_acl = nfs4acl.mode2acl(self.fattr4_mode, self.fattr4_type == NF4DIR) self.fattr4_numlinks = 1 # Updated? - Yes
nfs4.0/servertests/st_close.py +2 -2
@@ -110,7 +110,7 @@ def testTimedoutClose1(t, env): sleeptime = c.getLeaseTime() * 2 c.init_connection() fh, stateid = c.create_confirm(t.code, deny=OPEN4_SHARE_DENY_WRITE, - attrs={FATTR4_MODE: 0666}) + attrs={FATTR4_MODE: 0o666}) env.sleep(sleeptime) # Conflicting open should force server to drop state c2 = env.c2
@@ -132,7 +132,7 @@ def testTimedoutClose2(t, env): sleeptime = c.getLeaseTime() * 2 c.init_connection() fh, stateid = c.create_confirm(t.code, deny=OPEN4_SHARE_DENY_WRITE, - attrs={FATTR4_MODE: 0666}) + attrs={FATTR4_MODE: 0o666}) res = c.lock_file(t.code, fh, stateid) check(res) env.sleep(sleeptime)
nfs4.0/servertests/st_create.py +1 -1
@@ -8,7 +8,7 @@ def getDefaultAttr(c): attr = {} #attr[FATTR4_OWNER] = c.security.get_owner() #attr[FATTR4_OWNER_GROUP] = c.security.get_group() - attr[FATTR4_MODE] = 0755 + attr[FATTR4_MODE] = 0o755 return attr def _test_create(t, env, type, name, **keywords):
nfs4.0/servertests/st_delegation.py +1 -1
@@ -706,7 +706,7 @@ def testServerChmod(t, env): c.init_connection('pynfs%i_%s' % (os.getpid(), t.code), cb_ident=0) c.create_confirm(t.code, path=c.homedir + [t.code + '-2']) _get_deleg(t, c, c.homedir + [t.code], _recall, NFS4_OK) - env.serverhelper("chmod 0777 " + _listToPath(c.homedir + [t.code])) + env.serverhelper("chmod 0o777 " + _listToPath(c.homedir + [t.code])) _verify_cb_occurred(t, c, count) def testServerSelfConflict(t, env):
nfs4.0/servertests/st_lock.py +1 -1
@@ -529,7 +529,7 @@ def testReadLocks2(t, env): file = c1.homedir + [t.code] # Client1 creates a file fh1, stateid1 = c1.create_confirm('owner1', file, - attrs={FATTR4_MODE: 0666}, + attrs={FATTR4_MODE: 0o666}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE) # Client2 opens the file
nfs4.0/servertests/st_locku.py +1 -1
@@ -256,7 +256,7 @@ def testTimedoutUnlock(t, env): c = env.c1 sleeptime = c.getLeaseTime() * 3 // 2 c.init_connection() - fh, stateid = c.create_confirm(t.code, attrs={FATTR4_MODE: 0666}) + fh, stateid = c.create_confirm(t.code, attrs={FATTR4_MODE: 0o666}) res1 = c.lock_file(t.code, fh, stateid) check(res1) env.sleep(sleeptime)
nfs4.0/servertests/st_lookup.py +5 -5
@@ -206,7 +206,7 @@ def testNonAccessable(t, env): DEPEND: MKDIR CODE: LOOK6 """ - # Create dir/foo, and set mode of dir to 000 + # Create dir/foo, and set mode of dir to 0o000 c = env.c1 dir = c.homedir + [t.code] res = c.create_obj(dir)
@@ -220,9 +220,9 @@ def testNonAccessable(t, env): check(res) res = c.compound(c.use_obj(dir + ['foo'])) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP object in a dir with mode=000") + check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP object in a dir with mode=0o000") else: - check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=000") + check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=0o000") def testInvalidUtf8(t, env): """LOOKUP with bad UTF-8 name strings should return NFS4ERR_INVAL
@@ -283,9 +283,9 @@ def testUnaccessibleDir(t, env): check(res, msg="Setting mode=0 on directory %s" % t.code) res = c.compound(c.use_obj(path + ['hidden'])) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP off of dir with mode=000") + check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP off of dir with mode=0o000") else: - check(res, NFS4ERR_ACCESS, "LOOKUP off of dir with mode=000") + check(res, NFS4ERR_ACCESS, "LOOKUP off of dir with mode=0o000") def testBadOpaque(t, env): """LOOKUP with a path component that has an incorrect array length
nfs4.0/servertests/st_open.py +9 -9
@@ -25,7 +25,7 @@ def testCreateUncheckedFile(t, env): c.init_connection() # Create the file - orig_attrs = { FATTR4_MODE: 0644, FATTR4_SIZE: 32 } + orig_attrs = { FATTR4_MODE: 0o644, FATTR4_SIZE: 32 } res = c.create_file(t.code, attrs=orig_attrs, deny=OPEN4_SHARE_DENY_NONE) check(res, msg="Trying to create file %s" % t.code) fh, stateid = c.confirm(t.code, res)
@@ -33,7 +33,7 @@ def testCreateUncheckedFile(t, env): checkdict(orig_attrs, rcvd_attrs, get_bitnumattr_dict(), "Checking attrs on creation") # Create the file again...it should ignore attrs - attrs = { FATTR4_MODE: 0600, FATTR4_SIZE: 16 } + attrs = { FATTR4_MODE: 0o600, FATTR4_SIZE: 16 } res = c.create_file(t.code, attrs=attrs, deny=OPEN4_SHARE_DENY_NONE) check(res, msg="Trying to recreate file %s" % t.code) fh, stateid = c.confirm(t.code, res)
@@ -41,12 +41,12 @@ def testCreateUncheckedFile(t, env): checkdict(orig_attrs, rcvd_attrs, get_bitnumattr_dict(), "Attrs on recreate should be ignored") # Create the file again, should truncate size to 0 and ignore other attrs - attrs = { FATTR4_MODE: 0600, FATTR4_SIZE: 0 } + attrs = { FATTR4_MODE: 0o600, FATTR4_SIZE: 0 } res = c.create_file(t.code, attrs=attrs, deny=OPEN4_SHARE_DENY_NONE) check(res, msg="Trying to truncate file %s" % t.code) fh, stateid = c.confirm(t.code, res) rcvd_attrs = c.do_getattrdict(fh, orig_attrs.keys()) - expect = { FATTR4_MODE: 0644, FATTR4_SIZE: 0 } + expect = { FATTR4_MODE: 0o644, FATTR4_SIZE: 0 } checkdict(expect, rcvd_attrs, get_bitnumattr_dict(), "Attrs on recreate should be ignored, except for size")
@@ -327,13 +327,13 @@ def testModeChange(t, env): check(res) ops = c.use_obj(fh) + [c.setattr({FATTR4_MODE:0})] res = c.compound(ops) - check(res, msg="Setting mode of file %s to 000" % t.code) + check(res, msg="Setting mode of file %s to 0o000" % t.code) res = c.open_file(t.code, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "Opening file %s with mode=000" % t.code) + check(res, [NFS4_OK, NFS4ERR_ACCESS], "Opening file %s with mode=0o000" % t.code) else: - check(res, NFS4ERR_ACCESS, "Opening file %s with mode=000" % t.code) + check(res, NFS4ERR_ACCESS, "Opening file %s with mode=0o000" % t.code) def testShareConflict1(t, env): """OPEN conflicting with previous share
@@ -361,13 +361,13 @@ def testFailedOpen(t, env): c1.init_connection() # Client 1: create a file and deny others access fh, stateid = c1.create_confirm(t.code) - ops = c1.use_obj(fh) + [c1.setattr({FATTR4_MODE: 0700})] + ops = c1.use_obj(fh) + [c1.setattr({FATTR4_MODE: 0o700})] check(c1.compound(ops)) # Client 2: try to open the file c2 = env.c2 c2.init_connection() res = c2.open_file(t.code) - check(res, NFS4ERR_ACCESS, "Opening file with mode 0700 as 'other'") + check(res, NFS4ERR_ACCESS, "Opening file with mode 0o700 as 'other'") # Client 1: try to use fh, stateid res1 = c1.lock_file(t.code, fh, stateid) check(res1, msg="Locking file after another client had a failed open")
nfs4.0/servertests/st_read.py +2 -2
@@ -74,7 +74,7 @@ def testLargeCount(t, env): c = env.c1 c.init_connection() fh, stateid = c.create_confirm(t.code, attrs={FATTR4_SIZE: 10000000, - FATTR4_MODE: 0644}) + FATTR4_MODE: 0o644}) res = c.read_file(fh, 0, 9000000, stateid) check(res, msg="Reading file %s" % t.code) _compare(t, res, '\x00'*9000000, False)
@@ -234,7 +234,7 @@ def testStolenStateid(t, env): """ c = env.c1 c.init_connection() - res = c.create_file(t.code, attrs={FATTR4_MODE: 0600}) + res = c.create_file(t.code, attrs={FATTR4_MODE: 0o600}) fh, stateid = c.confirm(t.code, res) security=c.security c.security=rpc.SecAuthSys(0, "whatever", 3912, 2422, [])
nfs4.0/servertests/st_readdir.py +4 -4
@@ -232,9 +232,9 @@ def testUnaccessibleDir(t, env): ops = c.use_obj(path) + [c.readdir()] res = c.compound(ops) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=000") + check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=0o000") else: - check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=000") + check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=0o000") def testUnaccessibleDirAttrs(t, env): """READDIR with (cfh) in unaccessible directory requesting attrs
@@ -253,9 +253,9 @@ def testUnaccessibleDirAttrs(t, env): [c.readdir(attr_request=[FATTR4_RDATTR_ERROR, FATTR4_TYPE])] res = c.compound(ops) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=000") + check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=0o000") else: - check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=000") + check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=0o000") ###########################################
nfs4.0/servertests/st_reboot.py +2 -2
@@ -116,7 +116,7 @@ def testEdge1(t, env): c1 = env.c1 c1.init_connection() # Client 1: lock file - fh1, stateid1 = c1.create_confirm(t.code, attrs={FATTR4_MODE:0666}, + fh1, stateid1 = c1.create_confirm(t.code, attrs={FATTR4_MODE:0o666}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE) res1 = c1.lock_file(t.code, fh1, stateid1)
@@ -161,7 +161,7 @@ def testEdge2(t, env): c1 = env.c1 c1.init_connection() # Client 1: lock file - fh1, stateid1 = c1.create_confirm(t.code, attrs={FATTR4_MODE:0666}, + fh1, stateid1 = c1.create_confirm(t.code, attrs={FATTR4_MODE:0o666}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE) res1 = c1.lock_file(t.code, fh1, stateid1)
nfs4.0/servertests/st_setattr.py +9 -9
@@ -7,7 +7,7 @@ op = nfs_ops.NFS4ops() def _set_mode(t, c, file, stateid=None, msg=" using stateid=0", warnlist=[]): - mode = 0740 + mode = 0o740 dict = {FATTR4_MODE: mode} ops = c.use_obj(file) + [c.setattr(dict, stateid)] res = c.compound(ops)
@@ -399,7 +399,7 @@ def testInvalidAttr1(t, env): path = c.homedir + [t.code] res = c.create_obj(path) check(res) - badattr = dict2fattr({FATTR4_MODE: 0644}) + badattr = dict2fattr({FATTR4_MODE: 0o644}) badattr.attr_vals = '' res = c.compound(c.use_obj(path) + [op.setattr(env.stateid0, badattr)]) check(res, NFS4ERR_BADXDR, "SETATTR(FATTR4_MODE) with no data")
@@ -418,7 +418,7 @@ def testInvalidAttr2(t, env): path = c.homedir + [t.code] res = c.create_obj(path) check(res) - badattr = dict2fattr({FATTR4_MODE: 0644}) + badattr = dict2fattr({FATTR4_MODE: 0o644}) badattr.attr_vals += 'Garbage data' res = c.compound(c.use_obj(path) + [op.setattr(env.stateid0, badattr)]) check(res, NFS4ERR_BADXDR,
@@ -674,7 +674,7 @@ def testInodeLocking(t, env): # In a single compound statement, setattr on dir and then # do a state operation on a file in dir (like write or remove) - ops = c.use_obj(basedir) + [c.setattr({FATTR4_MODE:0754})] + ops = c.use_obj(basedir) + [c.setattr({FATTR4_MODE:0o754})] ops += [op.lookup('file'), op.write(stateid, 0, 0, 'blahblah')] res = c.compound(ops) check(res, msg="SETATTR on dir and state operation on file in dir")
@@ -690,7 +690,7 @@ def testChange(t, env): c.init_connection() fh, stateid = c.create_confirm(t.code) change = c.do_getattr(FATTR4_CHANGE, fh) - ops = c.use_obj(fh) + [c.setattr({FATTR4_MODE: 0740})] + ops = c.use_obj(fh) + [c.setattr({FATTR4_MODE: 0o740})] res = c.compound(ops) check(res) change2 = c.do_getattr(FATTR4_CHANGE, fh)
@@ -708,10 +708,10 @@ def testChangeGranularity(t, env): c.init_connection() fh, stateid = c.create_confirm(t.code) ops = c.use_obj(fh) + [c.getattr([FATTR4_CHANGE])] \ - + [c.setattr({FATTR4_MODE: 0740})] + [c.getattr([FATTR4_CHANGE])] \ - + [c.setattr({FATTR4_MODE: 0741})] + [c.getattr([FATTR4_CHANGE])] \ - + [c.setattr({FATTR4_MODE: 0742})] + [c.getattr([FATTR4_CHANGE])] \ - + [c.setattr({FATTR4_MODE: 0743})] + [c.getattr([FATTR4_CHANGE])] + + [c.setattr({FATTR4_MODE: 0o740})] + [c.getattr([FATTR4_CHANGE])] \ + + [c.setattr({FATTR4_MODE: 0o741})] + [c.getattr([FATTR4_CHANGE])] \ + + [c.setattr({FATTR4_MODE: 0o742})] + [c.getattr([FATTR4_CHANGE])] \ + + [c.setattr({FATTR4_MODE: 0o743})] + [c.getattr([FATTR4_CHANGE])] res = c.compound(ops) check(res) chattr1 = res.resarray[1].obj_attributes
nfs4.0/servertests/st_write.py +8 -8
@@ -38,7 +38,7 @@ def testSimpleWrite(t, env): """ c = env.c1 c.init_connection() - attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644} + attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644} fh, stateid = c.create_confirm(t.code, attrs=attrs, deny=OPEN4_SHARE_DENY_NONE) res = c.write_file(fh, _text, how=UNSTABLE4)
@@ -55,7 +55,7 @@ def testSimpleWrite2(t, env): """ c = env.c1 c.init_connection() - attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644} + attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644} fh, stateid = c.create_confirm(t.code, attrs=attrs, deny=OPEN4_SHARE_DENY_NONE) res = c.write_file(fh, _text, 30)
@@ -72,7 +72,7 @@ def testStateidOne(t, env): """ c = env.c1 c.init_connection() - attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644} + attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644} fh, stateid = c.create_confirm(t.code, attrs=attrs, deny=OPEN4_SHARE_DENY_NONE) res = c.write_file(fh, _text, 5, env.stateid1, DATA_SYNC4)
@@ -91,7 +91,7 @@ def testWithOpen(t, env): """ c = env.c1 c.init_connection() - attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644} + attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644} fh, stateid = c.create_confirm(t.code, attrs=attrs) res = c.write_file(fh, _text, 50, stateid, FILE_SYNC4) check(res, msg="WRITE with openstateid and FILE_SYNC4")
@@ -109,7 +109,7 @@ def testNoData(t, env): """ c = env.c1 c.init_connection() - attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644} + attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644} fh, stateid = c.create_confirm(t.code, attrs=attrs) time_prior = c.do_getattr(FATTR4_TIME_MODIFY, fh) env.sleep(1)
@@ -281,7 +281,7 @@ def testOpenMode(t, env): """ c = env.c1 c.init_connection() - attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644} + attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644} fh, stateid = c.create_confirm(t.code, attrs=attrs, access=OPEN4_SHARE_ACCESS_READ) res = c.write_file(fh, _text, 0, stateid)
@@ -298,7 +298,7 @@ def testShareDeny(t, env): """ c = env.c1 c.init_connection() - attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644} + attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644} fh, stateid = c.create_confirm(t.code, attrs=attrs, deny=OPEN4_SHARE_DENY_WRITE) res = c.write_file(fh, _text)
@@ -520,7 +520,7 @@ def testStolenStateid(t, env): """ c = env.c1 c.init_connection() - res = c.create_file(t.code, attrs={FATTR4_MODE: 0600}) + res = c.create_file(t.code, attrs={FATTR4_MODE: 0o600}) fh, stateid = c.confirm(t.code, res) security=c.security c.security=rpc.SecAuthSys(0, "whatever", 3912, 2422, [])
nfs4.1/client41tests/environment.py +4 -4
@@ -362,7 +362,7 @@ def clean_dir(sess, path): for e in entries: # We separate setattr and remove to avoid an inode locking bug ops = use_obj(path + [e.name]) - ops += [op.setattr(stateid, {FATTR4_MODE:0755})] + ops += [op.setattr(stateid, {FATTR4_MODE:0o755})] res = sess.compound(ops) check(res, msg="Setting mode on %s" % repr(e.name)) ops = use_obj(path)
@@ -405,7 +405,7 @@ def use_obj(file): else: return [op.putrootfh()] + [op.lookup(comp) for comp in file] -def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0755}): +def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0o755}): """Return ops needed to create given non-file object""" # Ensure using createtype4 if not hasattr(kind, "type"):
@@ -413,7 +413,7 @@ def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0755}): ops = use_obj(path[:-1]) + [op.create(kind, path[-1], attrs)] return sess.compound(ops) -def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, +def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE, mode=GUARDED4, verifier=None, want_deleg=False):
@@ -434,7 +434,7 @@ def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, open_claim4(CLAIM_NULL, name)) return sess.compound(use_obj(dir) + [open_op, op.getfh()]) -def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, +def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE, mode=GUARDED4):
nfs4.1/dataserver.py +3 -3
@@ -130,7 +130,7 @@ class DataServer41(DataServer): self.sess.compound([op4.reclaim_complete(const4.FALSE)]) def make_root(self): - attrs = {const4.FATTR4_MODE:0777} + attrs = {const4.FATTR4_MODE:0o777} existing_path = [] kind = type4.createtype4(const4.NF4DIR) for comp in self.path:
@@ -153,7 +153,7 @@ class DataServer41(DataServer): seqid=0 access = const4.OPEN4_SHARE_ACCESS_BOTH deny = const4.OPEN4_SHARE_DENY_NONE - attrs = {const4.FATTR4_MODE: 0777} + attrs = {const4.FATTR4_MODE: 0o777} owner = "mds" mode = const4.GUARDED4 verifier = self.sess.c.verifier
@@ -257,7 +257,7 @@ class DataServer3(DataServer): def open_file(self, mds_fh): name = self.fh_to_name(mds_fh) where = type3.diropargs3(self.rootfh, name) - attr = type3.sattr3(mode=type3.set_mode3(True, 0777), + attr = type3.sattr3(mode=type3.set_mode3(True, 0o777), uid=type3.set_uid3(True, 0), gid=type3.set_gid3(True, 0), size=type3.set_size3(False),
nfs4.1/fs.py +1 -1
@@ -25,7 +25,7 @@ class MetaData(object): self.refcnt = 0 self.createverf = "" self.owner = "" - self.mode = 0777 + self.mode = 0o777 self.time_access = self.time_modify = self.time_create = nfs4lib.get_nfstime() if 1: self.parent = 0
nfs4.1/nfs4client.py +1 -1
@@ -560,7 +560,7 @@ class SessionRecord(object): return res ## def open(self, owner, name=None, type=OPEN4_NOCREATE, -## mode=UNCHECKED4, attrs={FATTR4_MODE:0644}, verf=None, +## mode=UNCHECKED4, attrs={FATTR4_MODE:0o644}, verf=None, ## access=OPEN4_SHARE_ACCESS_READ, ## deny=OPEN4_SHARE_DENY_WRITE, ## claim_type=CLAIM_NULL, deleg_type=None, deleg_cur_info=None):
nfs4.1/server41tests/environment.py +7 -7
@@ -418,7 +418,7 @@ def clean_dir(sess, path): for e in entries: # We separate setattr and remove to avoid an inode locking bug ops = use_obj(path + [e.name]) - ops += [op.setattr(stateid, {FATTR4_MODE:0755})] + ops += [op.setattr(stateid, {FATTR4_MODE:0o755})] res = sess.compound(ops) check(res, msg="Setting mode on %s" % repr(e.name)) ops = use_obj(path)
@@ -460,7 +460,7 @@ def do_getattrdict(sess, file, attrlist): check(res) return res.resarray[-1].obj_attributes -def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0755}): +def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0o755}): """Return ops needed to create given non-file object""" # Ensure using createtype4 if not hasattr(kind, "type"):
@@ -468,7 +468,7 @@ def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0755}): ops = use_obj(path[:-1]) + [op.create(kind, path[-1], attrs)] return sess.compound(ops) -def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, +def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE, mode=GUARDED4, verifier=None,
@@ -483,7 +483,7 @@ def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, return sess.compound(open_op) -def open_create_file_op(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, +def open_create_file_op(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE, mode=GUARDED4, verifier=None,
@@ -526,7 +526,7 @@ def open_create_file_op(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, return fh_op + [open_op, op.getfh()] -def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, +def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE, mode=GUARDED4, verifier=None, want_deleg=False,
@@ -559,7 +559,7 @@ def open_file(sess, owner, path=None, verifier, claim_type, want_deleg, deleg_type, open_create, seqid, clientid) -def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, +def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE, mode=GUARDED4):
@@ -572,7 +572,7 @@ def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, fh = res.resarray[-1].object return fh, res.resarray[-2].stateid -def create_close(sess, owner, path=None, attrs={FATTR4_MODE: 0644}, +def create_close(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE, mode=GUARDED4):
nfs4.1/server41tests/st_lookup.py +2 -2
@@ -270,7 +270,7 @@ if 0: DEPEND: MKDIR CODE: LOOK6 """ - # Create dir/foo, and set mode of dir to 000 + # Create dir/foo, and set mode of dir to 0o000 c = env.c1 dir = c.homedir + [t.code] res = c.create_obj(dir)
@@ -283,7 +283,7 @@ if 0: res = c.compound(c.use_obj(dir)) check(res) res = c.compound(c.use_obj(dir + ['foo'])) - check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=000") + check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=0o000") def testInvalidUtf8(t, env): """LOOKUP with bad UTF-8 name strings should return NFS4ERR_INVAL
Signature · 1 line
2.17.1
PATCH 7/24 pynfs: python3 support plan: sys.maxint -> sys.maxsize
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
s/sys.maxint/sys.maxsize/g
--- nfs4.1/testmod.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
nfs4.1/testmod.py +2 -2
@@ -333,7 +333,7 @@ def parseversions(t): raise RuntimeError("Test %s has invalid version range %s" % (t.fullname, t.vers_list)) if len(t.vers_list) == 0: - return (0, sys.maxint) + return (0, sys.maxsize) limits = t.vers_list[0].split("-") if len(limits) != 2: raise RuntimeError("Test %s has invalid version range %s"
@@ -343,7 +343,7 @@ def parseversions(t): else: left = int(limits[0]) if limits[1] == '': - right = sys.maxint + right = sys.maxsize else: right = int(limits[1]) return (left, right)
Signature · 1 line
2.17.1
PATCH 8/24 pynfs: python3 support plan: cStringIO -> StringIO
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
try: # python2
import cStringIO.StringIO as StringIO
except: # python3
from io import StringIO
--- nfs4.0/nfs4state.py | 5 ++--- nfs4.1/fs.py | 5 ++++- xdr/xdrgen.py | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-)
nfs4.0/nfs4state.py +2 -3
@@ -5,10 +5,9 @@ import nfs4acl import nfs4lib import os, time, array, random, string try: - import cStringIO - StringIO = cStringIO + import cStringIO.StringIO as StringIO except: - import StringIO + from io import StringIO from stat import * import sha
nfs4.1/fs.py +4 -1
@@ -6,7 +6,10 @@ from nfs4lib import NFS4Error import struct import logging from locking import Lock, RWLock -from cStringIO import StringIO +try: + import cStringIO.StringIO as StringIO +except: + from io import StringIO import time from xdrdef.nfs4_pack import NFS4Packer
xdr/xdrgen.py +4 -1
@@ -215,7 +215,10 @@ import sys import keyword -import StringIO +try: + import cStringIO.StringIO as StringIO +except: + from io import StringIO import time import os # Allow to be run stright from package
Signature · 1 line
2.17.1
PATCH 9/24 pynfs: python3 support plan: dict.has_key -> key in dict
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
and rename DirList.has_key() to DirList.has_name()
to avoid confuse
--- nfs4.0/lib/rpc/rpc.py | 2 +- nfs4.0/nfs4lib.py | 2 +- nfs4.0/nfs4server.py | 4 ++-- nfs4.0/nfs4state.py | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-)
nfs4.0/lib/rpc/rpc.py +1 -1
@@ -514,7 +514,7 @@ class RPCServer(Server): 'sys': AUTH_SYS, 'gss': RPCSEC_GSS, }.iteritems(): - if supported.has_key(secname): + if secname in supported: self.security[sectype] = supported[secname]() self.readbufs = {}
nfs4.0/nfs4lib.py +1 -1
@@ -232,7 +232,7 @@ class CBServer(rpc.RPCServer): results = [] ok = NFS4_OK for op in cmp4args.argarray: - if self.opcodes.has_key(op.argop): + if op.argop in self.opcodes: ok, result = self.opcodes[op.argop](op, cbid) else: ok = NFS4ERR_OP_ILLEGAL
nfs4.0/nfs4server.py +2 -2
@@ -504,7 +504,7 @@ class NFS4Server(rpc.RPCServer): if op.opopen.openhow.how.mode == GUARDED4: raise NFS4Error(NFS4ERR_EXIST) # with an existing file ignore attrs except size=0 - if attrs.has_key(FATTR4_SIZE) and attrs[FATTR4_SIZE]==0: + if FATTR4_SIZE in attrs and attrs[FATTR4_SIZE]==0: attrset = existing.set_attributes(attrdict={FATTR4_SIZE:0}) # Now break out and use existing as is else:
@@ -593,7 +593,7 @@ class NFS4Server(rpc.RPCServer): def op_putfh(self, op): print(" FILEHANDLE '%s'" % repr(op.opputfh.object)) # check access! - if not self.fhcache.has_key(op.opputfh.object): + if not op.opputfh.object in self.fhcache: return simple_error(NFS4ERR_BADHANDLE) self.curr_fh = self.fhcache[op.opputfh.object] return simple_error(NFS4_OK)
nfs4.0/nfs4state.py +5 -5
@@ -1014,7 +1014,7 @@ class VirtualHandle(NFSFileHandle): # Must make sure that if it fails, nothing is changed if self.fattr4_type != NF4DIR: raise "create called on non-directory (%s)" % self.ref - if self.dirent.has_key(name): + if self.dirent.has_name(name): raise "attempted to create already existing file." fh = VirtualHandle(name, type, self) if FATTR4_SIZE in attrs and type.type != NF4REG:
@@ -1116,7 +1116,7 @@ class VirtualHandle(NFSFileHandle): mapping = nfs4lib.list2bitmap ret_list = [] for attr in attrdict.keys(): - if not self.supported.has_key(attr): + if not attr in self.supported: raise NFS4Error(NFS4ERR_ATTRNOTSUPP, attrs=mapping(ret_list)) if 'w' not in self.supported[attr]: raise NFS4Error(NFS4ERR_INVAL, attrs=mapping(ret_list))
@@ -1182,7 +1182,7 @@ class VirtualHandle(NFSFileHandle): # Make sure any error is recorded in fattr4_rdattr_error ret_dict = {} for attr in attrlist: - if not self.supported.has_key(attr): + if not attr in self.supported: # Ignore unknown attributes continue if 'r' not in self.supported[attr]:
@@ -1419,7 +1419,7 @@ class HardHandle(NFSFileHandle): self.oldfiles = self.dirent.keys() for i in os.listdir(self.file): fullfile = os.path.join(self.file, i) - if not self.dirent.has_key(i): + if not self.dirent.has_name(i): self.dirent[i] = HardHandle(i, self, fullfile) else: self.oldfiles.remove(i)
@@ -1520,7 +1520,7 @@ class DirList: else: return self.list[i:] - def has_key(self, name): + def has_name(self, name): for x in self.list: if x.name == name: return True
Signature · 1 line
2.17.1
PATCH 10/24 pynfs: python3 support plan: not equal op s/ <> / != /
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/nfs4lib.py | 4 ++-- nfs4.0/nfs4server.py | 4 ++-- nfs4.1/nfs4client.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
nfs4.0/nfs4lib.py +2 -2
@@ -227,7 +227,7 @@ class CBServer(rpc.RPCServer): cbid = cmp4args.callback_ident except XDRError: return NFS4ERR_BADXDR, [], tag - if cmp4args.minorversion <> 0: + if cmp4args.minorversion != 0: return NFS4ERR_MINOR_VERS_MISMATCH, [], tag results = [] ok = NFS4_OK
@@ -239,7 +239,7 @@ class CBServer(rpc.RPCServer): resop4 = CB_ILLEGAL4res(NFS4ERR_OP_ILLEGAL) result = nfs_cb_resop4(resop=OP_ILLEGAL, opcbillegal=resop4) results += [ result ] - if ok <> NFS4_OK: + if ok != NFS4_OK: break return ok, results, tag
nfs4.0/nfs4server.py +2 -2
@@ -171,7 +171,7 @@ class NFS4Server(rpc.RPCServer): return NFS4ERR_BADXDR, [], tag print("TCP NFSv4 COMPOUND call, tag: %s, n_ops: %d" % \ (repr(tag), len(cmp4args.argarray))) - if cmp4args.minorversion <> 0: + if cmp4args.minorversion != 0: return NFS4ERR_MINOR_VERS_MISMATCH, [], tag if not verify_utf8(tag): return NFS4ERR_INVAL, [], tag
@@ -183,7 +183,7 @@ class NFS4Server(rpc.RPCServer): print("*** %s (%d) ***" % (opname, op.argop)) ok, result = getattr(self, opname.lower())(op) results += [ result ] - if ok <> NFS4_OK: + if ok != NFS4_OK: print(" ! error %s" % nfsstat4[ok]) break print("Replying. Status %s (%d)" % (nfsstat4[ok], ok))
nfs4.1/nfs4client.py +1 -1
@@ -177,7 +177,7 @@ class NFS4Client(rpc.Client, rpc.Server): def op_cb_compound(self, args, cred): env = CompoundState(args, cred) # Check for problems with the compound itself - if args.minorversion <> 0: + if args.minorversion != 0: if args.minorversion not in self.minor_versions: env.results.set_empty_return(NFS4ERR_MINOR_VERS_MISMATCH) return env
Signature · 1 line
2.17.1
PATCH 11/24 pynfs: python3 support plan: xdrgen: remove 'L' suffix of long integer
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- xdr/xdrgen.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
xdr/xdrgen.py +1 -4
@@ -341,10 +341,7 @@ def p_constant(t): '''constant : CONST10 | CONST8 | CONST16''' - if len(t[1]) > 9: - t[0] = t[1] + 'L' - else: - t[0] = t[1] + t[0] = t[1] def p_value(t): '''value : constant
Signature · 1 line
2.17.1
PATCH 12/24 pynfs: python3 support plan: file() -> open()
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/testserver.py | 2 +- nfs4.1/testclient.py | 2 +- nfs4.1/testserver.py | 2 +- showresults.py | 2 +- xdr/xdrgen.py | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-)
nfs4.0/testserver.py +1 -1
@@ -354,7 +354,7 @@ def main(): print(sys.exc_info()[1]) sys.exit(1) if opt.outfile is not None: - fd = file(opt.outfile, 'w') + fd = open(opt.outfile, 'w') try: clean_finish = False testmod.runtests(tests, opt, env, run_filter)
nfs4.1/testclient.py +1 -1
@@ -313,7 +313,7 @@ def main(): print(sys.exc_info()[1]) sys.exit(1) if opt.outfile is not None: - fd = file(opt.outfile, 'w') + fd = open(opt.outfile, 'w') try: clean_finish = False testmod.runtests(tests, opt, env, run_filter)
nfs4.1/testserver.py +1 -1
@@ -333,7 +333,7 @@ def main(): print(sys.exc_info()[1]) sys.exit(1) if opt.outfile is not None: - fd = file(opt.outfile, 'w') + fd = open(opt.outfile, 'w') try: clean_finish = False testmod.runtests(tests, opt, env, run_filter)
showresults.py +1 -1
@@ -38,7 +38,7 @@ class MyUnpickler(pickle.Unpickler): return self.Unknown(name) def show(filename, opt): - fd = file(filename, 'r') + fd = open(filename, 'r') p = MyUnpickler(fd) tests = p.load() testmod.printresults(tests, opt)
xdr/xdrgen.py +3 -3
@@ -1419,12 +1419,12 @@ def run(infile, filters=True, pass_attrs=True, debug=False): comment_string = "# Generated by rpcgen.py from %s on %s\n" % \ (infile, time.asctime()) - const_fd = file(constants_file + ".py", "w") + const_fd = open(constants_file + ".py", "w") const_fd.write(comment_string) - type_fd = file(types_file + ".py", "w") + type_fd = open(types_file + ".py", "w") type_fd.write(comment_string) type_fd.write("import %s as const\n" % constants_file) - pack_fd = file(packer_file + ".py", "w") + pack_fd = open(packer_file + ".py", "w") pack_fd.write(comment_string) pack_fd.write(pack_header % (constants_file, types_file)) pack_fd.write(pack_init % name_base.upper())
Signature · 1 line
2.17.1
PATCH 13/24 pynfs: python3 support plan: list.sort() -> newlist = sorted(list)
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- xdr/xdrgen.py | 56 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 21 deletions(-)
xdr/xdrgen.py +35 -21
@@ -305,7 +305,7 @@ def t_linecomment(t): def t_error(t): print("Illegal character %s at %d type %s" % (repr(t.value[0]), t.lexer.lineno, t.type)) t.lexer.skip(1) - + # Build the lexer lex.lex(debug=0)
@@ -641,7 +641,7 @@ def p_proc_firstarg(t): def p_type_specifier_list(t): '''type_specifier_list : COMMA type_specifier type_specifier_list | empty''' - + ########################################################################## # #
@@ -718,7 +718,7 @@ class Info(object): def const_output(self): return None - + def type_output(self): return None
@@ -853,7 +853,7 @@ class Info(object): else: subheader = array = varindent = '' return prefix+varindent, newdata, subheader, array - + def packenum(self, prefix, data='data'): prefix, data, subheader, array = self._array_pack(prefix, data) varlist = ["const.%s" % l.id for l in self.body]
@@ -952,7 +952,7 @@ class Info(object): else: unpack += "%s%sraise XDRError('bad switch=%%s' %% %s.%s)\n" % \ (prefix, indent, data, switch.id) - + return subheader + unpack + array def xdrbody(self, prefix=''):
@@ -977,7 +977,7 @@ class Info(object): ''.join(["%s\n" % d.xdrout(prefix + indent) for d in self.body[-1].declarations]) return body - + class const_info(Info): """The result of 'CONST ID EQUALS constant SEMI' or inside of enum as 'ID EQUALS value' """
@@ -988,13 +988,16 @@ class const_info(Info): self.lineno = self.sortno = lineno self.type = 'const' self.enum = enum - + def __repr__(self): return "constant %s=%s at line %s" % (self.id, self.value, self.lineno) + def __lt__(self, other): + return self.sortno < other.sortno + def xdrout(self, prefix=''): return "%s%s = %s" % (prefix, self.id, self.value) - + def const_output(self): return "%s = %s\n" % (self.id, self.value)
@@ -1016,6 +1019,9 @@ class enum_info(Info): self.array = False self.parent = True + def __lt__(self, other): + return self.sortno < other.sortno + def const_output(self): body = ''.join(["%s%s : '%s',\n" % (indent, l.value, l.id) for l in self.body])
@@ -1029,7 +1035,7 @@ class enum_info(Info): header = "%sdef unpack_%s(self):\n" % (indent, self.id) return header + self.unpackenum(indent2) + \ self._get_unpack_footer() - + class struct_info(Info): """The result of 'TYPEDEF STRUCT <struct_body> ID <array> SEMI' or 'STRUCT ID <struct_body> SEMI'
@@ -1048,6 +1054,9 @@ class struct_info(Info): self.array = False self.parent = True + def __lt__(self, other): + return self.sortno < other.sortno + def type_output(self): comment = '%s# ' % indent xdrbody = self.xdrbody(comment)
@@ -1079,11 +1088,11 @@ class struct_info(Info): (indent, indent2, candidates[0].id) else: return '' - + def pack_output(self): header = self._get_pack_header() return header + self.packstruct(indent2) - + def unpack_output(self): header = "%sdef unpack_%s(self):\n" % (indent, self.id) return header + self.unpackstruct(indent2) + \
@@ -1107,6 +1116,9 @@ class union_info(Info): self.array = False self.parent = True + def __lt__(self, other): + return self.sortno < other.sortno + def union_getattr(self, prefix=indent): return "%sdef __getattr__(self, attr):\n"\ "%s%sreturn getattr(self.switch, attr)\n" % \
@@ -1174,6 +1186,9 @@ class type_info(Info): self.fixed = False self.parent = False + def __lt__(self, other): + return self.sortno < other.sortno + def __str__(self): return "%s %s at line %s" % (self.type, self.id, self.lineno)
@@ -1198,14 +1213,14 @@ class type_info(Info): x.len = self.len x.fixed = self.fixed return x - + def xdrout(self, prefix=''): if self.type == 'void': return "%svoid;" % prefix elif self.type == 'enum': body = self.xdrbody(prefix) name = "%senum {\n%s%s}" % (prefix, body, prefix) - + elif self.type == 'struct': body = self.xdrbody(prefix) name = "%sstruct {\n%s%s}" % (prefix, body, prefix)
@@ -1260,7 +1275,7 @@ class type_info(Info): return "%s = %s\n" % (self.id, self.type) elif cast.type == "enum": return "%s = const.%s\n" % (self.id, self.type) - + def pack_output(self): if not self.array: return "%spack_%s = pack_%s\n" % (indent, self.id, self.type)
@@ -1297,7 +1312,7 @@ class type_info(Info): pack = "%sself.pack_%s%s(%s%s%s)\n" % \ (prefix, fixchar, type, fixnum, data, packer) return limit + pack - + def _unpack_array(self, prefix, data='data'): if self.fixed or self.len is None: limit = ''
@@ -1322,9 +1337,9 @@ class type_info(Info): pack = "%s%s = self.unpack_%s%s(%s)\n" % \ (prefix, data, fixchar, type, ', '.join(fixnum+packer)) return pack + limit - - - + + + ########################################################################## # # # Main Loop #
@@ -1430,8 +1445,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False): pack_fd.write(pack_init % name_base.upper()) pack_fd.write(packer_start) - type_list = name_dict.values() - type_list.sort() + type_list = sorted(name_dict.values()) for value in type_list: #print(value) output = value.const_output()
@@ -1454,7 +1468,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False): if output is not None: pack_fd.write(output) pack_fd.write('\n') - + const_fd.close() type_fd.close() pack_fd.close()
Signature · 1 line
2.17.1
PATCH 14/24 pynfs: python3 support plan: Relative Import -> Absolute Import
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/lib/rpc/rpc.py | 23 ++++++++++++----------- nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py | 2 +- nfs4.0/lib/rpc/rpcsec/sec_auth_none.py | 2 +- nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py | 2 +- nfs4.0/nfs4lib.py | 20 +++++++++++--------- xdr/xdrgen.py | 4 +++- 6 files changed, 29 insertions(+), 24 deletions(-)
nfs4.0/lib/rpc/rpc.py +12 -11
@@ -7,6 +7,7 @@ # Information Technology Integration # +from __future__ import absolute_import import struct import xdrlib import socket
@@ -14,17 +15,17 @@ import select import threading import errno -from rpc_const import * -from rpc_type import * -import rpc_pack +from rpc.rpc_const import * +from rpc.rpc_type import * +import rpc.rpc_pack as rpc_pack # Import security flavors and store valid ones -from rpcsec.sec_auth_none import SecAuthNone -from rpcsec.sec_auth_sys import SecAuthSys +from .rpcsec.sec_auth_none import SecAuthNone +from .rpcsec.sec_auth_sys import SecAuthSys supported = {'none' : SecAuthNone, 'sys' : SecAuthSys } try: - from rpcsec.sec_auth_gss import SecAuthGss + from .rpcsec.sec_auth_gss import SecAuthGss supported['gss'] = SecAuthGss except ImportError: pass
@@ -427,11 +428,11 @@ class RPCClient(object): cred = self.security.make_cred() p.pack_uint(xid) p.pack_enum(CALL) - p.pack_uint(RPCVERSION) - p.pack_uint(prog) - p.pack_uint(vers) - p.pack_uint(proc) - p.pack_opaque_auth(cred) + p.pack_uint(RPCVERSION) + p.pack_uint(prog) + p.pack_uint(vers) + p.pack_uint(proc) + p.pack_opaque_auth(cred) verf = self.security.make_verf(p.get_buffer()) p.pack_opaque_auth(verf) return p.get_buffer(), cred
nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py +1 -1
@@ -1,4 +1,4 @@ -from base import SecFlavor, SecError +from .base import SecFlavor, SecError from rpc.rpc_const import RPCSEC_GSS from rpc.rpc_type import opaque_auth from gss_const import *
nfs4.0/lib/rpc/rpcsec/sec_auth_none.py +1 -1
@@ -1,4 +1,4 @@ -from base import SecFlavor +from .base import SecFlavor class SecAuthNone(SecFlavor): pass
nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py +1 -1
@@ -1,4 +1,4 @@ -from base import SecFlavor, SecError +from .base import SecFlavor, SecError from rpc.rpc_const import AUTH_SYS from rpc.rpc_type import opaque_auth from xdrlib import Packer, Error
nfs4.0/nfs4lib.py +11 -9
@@ -24,16 +24,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +from __future__ import absolute_import - -import rpc -import threading -from xdrlib import Error as XDRError -import xdrdef.nfs4_const as nfs4_const -from xdrdef.nfs4_const import * -import xdrdef.nfs4_type as nfs4_type -from xdrdef.nfs4_type import * -import xdrdef.nfs4_pack as nfs4_pack import time import struct import socket
@@ -41,6 +33,16 @@ import sys import re import inspect from os.path import basename +import threading + +import rpc.rpc as rpc +import rpc.rpc_const as rpc_const +import xdrdef.nfs4_const as nfs4_const +from xdrdef.nfs4_const import * +import xdrdef.nfs4_type as nfs4_type +from xdrdef.nfs4_type import * +from xdrlib import Error as XDRError +import xdrdef.nfs4_pack as nfs4_pack import nfs_ops op4 = nfs_ops.NFS4ops()
xdr/xdrgen.py +3 -1
@@ -1354,6 +1354,8 @@ allow_attr_passthrough = True # Option which allows substructure attrs to # be referenced directly, in cases where there # is a unique substructure to search. pack_header = """\ +import sys,os +sys.path.append(os.path.dirname(__file__)) import %s as const import %s as types import xdrlib
@@ -1438,7 +1440,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False): const_fd.write(comment_string) type_fd = open(types_file + ".py", "w") type_fd.write(comment_string) - type_fd.write("import %s as const\n" % constants_file) + type_fd.write("import sys,os\nsys.path.append(os.path.dirname(__file__))\nimport %s as const\n" % constants_file) pack_fd = open(packer_file + ".py", "w") pack_fd.write(comment_string) pack_fd.write(pack_header % (constants_file, types_file))
Signature · 1 line
2.17.1
PATCH 15/24 pynfs: python3 support plan: fix 'socket' has no attribute '_socketobject'
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/lib/rpc/rpc.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
nfs4.0/lib/rpc/rpc.py +8 -3
@@ -176,9 +176,14 @@ def _send_record(self, data, chunksize=2048): mark = struct.pack('>L', last | len(chunk)) self.sendall(mark + chunk) -socket._socketobject.recv_all = _recv_all -socket._socketobject.recv_record = _recv_record -socket._socketobject.send_record = _send_record +try: #for python2 + socket._socketobject.recv_all = _recv_all + socket._socketobject.recv_record = _recv_record + socket._socketobject.send_record = _send_record +except: #for python3 + socket.recv_all = _recv_all + socket.recv_record = _recv_record + socket.send_record = _send_record #################################################
Signature · 1 line
2.17.1
PATCH 16/24 pynfs: python3 support plan: remove cPickle
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/testserver.py | 2 +- nfs4.1/testclient.py | 2 +- nfs4.1/testserver.py | 2 +- showresults.py | 1 - 4 files changed, 3 insertions(+), 4 deletions(-)
nfs4.0/testserver.py +1 -1
@@ -41,7 +41,7 @@ from optparse import OptionParser, OptionGroup, IndentedHelpFormatter import servertests.environment as environment import socket import rpc -import cPickle as pickle +import pickle VERSION="0.2" # How/when update this?
nfs4.1/testclient.py +1 -1
@@ -34,7 +34,7 @@ from optparse import OptionParser, OptionGroup, IndentedHelpFormatter import client41tests.environment as environment import socket import rpc -import cPickle as pickle +import pickle def parse_useparams(str): return str.split(':')
nfs4.1/testserver.py +1 -1
@@ -38,7 +38,7 @@ from optparse import OptionParser, OptionGroup, IndentedHelpFormatter import server41tests.environment as environment import socket import rpc -import cPickle as pickle +import pickle VERSION="0.2" # How/when update this?
showresults.py +0 -1
@@ -17,7 +17,6 @@ if __name__ == "__main__": if os.path.isfile(os.path.join(sys.path[0], 'nfs4.1', 'testmod.py')): sys.path.insert(1, os.path.join(sys.path[0], 'nfs4.1')) -#import cPickle as pickle import pickle import testmod from optparse import OptionParser
Signature · 1 line
2.17.1
PATCH 17/24 pynfs: python3 support plan: fix indent error on python3
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/servertests/__init__.py | 2 +- nfs4.0/servertests/st_getattr.py | 12 +++++------ nfs4.0/servertests/st_lookup.py | 8 ++++---- nfs4.0/servertests/st_open.py | 4 ++-- nfs4.0/servertests/st_opendowngrade.py | 5 ++--- nfs4.0/servertests/st_readdir.py | 8 ++++---- nfs4.0/servertests/st_write.py | 4 ++-- nfs4.1/server41tests/__init__.py | 4 ++-- nfs4.1/server41tests/environment.py | 24 +++++++++++----------- nfs4.1/server41tests/st_current_stateid.py | 2 +- nfs4.1/server41tests/st_delegation.py | 12 +++++------ nfs4.1/server41tests/st_destroy_session.py | 2 +- nfs4.1/server41tests/st_flex.py | 2 +- nfs4.1/testmod.py | 8 ++++---- 14 files changed, 48 insertions(+), 49 deletions(-)
nfs4.0/servertests/__init__.py +1 -1
@@ -1,5 +1,5 @@ __all__ = [ "st_access.py", - "st_acl.py", + "st_acl.py", "st_close.py", "st_commit.py", "st_compound.py",
nfs4.0/servertests/st_getattr.py +6 -6
@@ -525,18 +525,18 @@ def testOwnerName(t, env): def xxxtestMountedOnFileid(self): """GETATTR(FATTR4_MOUNTED_ON_FILEID) - This DOES NOT work on standard test tree. It assumes that pseudofs - root / and pseudo fs node /unix exist, and that /unix is a mountpoint - of an exported file system. The fsid of "/" should differ from the - fsid of "/unix", and the mounted_on_fileid should != the filed with - both the Getattr of "/unix" and the Readdir of "/". + This DOES NOT work on standard test tree. It assumes that pseudofs + root / and pseudo fs node /unix exist, and that /unix is a mountpoint + of an exported file system. The fsid of "/" should differ from the + fsid of "/unix", and the mounted_on_fileid should != the filed with + both the Getattr of "/unix" and the Readdir of "/". """ request = [FATTR4_MOUNTED_ON_FILEID, FATTR4_FILEID, FATTR4_FSID] lookupops = [op.lookup("unix")] ops = [op.putrootfh()] ops.append(self.ncl.getattr(request)) - ops += lookupops + ops += lookupops ops.append(self.ncl.getattr(request)) res = self.ncl.do_ops(ops) self.assert_OK(res)
nfs4.0/servertests/st_lookup.py +4 -4
@@ -220,9 +220,9 @@ def testNonAccessable(t, env): check(res) res = c.compound(c.use_obj(dir + ['foo'])) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP object in a dir with mode=0o000") + check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP object in a dir with mode=0o000") else: - check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=0o000") + check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=0o000") def testInvalidUtf8(t, env): """LOOKUP with bad UTF-8 name strings should return NFS4ERR_INVAL
@@ -283,9 +283,9 @@ def testUnaccessibleDir(t, env): check(res, msg="Setting mode=0 on directory %s" % t.code) res = c.compound(c.use_obj(path + ['hidden'])) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP off of dir with mode=0o000") + check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP off of dir with mode=0o000") else: - check(res, NFS4ERR_ACCESS, "LOOKUP off of dir with mode=0o000") + check(res, NFS4ERR_ACCESS, "LOOKUP off of dir with mode=0o000") def testBadOpaque(t, env): """LOOKUP with a path component that has an incorrect array length
nfs4.0/servertests/st_open.py +2 -2
@@ -331,9 +331,9 @@ def testModeChange(t, env): res = c.open_file(t.code, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "Opening file %s with mode=0o000" % t.code) + check(res, [NFS4_OK, NFS4ERR_ACCESS], "Opening file %s with mode=0o000" % t.code) else: - check(res, NFS4ERR_ACCESS, "Opening file %s with mode=0o000" % t.code) + check(res, NFS4ERR_ACCESS, "Opening file %s with mode=0o000" % t.code) def testShareConflict1(t, env): """OPEN conflicting with previous share
nfs4.0/servertests/st_opendowngrade.py +2 -3
@@ -136,16 +136,15 @@ class open_sequence: deny=OPEN4_SHARE_DENY_NONE, mode=UNCHECKED4) def downgrade(self, access): - res = self.client.downgrade_file(self.owner, self.fh, self.stateid, + res = self.client.downgrade_file(self.owner, self.fh, self.stateid, access=access, deny=OPEN4_SHARE_DENY_NONE) - self.stateid = res.stateid + self.stateid = res.stateid def close(self): self.client.close_file(self.owner, self.fh, self.stateid) def lock(self, type): self.client.lock_file(self.owner, self.fh, self.stateid, type=type) - def testOpenDowngradeSequence(t, env): """test complex upgrade/downgrade sequence
nfs4.0/servertests/st_readdir.py +4 -4
@@ -232,9 +232,9 @@ def testUnaccessibleDir(t, env): ops = c.use_obj(path) + [c.readdir()] res = c.compound(ops) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=0o000") + check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=0o000") else: - check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=0o000") + check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=0o000") def testUnaccessibleDirAttrs(t, env): """READDIR with (cfh) in unaccessible directory requesting attrs
@@ -253,9 +253,9 @@ def testUnaccessibleDirAttrs(t, env): [c.readdir(attr_request=[FATTR4_RDATTR_ERROR, FATTR4_TYPE])] res = c.compound(ops) if env.opts.uid == 0: - check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=0o000") + check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=0o000") else: - check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=0o000") + check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=0o000") ###########################################
nfs4.0/servertests/st_write.py +2 -2
@@ -438,8 +438,8 @@ def testLargeReadWrite(t, env): check(res) data = res.resarray[-2].switch.switch.data if len(data) != len(writedata): - t.fail("READ returned %d bytes, expected %d" % - (len(data), len(writedata))) + t.fail("READ returned %d bytes, expected %d" % + (len(data), len(writedata))) if (data != '\0'*size): t.fail("READ returned unexpected data") res = c.read_file(fh, 0, size)
nfs4.1/server41tests/__init__.py +2 -2
@@ -7,7 +7,7 @@ __all__ = ["st_exchange_id.py", # draft 21 "st_secinfo_no_name.py", "st_secinfo.py", "st_sequence.py", - "st_trunking.py", + "st_trunking.py", "st_open.py", "st_delegation.py", "st_verify.py",
@@ -22,6 +22,6 @@ __all__ = ["st_exchange_id.py", # draft 21 ## "st_debug.py", ## "st_loop", "st_current_stateid.py", - "st_sparse.py", + "st_sparse.py", "st_flex.py", ]
nfs4.1/server41tests/environment.py +12 -12
@@ -471,12 +471,12 @@ def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0o755}): def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE, - mode=GUARDED4, verifier=None, - claim_type=CLAIM_NULL, - want_deleg=False, - deleg_type=None, - open_create=OPEN4_NOCREATE, - seqid=0, clientid=0): + mode=GUARDED4, verifier=None, + claim_type=CLAIM_NULL, + want_deleg=False, + deleg_type=None, + open_create=OPEN4_NOCREATE, + seqid=0, clientid=0): open_op = open_create_file_op(sess, owner, path, attrs, access, deny, mode, verifier, claim_type, want_deleg, deleg_type, open_create, seqid, clientid)
@@ -486,12 +486,12 @@ def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, def open_create_file_op(sess, owner, path=None, attrs={FATTR4_MODE: 0o644}, access=OPEN4_SHARE_ACCESS_BOTH, deny=OPEN4_SHARE_DENY_NONE, - mode=GUARDED4, verifier=None, - claim_type=CLAIM_NULL, - want_deleg=False, - deleg_type=None, - open_create=OPEN4_NOCREATE, - seqid=0, clientid=0): + mode=GUARDED4, verifier=None, + claim_type=CLAIM_NULL, + want_deleg=False, + deleg_type=None, + open_create=OPEN4_NOCREATE, + seqid=0, clientid=0): # Set defaults if path is None: dir = sess.c.homedir
nfs4.1/server41tests/st_current_stateid.py +1 -1
@@ -43,7 +43,7 @@ def testLockLockU(t, env): open_to_lock_owner = open_to_lock_owner4( 0, stateid, 0, lock_owner4(0, "lock1")) lock_owner = locker4(open_owner=open_to_lock_owner, new_lock_owner=True) lock_ops = [ op.lock(WRITE_LT, False, 0, NFS4_UINT64_MAX, lock_owner), - op.locku(WRITE_LT, 0, current_stateid, 0, NFS4_UINT64_MAX) ] + op.locku(WRITE_LT, 0, current_stateid, 0, NFS4_UINT64_MAX) ] res = sess1.compound([op.putfh(fh)] + lock_ops) check(res, NFS4_OK) res = close_file(sess1, fh, stateid=stateid)
nfs4.1/server41tests/st_delegation.py +6 -6
@@ -27,8 +27,8 @@ def __create_file_with_deleg(sess, name, access): return (fh, deleg) def _create_file_with_deleg(sess, name, access): - fh, deleg = __create_file_with_deleg(sess, name, access) - return fh + fh, deleg = __create_file_with_deleg(sess, name, access) + return fh def _testDeleg(t, env, openaccess, want, breakaccess, sec = None, sec2 = None): recall = threading.Event()
@@ -182,7 +182,7 @@ def testDelegRevocation(t, env): if res.status == NFS4_OK: break; check(res, [NFS4_OK, NFS4ERR_DELAY]) - # just to keep sess1 renewed. This is a bit fragile, as we + # just to keep sess1 renewed. This is a bit fragile, as we # depend on the above compound waiting no longer than the # server's lease period: res = sess1.compound([])
@@ -196,7 +196,7 @@ def testDelegRevocation(t, env): " sucess of open conflicting with delegation") flags &= ~SEQ4_STATUS_RECALLABLE_STATE_REVOKED if flags: - print("WARNING: unexpected status flag(s) 0x%x set" % flags); + print("WARNING: unexpected status flag(s) 0x%x set" % flags); res = sess1.update_seq_state(res, slot) res = sess1.compound([op.test_stateid([delegstateid])]) stateid_stat = res.resarray[0].tsr_status_codes[0]
@@ -210,7 +210,7 @@ def testDelegRevocation(t, env): res = sess1.c.compound([seq_op]) flags = res.resarray[0].sr_status_flags if flags & SEQ4_STATUS_RECALLABLE_STATE_REVOKED: - fail("SEQ4_STATUS_RECALLABLE_STATE_REVOKED should be cleared after" - " FREE_STATEID") + fail("SEQ4_STATUS_RECALLABLE_STATE_REVOKED should be cleared after" + " FREE_STATEID") if flags & ~SEQ4_STATUS_RECALLABLE_STATE_REVOKED: print("WARNING: unexpected status flag(s) 0x%x set" % flags)
nfs4.1/server41tests/st_destroy_session.py +1 -1
@@ -97,7 +97,7 @@ def testDestroy3(t, env): recall.happened = True env.notify = recall.set # This is called after compound sent to queue def bad_post_hook(arg, env, res): - return None; + return None; def good_post_hook(arg, env, res): return res c = env.c1.new_client(env.testname(t))
nfs4.1/server41tests/st_flex.py +1 -1
@@ -50,7 +50,7 @@ def testStateid1(t, env): # From draft23 12.5.3 "After the layout stateid is established, # the server increments by one the value of the "seqid" in each # subsequent LAYOUTGET and LAYOUTRETURN response, - check_seqid(lo_stateid, i + 2) + check_seqid(lo_stateid, i + 2) res = close_file(sess, fh, stateid=open_stateid) check(res)
nfs4.1/testmod.py +4 -4
@@ -222,8 +222,8 @@ class Test(object): environment.startUp() self.runtest(self, environment) self.result = self._pass_result - environment.clean_sessions() - environment.clean_clients() + environment.clean_sessions() + environment.clean_clients() except KeyboardInterrupt: raise except TestException as e:
@@ -330,8 +330,8 @@ def _import_by_name(name): def parseversions(t): if len(t.vers_list) > 1: - raise RuntimeError("Test %s has invalid version range %s" - % (t.fullname, t.vers_list)) + raise RuntimeError("Test %s has invalid version range %s" + % (t.fullname, t.vers_list)) if len(t.vers_list) == 0: return (0, sys.maxsize) limits = t.vers_list[0].split("-")
Signature · 1 line
2.17.1
PATCH 18/24 pynfs: python3 support plan: fix 'TypeError: must be str, not bytes'
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py +4 -1
@@ -13,7 +13,10 @@ class SecAuthSys(SecFlavor): try: p = Packer() p.pack_int(stamp) - p.pack_string(machinename) + try: # for python2 + p.pack_string(machinename) + except: # for python3 + p.pack_string(bytes(machinename, 'utf-8')) p.pack_uint(uid) p.pack_uint(gid) p.pack_array(gids, p.pack_uint)
Signature · 1 line
2.17.1
PATCH 19/24 pynfs: python3 support plan: fix import fail on python3
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/servertests/environment.py | 2 +- nfs4.0/servertests/st_access.py | 2 +- nfs4.0/servertests/st_acl.py | 2 +- nfs4.0/servertests/st_close.py | 2 +- nfs4.0/servertests/st_commit.py | 2 +- nfs4.0/servertests/st_compound.py | 5 +++-- nfs4.0/servertests/st_create.py | 2 +- nfs4.0/servertests/st_delegation.py | 2 +- nfs4.0/servertests/st_fslocations.py | 2 +- nfs4.0/servertests/st_getattr.py | 2 +- nfs4.0/servertests/st_getfh.py | 2 +- nfs4.0/servertests/st_gss.py | 4 ++-- nfs4.0/servertests/st_link.py | 2 +- nfs4.0/servertests/st_lock.py | 2 +- nfs4.0/servertests/st_lockt.py | 2 +- nfs4.0/servertests/st_locku.py | 2 +- nfs4.0/servertests/st_lookup.py | 4 ++-- nfs4.0/servertests/st_lookupp.py | 2 +- nfs4.0/servertests/st_nverify.py | 2 +- nfs4.0/servertests/st_open.py | 2 +- nfs4.0/servertests/st_openconfirm.py | 2 +- nfs4.0/servertests/st_opendowngrade.py | 2 +- nfs4.0/servertests/st_putfh.py | 2 +- nfs4.0/servertests/st_putpubfh.py | 2 +- nfs4.0/servertests/st_putrootfh.py | 2 +- nfs4.0/servertests/st_read.py | 4 ++-- nfs4.0/servertests/st_readdir.py | 2 +- nfs4.0/servertests/st_readlink.py | 2 +- nfs4.0/servertests/st_reboot.py | 2 +- nfs4.0/servertests/st_releaselockowner.py | 2 +- nfs4.0/servertests/st_remove.py | 2 +- nfs4.0/servertests/st_rename.py | 2 +- nfs4.0/servertests/st_renew.py | 2 +- nfs4.0/servertests/st_replay.py | 2 +- nfs4.0/servertests/st_restorefh.py | 2 +- nfs4.0/servertests/st_savefh.py | 2 +- nfs4.0/servertests/st_secinfo.py | 2 +- nfs4.0/servertests/st_setattr.py | 2 +- nfs4.0/servertests/st_setclientid.py | 2 +- nfs4.0/servertests/st_setclientidconfirm.py | 2 +- nfs4.0/servertests/st_spoof.py | 2 +- nfs4.0/servertests/st_verify.py | 2 +- nfs4.0/servertests/st_write.py | 4 ++-- nfs4.0/testserver.py | 2 +- nfs4.1/client41tests/ct_reboot.py | 2 +- nfs4.1/client41tests/environment.py | 2 +- nfs4.1/dataserver.py | 2 +- nfs4.1/nfs3client.py | 2 +- nfs4.1/nfs4client.py | 2 +- nfs4.1/nfs4lib.py | 2 +- nfs4.1/nfs4proxy.py | 2 +- nfs4.1/nfs4server.py | 2 +- nfs4.1/nfs4state.py | 2 +- nfs4.1/server41tests/environment.py | 2 +- nfs4.1/server41tests/st_block.py | 2 +- nfs4.1/server41tests/st_compound.py | 2 +- nfs4.1/server41tests/st_create_session.py | 2 +- nfs4.1/server41tests/st_current_stateid.py | 4 ++-- nfs4.1/server41tests/st_debug.py | 2 +- nfs4.1/server41tests/st_delegation.py | 2 +- nfs4.1/server41tests/st_destroy_clientid.py | 2 +- nfs4.1/server41tests/st_destroy_session.py | 4 ++-- nfs4.1/server41tests/st_exchange_id.py | 2 +- nfs4.1/server41tests/st_flex.py | 2 +- nfs4.1/server41tests/st_getdevicelist.py | 2 +- nfs4.1/server41tests/st_lookup.py | 4 ++-- nfs4.1/server41tests/st_lookupp.py | 2 +- nfs4.1/server41tests/st_open.py | 4 ++-- nfs4.1/server41tests/st_putfh.py | 2 +- nfs4.1/server41tests/st_reboot.py | 2 +- nfs4.1/server41tests/st_reclaim_complete.py | 2 +- nfs4.1/server41tests/st_rename.py | 2 +- nfs4.1/server41tests/st_secinfo.py | 2 +- nfs4.1/server41tests/st_secinfo_no_name.py | 2 +- nfs4.1/server41tests/st_sequence.py | 2 +- nfs4.1/server41tests/st_sparse.py | 2 +- nfs4.1/server41tests/st_trunking.py | 2 +- nfs4.1/server41tests/st_verify.py | 2 +- nfs4.1/testclient.py | 2 +- nfs4.1/testserver.py | 2 +- rpc/rpc.py | 2 +- 81 files changed, 91 insertions(+), 90 deletions(-)
nfs4.0/servertests/environment.py +1 -1
@@ -14,7 +14,7 @@ from nfs4lib import NFS4Client, get_attrbitnum_dict from xdrdef.nfs4_const import * from xdrdef.nfs4_type import fsid4, nfsace4, fs_locations4, fs_location4, \ specdata4, nfstime4, settime4, stateid4 -import rpc +import rpc.rpc as rpc import sys import os import nfs_ops
nfs4.0/servertests/st_access.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_acl.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check from xdrdef.nfs4_type import nfsace4 from nfs4lib import list2bitmap
nfs4.0/servertests/st_close.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, makeStaleId +from .environment import check, makeStaleId def testCloseCreate(t, env):
nfs4.0/servertests/st_commit.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check _text = "Random data to write"
nfs4.0/servertests/st_compound.py +3 -2
@@ -1,8 +1,9 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import nfs_argop4 from xdrdef.nfs4_pack import NFS4Packer -from environment import check, get_invalid_utf8strings -from rpc import RPCError +from .environment import check, get_invalid_utf8strings +from rpc.rpc import RPCError + import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_create.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import createtype4, specdata4 -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_delegation.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import nfs_client_id4, clientaddr4, cb_client4 -from environment import check +from .environment import check import os import threading import time
nfs4.0/servertests/st_fslocations.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from nfs4lib import list2bitmap -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_getattr.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check from nfs4lib import get_attr_name import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_getfh.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_gss.py +2 -2
@@ -1,7 +1,7 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check from socket import timeout -import rpc +import rpc.rpc as rpc import rpc.rpcsec.gss_const as gss from rpc.rpcsec.gss_type import rpc_gss_cred_t import nfs_ops
nfs4.0/servertests/st_link.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_utf8strings +from .environment import check, get_invalid_utf8strings import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_lock.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import stateid4 -from environment import check, get_invalid_clientid, makeStaleId, makeBadIDganesha +from .environment import check, get_invalid_clientid, makeStaleId, makeBadIDganesha import time import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_lockt.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_clientid +from .environment import check, get_invalid_clientid def testUnlockedFile(t, env): """LOCKT on a regular unlocked file
nfs4.0/servertests/st_locku.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import stateid4 -from environment import check, makeStaleId +from .environment import check, makeStaleId def testFile(t, env): """LOCKU a regular file
nfs4.0/servertests/st_lookup.py +2 -2
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_utf8strings -import rpc +from .environment import check, get_invalid_utf8strings +import rpc.rpc as rpc import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_lookupp.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_utf8strings +from .environment import check, get_invalid_utf8strings import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_nverify.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_clientid, makeStaleId +from .environment import check, get_invalid_clientid, makeStaleId import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_open.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, checkdict, get_invalid_utf8strings +from .environment import check, checkdict, get_invalid_utf8strings from nfs4lib import get_bitnumattr_dict # Any test that uses create_confirm should depend on this test
nfs4.0/servertests/st_openconfirm.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import stateid4 -from environment import check, makeStaleId +from .environment import check, makeStaleId import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_opendowngrade.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, makeStaleId +from .environment import check, makeStaleId def testRegularOpen(t, env): """OPENDOWNGRADE on regular file
nfs4.0/servertests/st_putfh.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_putpubfh.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_putrootfh.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_read.py +2 -2
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * -from environment import check, makeBadID, makeBadIDganesha, makeStaleId -import rpc +from .environment import check, makeBadID, makeBadIDganesha, makeStaleId +import rpc.rpc as rpc def _compare(t, res, expect, eof=True): def shorten(str):
nfs4.0/servertests/st_readdir.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from nfs4lib import get_attr_name -from environment import check +from .environment import check def _compare(t, entries, expect, attrlist=[]): names = [e.name for e in entries]
nfs4.0/servertests/st_readlink.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_reboot.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import os import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_releaselockowner.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import lock_owner4 -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_remove.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_utf8strings +from .environment import check, get_invalid_utf8strings import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_rename.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_utf8strings +from .environment import check, get_invalid_utf8strings import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_renew.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_replay.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check from xdrdef.nfs4_type import * import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_restorefh.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_savefh.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_secinfo.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_utf8strings +from .environment import check, get_invalid_utf8strings import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_setattr.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_utf8strings +from .environment import check, get_invalid_utf8strings from nfs4lib import bitmap2list, dict2fattr from xdrdef.nfs4_type import nfstime4, settime4 import nfs_ops
nfs4.0/servertests/st_setclientid.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import os import struct, time import nfs_ops
nfs4.0/servertests/st_setclientidconfirm.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check import os import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_spoof.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check +from .environment import check def testSpoofUser(t, env): """SPOOF test, try to spoof user
nfs4.0/servertests/st_verify.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, get_invalid_clientid, makeStaleId +from .environment import check, get_invalid_clientid, makeStaleId import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/servertests/st_write.py +2 -2
@@ -1,8 +1,8 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import * -from environment import check, compareTimes, makeBadID, makeBadIDganesha, makeStaleId +from .environment import check, compareTimes, makeBadID, makeBadIDganesha, makeStaleId import struct -import rpc +import rpc.rpc as rpc import nfs_ops op = nfs_ops.NFS4ops()
nfs4.0/testserver.py +1 -1
@@ -40,7 +40,7 @@ import testmod from optparse import OptionParser, OptionGroup, IndentedHelpFormatter import servertests.environment as environment import socket -import rpc +import rpc.rpc as rpc import pickle VERSION="0.2" # How/when update this?
nfs4.1/client41tests/ct_reboot.py +1 -1
@@ -1,5 +1,5 @@ import os -from environment import fail +from .environment import fail def testReboot(t, env): """Test reboot
nfs4.1/client41tests/environment.py +1 -1
@@ -12,7 +12,7 @@ import time import testmod from xdrdef.nfs4_const import * from xdrdef.nfs4_type import * -import rpc +import rpc.rpc as rpc import nfs4client import os import nfs4lib
nfs4.1/dataserver.py +1 -1
@@ -1,4 +1,4 @@ -import rpc +import rpc.rpc as rpc import nfs4lib import xdrdef.nfs4_type as type4 from xdrdef.nfs4_pack import NFS4Packer
nfs4.1/nfs3client.py +1 -1
@@ -1,5 +1,5 @@ import use_local # HACK so don't have to rebuild constantly -import rpc +import rpc.rpc as rpc import nfs4lib #from nfs4lib import NFS4Error, NFS4Replay, inc_u32 from xdrdef.sctrl_pack import SCTRLPacker, SCTRLUnpacker
nfs4.1/nfs4client.py +1 -1
@@ -1,5 +1,5 @@ import use_local # HACK so don't have to rebuild constantly -import rpc +import rpc.rpc as rpc import nfs4lib from nfs4lib import NFS4Error, NFS4Replay, inc_u32 from xdrdef.nfs4_type import *
nfs4.1/nfs4lib.py +1 -1
@@ -1,5 +1,5 @@ from __future__ import with_statement -import rpc +import rpc.rpc as rpc import xdrdef.nfs4_const from xdrdef.nfs4_pack import NFS4Packer, NFS4Unpacker import xdrdef.nfs4_type
nfs4.1/nfs4proxy.py +1 -1
@@ -3,7 +3,7 @@ from __future__ import with_statement import use_local # HACK so don't have to rebuild constantly import nfs4lib from nfs4lib import inc_u32, NFS4Error, NFS4Replay -import rpc +import rpc.rpc as rpc from xdrdef.nfs4_const import * from xdrdef.nfs4_type import * from xdrdef.sctrl_pack import SCTRLPacker, SCTRLUnpacker
nfs4.1/nfs4server.py +1 -1
@@ -3,7 +3,7 @@ from __future__ import with_statement import use_local # HACK so don't have to rebuild constantly import nfs4lib from nfs4lib import inc_u32, NFS4Error, NFS4Replay -import rpc +import rpc.rpc as rpc from xdrdef.nfs4_const import * from xdrdef.nfs4_type import * from xdrdef.sctrl_pack import SCTRLPacker, SCTRLUnpacker
nfs4.1/nfs4state.py +1 -1
@@ -9,7 +9,7 @@ from nfs4lib import NFS4Error from xdrdef.nfs4_type import * from xdrdef.nfs4_const import * import nfs_ops -import rpc +import rpc.rpc as rpc import logging log = logging.getLogger("nfs.server.state")
nfs4.1/server41tests/environment.py +1 -1
@@ -12,7 +12,7 @@ import time import testmod from xdrdef.nfs4_const import * from xdrdef.nfs4_type import * -import rpc +import rpc.rpc as rpc import nfs4client import sys import os
nfs4.1/server41tests/st_block.py +1 -1
@@ -2,7 +2,7 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import * import nfs_ops op = nfs_ops.NFS4ops() -from environment import check, fail, create_file +from .environment import check, fail, create_file from block import Packer as BlockPacker, Unpacker as BlockUnpacker, \ PNFS_BLOCK_READWRITE_DATA, pnfs_block_layoutupdate4, \ pnfs_block_extent4
nfs4.1/server41tests/st_compound.py +1 -1
@@ -1,7 +1,7 @@ from xdrdef.nfs4_const import * import nfs_ops op = nfs_ops.NFS4ops() -from environment import check, fail, get_invalid_utf8strings +from .environment import check, fail, get_invalid_utf8strings from xdrdef.nfs4_type import * from rpc import RPCAcceptError, GARBAGE_ARGS, RPCTimeout from nfs4lib import NFS4Error, hash_oids, encrypt_oids, FancyNFS4Packer
nfs4.1/server41tests/st_create_session.py +1 -1
@@ -1,7 +1,7 @@ from xdrdef.nfs4_const import * import nfs_ops op = nfs_ops.NFS4ops() -from environment import check, fail, create_file, open_file +from .environment import check, fail, create_file, open_file from xdrdef.nfs4_type import * import random import nfs4lib
nfs4.1/server41tests/st_current_stateid.py +2 -2
@@ -1,8 +1,8 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail, create_file, open_file, close_file -from environment import open_create_file_op, use_obj +from .environment import check, fail, create_file, open_file, close_file +from .environment import open_create_file_op, use_obj from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from xdrdef.nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4 from xdrdef.nfs4_type import open_to_lock_owner4
nfs4.1/server41tests/st_debug.py +1 -1
@@ -1,6 +1,6 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail, create_file, close_file +from .environment import check, fail, create_file, close_file from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4 import nfs_ops op = nfs_ops.NFS4ops()
nfs4.1/server41tests/st_delegation.py +1 -1
@@ -2,7 +2,7 @@ from st_create_session import create_session from st_open import open_claim4 from xdrdef.nfs4_const import * -from environment import check, fail, create_file, open_file, close_file +from .environment import check, fail, create_file, open_file, close_file from xdrdef.nfs4_type import * import nfs_ops op = nfs_ops.NFS4ops()
nfs4.1/server41tests/st_destroy_clientid.py +1 -1
@@ -1,6 +1,6 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail +from .environment import check, fail import nfs_ops op = nfs_ops.NFS4ops() import nfs4lib
nfs4.1/server41tests/st_destroy_session.py +2 -2
@@ -1,11 +1,11 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail, create_file, open_file +from .environment import check, fail, create_file, open_file from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4 import nfs_ops op = nfs_ops.NFS4ops() import threading -import rpc +import rpc.rpc as rpc def testDestroy(t, env): """
nfs4.1/server41tests/st_exchange_id.py +1 -1
@@ -2,7 +2,7 @@ from xdrdef.nfs4_const import * import nfs_ops op = nfs_ops.NFS4ops() import time -from environment import check, fail +from .environment import check, fail from xdrdef.nfs4_type import * from rpc import RPCAcceptError, GARBAGE_ARGS, RPCTimeout from nfs4lib import NFS4Error, hash_oids, encrypt_oids
nfs4.1/server41tests/st_flex.py +1 -1
@@ -3,7 +3,7 @@ from xdrdef.nfs4_type import * from xdrdef.nfs4_pack import * import nfs_ops op = nfs_ops.NFS4ops() -from environment import check, fail, create_file, close_file, open_create_file_op +from .environment import check, fail, create_file, close_file, open_create_file_op from xdrdef.nfs4_pack import NFS4Packer as FlexPacker, \ NFS4Unpacker as FlexUnpacker from nfs4lib import FancyNFS4Packer, get_nfstime
nfs4.1/server41tests/st_getdevicelist.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import * -from environment import check, fail, use_obj, open_file, create_file, get_blocksize +from .environment import check, fail, use_obj, open_file, create_file, get_blocksize import nfs_ops op = nfs_ops.NFS4ops() from block import Packer as BlockPacker, Unpacker as BlockUnpacker, \
nfs4.1/server41tests/st_lookup.py +2 -2
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, fail +from .environment import check, fail import nfs_ops op = nfs_ops.NFS4ops()
@@ -64,7 +64,7 @@ def testLongName(t, env): ############################################################## if 0: - from environment import check, get_invalid_utf8strings + from .environment import check, get_invalid_utf8strings def testDir(t, env): """LOOKUP testtree dir
nfs4.1/server41tests/st_lookupp.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, fail, use_obj +from .environment import check, fail, use_obj import nfs_ops op = nfs_ops.NFS4ops()
nfs4.1/server41tests/st_open.py +2 -2
@@ -1,8 +1,8 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail, create_file, open_file, close_file -from environment import open_create_file_op +from .environment import check, fail, create_file, open_file, close_file +from .environment import open_create_file_op from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from xdrdef.nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4 from xdrdef.nfs4_type import open_to_lock_owner4
nfs4.1/server41tests/st_putfh.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, fail, use_obj, create_confirm, close_file +from .environment import check, fail, use_obj, create_confirm, close_file import nfs_ops op = nfs_ops.NFS4ops()
nfs4.1/server41tests/st_reboot.py +1 -1
@@ -1,6 +1,6 @@ from xdrdef.nfs4_const import * from xdrdef.nfs4_type import * -from environment import check, fail, create_file, open_file, create_confirm +from .environment import check, fail, create_file, open_file, create_confirm import sys import os import nfs4lib
nfs4.1/server41tests/st_reclaim_complete.py +1 -1
@@ -1,6 +1,6 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail, open_file, create_file, create_confirm +from .environment import check, fail, open_file, create_file, create_confirm import nfs_ops op = nfs_ops.NFS4ops() import nfs4lib
nfs4.1/server41tests/st_rename.py +1 -1
@@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from environment import check, fail, maketree, rename_obj, get_invalid_utf8strings, create_obj, create_confirm, link, use_obj, create_file +from .environment import check, fail, maketree, rename_obj, get_invalid_utf8strings, create_obj, create_confirm, link, use_obj, create_file import nfs_ops op = nfs_ops.NFS4ops() from xdrdef.nfs4_type import *
nfs4.1/server41tests/st_secinfo.py +1 -1
@@ -1,6 +1,6 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail, use_obj, bad_sessionid, create_file +from .environment import check, fail, use_obj, bad_sessionid, create_file from xdrdef.nfs4_type import channel_attrs4 import nfs_ops op = nfs_ops.NFS4ops()
nfs4.1/server41tests/st_secinfo_no_name.py +1 -1
@@ -1,6 +1,6 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail, bad_sessionid, create_file +from .environment import check, fail, bad_sessionid, create_file from xdrdef.nfs4_type import channel_attrs4 import nfs_ops op = nfs_ops.NFS4ops()
nfs4.1/server41tests/st_sequence.py +1 -1
@@ -1,6 +1,6 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail, bad_sessionid, create_file +from .environment import check, fail, bad_sessionid, create_file from xdrdef.nfs4_type import channel_attrs4 import nfs_ops op = nfs_ops.NFS4ops()
nfs4.1/server41tests/st_sparse.py +1 -1
@@ -1,6 +1,6 @@ from st_create_session import create_session from xdrdef.nfs4_const import * -from environment import check, fail, create_file +from .environment import check, fail, create_file import nfs_ops op = nfs_ops.NFS4ops() import nfs4lib
nfs4.1/server41tests/st_trunking.py +1 -1
@@ -1,7 +1,7 @@ from xdrdef.nfs4_const import * import nfs_ops op = nfs_ops.NFS4ops() -from environment import check, fail +from .environment import check, fail from xdrdef.nfs4_type import * import random import nfs4lib
nfs4.1/server41tests/st_verify.py +1 -1
@@ -1,7 +1,7 @@ from xdrdef.nfs4_const import * import nfs_ops op = nfs_ops.NFS4ops() -from environment import check, get_invalid_clientid, makeStaleId, \ +from .environment import check, get_invalid_clientid, makeStaleId, \ do_getattrdict, use_obj def _try_mand(t, env, path):
nfs4.1/testclient.py +1 -1
@@ -33,7 +33,7 @@ import testmod from optparse import OptionParser, OptionGroup, IndentedHelpFormatter import client41tests.environment as environment import socket -import rpc +import rpc.rpc as rpc import pickle def parse_useparams(str):
nfs4.1/testserver.py +1 -1
@@ -37,7 +37,7 @@ import testmod from optparse import OptionParser, OptionGroup, IndentedHelpFormatter import server41tests.environment as environment import socket -import rpc +import rpc.rpc as rpc import pickle VERSION="0.2" # How/when update this?
rpc/rpc.py +1 -1
@@ -7,7 +7,7 @@ import logging from collections import deque as Deque from errno import EINPROGRESS, EWOULDBLOCK -import rpc_pack +import rpc.rpc_pack as rpc_pack from rpc_const import * from rpc_type import *
Signature · 1 line
2.17.1
PATCH 20/24 pynfs: python3 support plan: fix 'dict' has no attribute 'iteritems'
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/lib/rpc/rpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
nfs4.0/lib/rpc/rpc.py +1 -1
@@ -519,7 +519,7 @@ class RPCServer(Server): for secname, sectype in {'none': AUTH_NONE, 'sys': AUTH_SYS, 'gss': RPCSEC_GSS, - }.iteritems(): + }.items(): if secname in supported: self.security[sectype] = supported[secname]()
Signature · 1 line
2.17.1
PATCH 21/24 pynfs: python3 support plan: fix sort() fail and require python version
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/testserver.py | 6 +++--- nfs4.1/nfs4client.py | 2 +- nfs4.1/nfs4lib.py | 2 +- nfs4.1/testclient.py | 6 +++--- nfs4.1/testmod.py | 5 ++++- nfs4.1/testserver.py | 6 +++--- 6 files changed, 15 insertions(+), 12 deletions(-)
nfs4.0/testserver.py +3 -3
@@ -1,7 +1,7 @@ #!/usr/bin/env python # nfs4stest.py - nfsv4 server tester # -# Requires python 2.5 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for
@@ -26,8 +26,8 @@ import sys -if sys.hexversion < 0x02050000: - print("Requires python 2.5 or higher") +if sys.hexversion < 0x02070000: + print("Requires python 2.7 or higher") sys.exit(1) import os # Allow to be run stright from package root
nfs4.1/nfs4client.py +1 -1
@@ -645,7 +645,7 @@ C.compound([C.bind_conn_to_session_op('0000000000000001', False, 3, False, 73, d """ PROGRAM COVERAGE -python2.5 ~/py_install/bin/coverage.py -x nfs4server.py +python2.7 ~/py_install/bin/coverage.py -x nfs4server.py coverage.py -a -d cover nfs4server.py run test suite """
nfs4.1/nfs4lib.py +1 -1
@@ -28,7 +28,7 @@ state00 = xdrdef.nfs4_type.stateid4(0, "\0" * 12) state11 = xdrdef.nfs4_type.stateid4(0xffffffff, "\xff" * 12) state01 = xdrdef.nfs4_type.stateid4(1, "\0" * 12) -import hashlib # Note this requires 2.5 or higher +import hashlib # Note this requires 2.7 or higher op4 = nfs_ops.NFS4ops()
nfs4.1/testclient.py +3 -3
@@ -1,7 +1,7 @@ #!/usr/bin/env python # nfs4stest.py - nfsv4 server tester # -# Requires python 2.5 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for
@@ -23,8 +23,8 @@ import use_local # HACK so don't have to rebuild constantly import sys -if sys.hexversion < 0x02050000: - print("Requires python 2.5 or higher") +if sys.hexversion < 0x02070000: + print("Requires python 2.7 or higher") sys.exit(1) import os
nfs4.1/testmod.py +4 -1
@@ -1,6 +1,6 @@ # testmod.py - run tests from a suite # -# Requires python 2.5 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for
@@ -157,6 +157,9 @@ class Test(object): else: return 1 + def __lt__(self, other): + return self.__cmp__(other) + def __str__(self): return "%-8s %s" % ( self.code, self.fullname)
nfs4.1/testserver.py +3 -3
@@ -1,7 +1,7 @@ #!/usr/bin/env python # nfs4stest.py - nfsv4 server tester # -# Requires python 2.5 +# Requires python 2.7 # # Written by Fred Isaman <[email protected]> # Copyright (C) 2004 University of Michigan, Center for
@@ -27,8 +27,8 @@ import use_local # HACK so don't have to rebuild constantly import sys -if sys.hexversion < 0x02050000: - print("Requires python 2.5 or higher") +if sys.hexversion < 0x02070000: + print("Requires python 2.7 or higher") sys.exit(1) import os
Signature · 1 line
2.17.1
PATCH 22/24 pynfs: python3 support plan: fix ord() failure on python3
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- nfs4.0/nfs4lib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
nfs4.0/nfs4lib.py +4 -1
@@ -144,7 +144,10 @@ class CBServer(rpc.RPCServer): self.client = client rpc.RPCServer.__init__(self, prog=self.prog, vers=1, port=self.port) packed = struct.pack('>H', self.port) - self.dotport = '.%s.%s' % (ord(packed[0]), ord(packed[1])) + try: #for python2 + self.dotport = '.%s.%s' % (ord(packed[0]), ord(packed[1])) + except: #for python3 + self.dotport = '.%s.%s' % ((packed[0]), (packed[1])) self.nfs4packer = FancyNFS4Packer() self.nfs4unpacker = FancyNFS4Unpacker('') self.recall_lock = threading.Lock()
Signature · 1 line
2.17.1
PATCH 23/24 pynfs: python3 support plan: fix except multi exceptions in one line
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
--- rpc/rpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rpc/rpc.py +1 -1
@@ -613,7 +613,7 @@ class ConnectionHandler(object): msg_data = record[p.get_position():] # RPC payload # Remember length of the header msg.length = p.get_position() - except (rpc_pack.XDRError, EOFError), e: + except (rpc_pack.XDRError, EOFError) as e: log_t.warn("XDRError: %s, dropping packet" % e) log_t.debug("unpacking raised the following error", exc_info=True) self._notify_drop()
Signature · 1 line
2.17.1
PATCH 24/24 pynfs: python3 support plan: fix access class var in list comprehension
In reply to [email protected]From: "Jianhong.Yin" <[email protected]>
---
Status:
'''
all patches works fine on python-2.7
and build success on python-3.6
but because xdrlib issue https://bugs.python.org/issue9544
pynfs has not been able to run on python-3.6 now
'''
nfs4.1/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
nfs4.1/config.py +3 -2
@@ -178,8 +178,9 @@ _invalid_ops = [ class OpsConfigServer(object): __metaclass__ = MetaConfig value = ['ERROR', 0, 0] # Note must have value == _opline(value) - attrs = [ConfigLine(name.lower()[3:], value, "Generic comment", _opline) - for name in nfs_opnum4.values()] + attrs = (lambda value=value: [ConfigLine(name.lower()[3:], value, "Generic comment", _opline) + for name in nfs_opnum4.values()])() + class Actions(object): __metaclass__ = MetaConfig
Signature · 1 line
2.17.1