From patchwork Tue Jul 24 07:33:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianhong Yin X-Patchwork-Id: 10541421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B0015184F for ; Tue, 24 Jul 2018 07:34:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9669128759 for ; Tue, 24 Jul 2018 07:34:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AB8C2875E; Tue, 24 Jul 2018 07:34:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB6C12875C for ; Tue, 24 Jul 2018 07:34:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388428AbeGXIj0 (ORCPT ); Tue, 24 Jul 2018 04:39:26 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53708 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388421AbeGXIj0 (ORCPT ); Tue, 24 Jul 2018 04:39:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C53E840241D3; Tue, 24 Jul 2018 07:34:18 +0000 (UTC) Received: from dhcp-12-115.nay.redhat.com (unknown [10.66.12.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39903178B3; Tue, 24 Jul 2018 07:34:16 +0000 (UTC) From: jiyin@redhat.com To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org, "Jianhong.Yin" Subject: [PATCH 14/24] pynfs: python3 support plan: Relative Import -> Absolute Import Date: Tue, 24 Jul 2018 15:33:32 +0800 Message-Id: <20180724073342.5738-14-jiyin@redhat.com> In-Reply-To: <20180724073342.5738-1-jiyin@redhat.com> References: <20180724073342.5738-1-jiyin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Jul 2018 07:34:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Jul 2018 07:34:18 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jiyin@redhat.com' RCPT:'' Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Jianhong.Yin" Signed-off-by: Jianhong Yin --- 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(-) diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py index be14658..86075b2 100644 --- a/nfs4.0/lib/rpc/rpc.py +++ b/nfs4.0/lib/rpc/rpc.py @@ -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 diff --git a/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py b/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py index ee6ad53..1b5eb93 100644 --- a/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py +++ b/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py @@ -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 * diff --git a/nfs4.0/lib/rpc/rpcsec/sec_auth_none.py b/nfs4.0/lib/rpc/rpcsec/sec_auth_none.py index 7058203..ec8896a 100644 --- a/nfs4.0/lib/rpc/rpcsec/sec_auth_none.py +++ b/nfs4.0/lib/rpc/rpcsec/sec_auth_none.py @@ -1,4 +1,4 @@ -from base import SecFlavor +from .base import SecFlavor class SecAuthNone(SecFlavor): pass diff --git a/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py b/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py index 27fc52e..778d379 100644 --- a/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py +++ b/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py @@ -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 diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py index 6f6d2f9..79e386e 100644 --- a/nfs4.0/nfs4lib.py +++ b/nfs4.0/nfs4lib.py @@ -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() diff --git a/xdr/xdrgen.py b/xdr/xdrgen.py index 6303184..abfc8d7 100755 --- a/xdr/xdrgen.py +++ b/xdr/xdrgen.py @@ -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))