diff options
| author | Kaleb S. KEITHLEY <kkeithle@redhat.com> | 2018-06-07 12:27:23 -0400 | 
|---|---|---|
| committer | Kaleb S. KEITHLEY <kkeithle@redhat.com> | 2018-06-07 12:37:43 -0400 | 
| commit | ee75c5abc41f43aa79b5e758e43f70a92672d3a2 (patch) | |
| tree | 67433fa9021a2f85b861f8dbee0df3a46ae04e45 /extras/quota | |
| parent | d788cc59b1cd4278ca0b8b2d9f6fe93f80550af3 (diff) | |
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/,
    https://review.gluster.org/#/c/19871/,
    https://review.gluster.org/#/c/19952/, and
    https://review.gluster.org/#/c/20104/
    https://review.gluster.org/#/c/20162/
This patch changes uses of map() and raise(), and a few cases of print()
that were overlooked in the prior patch that fixed print.
Note: Fedora packaging guidelines require explicit shebangs, so popular
practices like #!/usr/bin/env python and #!/usr/bin/python are not
allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3
Note: Selected small fixes from 2to3 utility. Specifically apply,
basestring, funcattrs, idioms, numliterals, set_literal, types, urllib,
zip, map, and raise have already been applied. Also version agnostic
imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested
 by Aravinda in https://review.gluster.org/#/c/19767/1
Note: these 2to3 fixes report no changes are necessary: asserts, buffer,
exec, execfile, exitfunc, filter, getcwdu, intern, itertools, metaclass,
methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce,
reload, renames, repr, standarderror, sys_exc, throw, tuple_params,
xreadlines.
Change-Id: Id62ea491e4ab5dd390075c5c6d9d889cf6f9da27
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'extras/quota')
| -rwxr-xr-x | extras/quota/quota_fsck.py | 31 | 
1 files changed, 16 insertions, 15 deletions
diff --git a/extras/quota/quota_fsck.py b/extras/quota/quota_fsck.py index 0ca93a4b7d9..e2bb580dd5d 100755 --- a/extras/quota/quota_fsck.py +++ b/extras/quota/quota_fsck.py @@ -12,6 +12,7 @@     later), or the GNU General Public License, version 2 (GPLv2), in all     cases as published by the Free Software Foundation.  ''' +from __future__ import print_function  import os, sys, re  from stat import *  import subprocess @@ -51,17 +52,17 @@ epilog_msg='''  def print_msg(log_type, path, xattr_dict = {}, stbuf = "", dir_size = None):      if log_type == QUOTA_VERBOSE: -        print '%-24s %-60s\nxattr_values: %s\n%s\n' % ("Verbose", path ,  xattr_dict, stbuf) +        print('%-24s %-60s\nxattr_values: %s\n%s\n' % {"Verbose", path ,  xattr_dict, stbuf})      elif log_type == QUOTA_META_ABSENT: -        print '%-24s %-60s\n%s\n' % ("Quota-Meta Absent", path , xattr_dict) +        print('%-24s %-60s\n%s\n' % {"Quota-Meta Absent", path , xattr_dict})      elif log_type == QUOTA_SIZE_MISMATCH: -        print "mismatch" +        print("mismatch")          if dir_size is not None: -            print '%24s %60s %12s %12s' % ("Size Mismatch",path , xattr_dict['contri_size'], -                   dir_size) +            print('%24s %60s %12s %12s' % {"Size Mismatch", path , xattr_dict['contri_size'], +                   dir_size})          else: -            print '%-24s %-60s %-12i %-12i' % ("Size Mismatch",path , xattr_dict['contri_size'], -                   stbuf.st_size) +            print('%-24s %-60s %-12i %-12i' % {"Size Mismatch", path , xattr_dict['contri_size'], +                   stbuf.st_size})  def size_differs_lot(s1, s2):      ''' @@ -119,12 +120,12 @@ def fix_xattr(file_name, mark_dirty):      if mnt_path is None:          return      if mark_dirty: -        print "MARKING DIRTY: " + file_name +        print("MARKING DIRTY: " + file_name)          out = subprocess.check_output (["/usr/bin/setfattr", "-n",                                         "trusted.glusterfs.quota.dirty",                                         "-v", IS_DIRTY, file_name])      rel_path = os.path.relpath(file_name, brick_path) -    print "stat on "  + mnt_path + "/" + rel_path +    print("stat on "  + mnt_path + "/" + rel_path)      stbuf = os.lstat(mnt_path + "/" + rel_path)      obj_fix_count += 1 @@ -175,7 +176,7 @@ def get_quota_xattr_brick(dpath):                  xattr_dict['version'] = xattr_version              else:                  if xattr_version != xattr_dict['version']: -                   print "Multiple xattr version found" +                   print("Multiple xattr version found")              cur_parent = xattr_key.split(".")[3] @@ -280,7 +281,7 @@ def walktree(t_dir, hard_link_dict):          if S_ISDIR(stbuf.st_mode):              # It's a directory, recurse into it              if entry == '.glusterfs': -                print "skipping " + pathname +                print("skipping " + pathname)                  continue              descendent_hardlinks = {}              subtree_size = walktree(pathname, descendent_hardlinks) @@ -317,7 +318,7 @@ def walktree(t_dir, hard_link_dict):          else:              # Unknown file type, print a message -            print 'Skipping %s, due to file mode' % pathname +            print('Skipping %s, due to file mode' % (pathname))      if t_dir not in aggr_size:          aggr_size[t_dir] = 0 @@ -372,7 +373,7 @@ if __name__ == '__main__':      else:          walktree(brick_path, hard_link_dict) -    print "Files verified : " + str(file_count) -    print "Directories verified : " + str(dir_count) +    print("Files verified : " + str(file_count)) +    print("Directories verified : " + str(dir_count))      if mnt_path is not None: -        print "Objects Fixed : " + str(obj_fix_count) +        print("Objects Fixed : " + str(obj_fix_count))  | 
