summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xapi/examples/getvolfile.py2
-rw-r--r--contrib/ipaddr-py/ipaddr.py4
-rwxr-xr-xcontrib/ipaddr-py/ipaddr_test.py7
-rwxr-xr-xextras/create_new_xlator/generate_xlator.py2
-rwxr-xr-xextras/prot_filter.py2
-rwxr-xr-xextras/snap_scheduler/gcron.py7
-rwxr-xr-xextras/snap_scheduler/snap_scheduler.py18
-rw-r--r--extras/volfilter.py2
-rwxr-xr-xlibglusterfs/src/generator.py2
-rwxr-xr-xtests/features/ipctest.py2
-rwxr-xr-xtests/utils/create-files.py10
-rw-r--r--tools/glusterfind/src/brickfind.py4
-rw-r--r--tools/glusterfind/src/changelog.py6
-rw-r--r--tools/glusterfind/src/main.py4
-rw-r--r--tools/glusterfind/src/nodeagent.py6
-rw-r--r--tools/glusterfind/src/utils.py6
-rw-r--r--xlators/features/glupy/examples/negative.py2
-rw-r--r--xlators/features/glupy/src/glupy/__init__.py4
18 files changed, 45 insertions, 45 deletions
diff --git a/api/examples/getvolfile.py b/api/examples/getvolfile.py
index f1d5761d6b1..9a5dd0d290a 100755
--- a/api/examples/getvolfile.py
+++ b/api/examples/getvolfile.py
@@ -34,7 +34,7 @@ if __name__ == "__main__":
import sys
try:
- res = apply(get_volfile, sys.argv[1:3])
+ res = get_volfile(*sys.argv[1:3])
except:
print("fetching volfile failed (volume not started?)")
diff --git a/contrib/ipaddr-py/ipaddr.py b/contrib/ipaddr-py/ipaddr.py
index 07fc873fb15..6ebd22a33ce 100644
--- a/contrib/ipaddr-py/ipaddr.py
+++ b/contrib/ipaddr-py/ipaddr.py
@@ -1222,7 +1222,7 @@ class IPv4Network(_BaseV4, _BaseNet):
"""
# the valid octets for host and netmasks. only useful for IPv4.
- _valid_mask_octets = set((255, 254, 252, 248, 240, 224, 192, 128, 0))
+ _valid_mask_octets = {255, 254, 252, 248, 240, 224, 192, 128, 0}
def __init__(self, address, strict=False):
"""Instantiate a new IPv4 network object.
@@ -1465,7 +1465,7 @@ class _BaseV6(object):
try:
# Now, parse the hextets into a 128-bit integer.
- ip_int = 0L
+ ip_int = 0
for i in xrange(parts_hi):
ip_int <<= 16
ip_int |= self._parse_hextet(parts[i])
diff --git a/contrib/ipaddr-py/ipaddr_test.py b/contrib/ipaddr-py/ipaddr_test.py
index 642466fa2ce..c56ecb5c4b1 100755
--- a/contrib/ipaddr-py/ipaddr_test.py
+++ b/contrib/ipaddr-py/ipaddr_test.py
@@ -265,7 +265,7 @@ class IpaddrUnitTest(unittest.TestCase):
'2001:658:22a:cafe:200::1')
def testGetNetmask(self):
- self.assertEqual(int(self.ipv4.netmask), 4294967040L)
+ self.assertEqual(int(self.ipv4.netmask), 4294967040)
self.assertEqual(str(self.ipv4.netmask), '255.255.255.0')
self.assertEqual(str(self.ipv4_hostmask.netmask), '255.0.0.0')
self.assertEqual(int(self.ipv6.netmask),
@@ -282,7 +282,7 @@ class IpaddrUnitTest(unittest.TestCase):
self.assertTrue(ipv6_zero_netmask._is_valid_netmask(str(0)))
def testGetBroadcast(self):
- self.assertEqual(int(self.ipv4.broadcast), 16909311L)
+ self.assertEqual(int(self.ipv4.broadcast), 16909311)
self.assertEqual(str(self.ipv4.broadcast), '1.2.3.255')
self.assertEqual(int(self.ipv6.broadcast),
@@ -681,8 +681,7 @@ class IpaddrUnitTest(unittest.TestCase):
ip3 = ipaddr.IPNetwork('10.10.10.2/31')
ip4 = ipaddr.IPNetwork('10.10.10.2')
sorted = [ip1, ip2, ip3, ip4]
- unsorted = [ip2, ip4, ip1, ip3]
- unsorted.sort()
+ unsorted = sorted([ip2, ip4, ip1, ip3])
self.assertEqual(sorted, unsorted)
unsorted = [ip4, ip1, ip3, ip2]
unsorted.sort()
diff --git a/extras/create_new_xlator/generate_xlator.py b/extras/create_new_xlator/generate_xlator.py
index 3af7ac48d54..1647efa2618 100755
--- a/extras/create_new_xlator/generate_xlator.py
+++ b/extras/create_new_xlator/generate_xlator.py
@@ -36,7 +36,7 @@ def get_error_arg(type_str):
def get_param(names, types):
# Convert two separate tuples to one of (name, type) sub-tuples.
- as_tuples = zip(types, names)
+ as_tuples = list(zip(types, names))
# Convert each sub-tuple into a "type name" string.
as_strings = map(string.join, as_tuples)
# Join all of those into one big string.
diff --git a/extras/prot_filter.py b/extras/prot_filter.py
index 0c48fd5b8e1..0e3e72cf461 100755
--- a/extras/prot_filter.py
+++ b/extras/prot_filter.py
@@ -42,7 +42,7 @@ class Translator:
def load (path):
# If it's a string, open it; otherwise, assume it's already a
# file-like object (most notably from urllib*).
- if type(path) in types.StringTypes:
+ if type(path) in (str,):
fp = file(path,"r")
else:
fp = path
diff --git a/extras/snap_scheduler/gcron.py b/extras/snap_scheduler/gcron.py
index 3f2ba388ccc..8324231a82c 100755
--- a/extras/snap_scheduler/gcron.py
+++ b/extras/snap_scheduler/gcron.py
@@ -122,12 +122,13 @@ def main():
global start_time
if sys.argv[1] == "--update":
if not os.path.exists(GCRON_TASKS):
- # Create a flag in /var/run/gluster which indicates that this nodes
- # doesn't have access to GCRON_TASKS right now, so that
+ # Create a flag in /var/run/gluster which indicates that this
+ # node doesn't have access to GCRON_TASKS right now, so that
# when the mount is available and GCRON_TASKS is available
# the flag will tell this routine to reload GCRON_CROND_TASK
try:
- f = os.open(GCRON_RELOAD_FLAG, os.O_CREAT | os.O_NONBLOCK, 0644)
+ f = os.open(GCRON_RELOAD_FLAG,
+ os.O_CREAT | os.O_NONBLOCK, 0o644)
os.close(f)
except OSError as (errno, strerror):
if errno != EEXIST:
diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py
index a22c0bccbf3..e461ef4f1dc 100755
--- a/extras/snap_scheduler/snap_scheduler.py
+++ b/extras/snap_scheduler/snap_scheduler.py
@@ -207,7 +207,7 @@ def enable_scheduler():
os.remove(GCRON_TASKS)
try:
f = os.open(GCRON_ENABLED, os.O_CREAT | os.O_NONBLOCK,
- 0644)
+ 0o644)
os.close(f)
except OSError as (errno, strerror):
log.error("Failed to open %s. Error: %s.",
@@ -262,7 +262,7 @@ def disable_scheduler():
os.remove(GCRON_DISABLED)
if os.path.lexists(GCRON_TASKS):
os.remove(GCRON_TASKS)
- f = os.open(GCRON_DISABLED, os.O_CREAT, 0644)
+ f = os.open(GCRON_DISABLED, os.O_CREAT, 0o644)
os.close(f)
os.symlink(GCRON_DISABLED, GCRON_TASKS)
log.info("Snapshot scheduling is disabled")
@@ -363,7 +363,7 @@ def list_schedules():
def write_tasks_to_file():
try:
- with open(TMP_FILE, "w", 0644) as f:
+ with open(TMP_FILE, "w", 0o644) as f:
# If tasks is empty, just create an empty tmp file
if len(tasks) != 0:
for key in sorted(tasks):
@@ -388,7 +388,7 @@ def write_tasks_to_file():
def update_current_scheduler(data):
try:
- with open(TMP_FILE, "w", 0644) as f:
+ with open(TMP_FILE, "w", 0o644) as f:
f.write("%s" % data)
f.flush()
os.fsync(f.fileno())
@@ -457,7 +457,7 @@ def add_schedules(jobname, schedule, volname):
job_lockfile = LOCK_FILE_DIR + jobname
try:
f = os.open(job_lockfile, os.O_CREAT | os.O_NONBLOCK,
- 0644)
+ 0o644)
os.close(f)
except OSError as (errno, strerror):
log.error("Failed to open %s. Error: %s.",
@@ -643,7 +643,7 @@ def initialise_scheduler():
return ret
try:
- with open(TMP_FILE, "w+", 0644) as f:
+ with open(TMP_FILE, "w+", 0o644) as f:
updater = ("* * * * * root PATH=$PATH:/usr/local/sbin:"
"/usr/sbin gcron.py --update\n")
f.write("%s\n" % updater)
@@ -659,7 +659,7 @@ def initialise_scheduler():
if not os.path.lexists(GCRON_TASKS):
try:
- f = open(GCRON_TASKS, "w", 0644)
+ f = open(GCRON_TASKS, "w", 0o644)
f.close()
except IOError as (errno, strerror):
log.error("Failed to open %s. Error: %s.", GCRON_TASKS, strerror)
@@ -902,7 +902,7 @@ def main(argv):
return INTERNAL_ERROR
if not os.path.exists(GCRON_ENABLED):
- f = os.open(GCRON_ENABLED, os.O_CREAT | os.O_NONBLOCK, 0644)
+ f = os.open(GCRON_ENABLED, os.O_CREAT | os.O_NONBLOCK, 0o644)
os.close(f)
if not os.path.exists(LOCK_FILE_DIR):
@@ -916,7 +916,7 @@ def main(argv):
return INTERNAL_ERROR
try:
- f = os.open(LOCK_FILE, os.O_CREAT | os.O_RDWR | os.O_NONBLOCK, 0644)
+ f = os.open(LOCK_FILE, os.O_CREAT | os.O_RDWR | os.O_NONBLOCK, 0o644)
try:
fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
ret = perform_operation(args)
diff --git a/extras/volfilter.py b/extras/volfilter.py
index d242e60dcba..79be8f7c378 100644
--- a/extras/volfilter.py
+++ b/extras/volfilter.py
@@ -83,7 +83,7 @@ class Translator:
def load (path):
# If it's a string, open it; otherwise, assume it's already a
# file-like object (most notably from urllib*).
- if type(path) in types.StringTypes:
+ if type(path) in (str,):
fp = file(path,"r")
else:
fp = path
diff --git a/libglusterfs/src/generator.py b/libglusterfs/src/generator.py
index 29e02782638..09f9727f760 100755
--- a/libglusterfs/src/generator.py
+++ b/libglusterfs/src/generator.py
@@ -718,7 +718,7 @@ def get_subs (names, types, cbktypes=None):
sdict = {}
sdict["@SHORT_ARGS@"] = string.join(names,", ")
# Convert two separate tuples to one of (name, type) sub-tuples.
- as_tuples = zip(types,names)
+ as_tuples = list(zip(types,names))
# Convert each sub-tuple into a "type name" string.
as_strings = map(string.join,as_tuples)
# Join all of those into one big string.
diff --git a/tests/features/ipctest.py b/tests/features/ipctest.py
index a8de3936b27..4417493a0ae 100755
--- a/tests/features/ipctest.py
+++ b/tests/features/ipctest.py
@@ -23,7 +23,7 @@ if __name__ == "__main__":
import sys
try:
- res = apply(do_ipc,sys.argv[1:3])
+ res = do_ipc(*sys.argv[1:3])
print(res)
except:
print("IPC failed (volume not started?)")
diff --git a/tests/utils/create-files.py b/tests/utils/create-files.py
index 71f967f4fdb..594072a359a 100755
--- a/tests/utils/create-files.py
+++ b/tests/utils/create-files.py
@@ -51,7 +51,7 @@ def os_rd(src, size):
def os_wr(dest, data):
global timr
st = time.time()
- fd = os.open(dest, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0644)
+ fd = os.open(dest, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o644)
os.write(fd, data)
os.close(fd)
ed = time.time()
@@ -88,7 +88,7 @@ def create_txt_file(fil, size, mins, maxs, rand):
else:
data = os_rd("/etc/services", 512*1024)
file_size = 0
- fd = os.open(fil, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0644)
+ fd = os.open(fil, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o644)
while file_size < size:
os.write(fd, data)
file_size += 500*1024
@@ -323,9 +323,9 @@ def human2bytes(size):
def bytes2human(byts):
abbr = {
- 1 << 30L: "GB",
- 1 << 20L: "MB",
- 1 << 10L: "KB",
+ 1 << 30: "GB",
+ 1 << 20: "MB",
+ 1 << 10: "KB",
1: "bytes"
}
if byts == 1:
diff --git a/tools/glusterfind/src/brickfind.py b/tools/glusterfind/src/brickfind.py
index 6b430d3b9d2..e24fb1f0bdf 100644
--- a/tools/glusterfind/src/brickfind.py
+++ b/tools/glusterfind/src/brickfind.py
@@ -13,7 +13,7 @@ import os
import sys
import logging
from argparse import ArgumentParser, RawDescriptionHelpFormatter
-import urllib
+import urllib.request, urllib.parse, urllib.error
import time
from utils import mkdirp, setup_logger, create_file, output_write, find
@@ -84,7 +84,7 @@ if __name__ == "__main__":
args = _get_args()
session_dir = os.path.join(conf.get_opt("session_dir"), args.session)
status_file = os.path.join(session_dir, args.volume,
- "%s.status" % urllib.quote_plus(args.brick))
+ "%s.status" % urllib.parse.quote_plus(args.brick))
status_file_pre = status_file + ".pre"
mkdirp(os.path.join(session_dir, args.volume), exit_on_err=True,
logger=logger)
diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py
index b124ae7e168..608b5c7c2de 100644
--- a/tools/glusterfind/src/changelog.py
+++ b/tools/glusterfind/src/changelog.py
@@ -16,7 +16,7 @@ import xattr
import logging
from argparse import ArgumentParser, RawDescriptionHelpFormatter
import hashlib
-import urllib
+import urllib.request, urllib.parse, urllib.error
import codecs
import libgfchangelog
@@ -243,7 +243,7 @@ def get_changes(brick, hash_dir, log_file, start, end, args):
session_dir = os.path.join(conf.get_opt("session_dir"),
args.session)
status_file = os.path.join(session_dir, args.volume,
- "%s.status" % urllib.quote_plus(args.brick))
+ "%s.status" % urllib.parse.quote_plus(args.brick))
# Get previous session
try:
@@ -380,7 +380,7 @@ if __name__ == "__main__":
session_dir = os.path.join(conf.get_opt("session_dir"), args.session)
status_file = os.path.join(session_dir, args.volume,
- "%s.status" % urllib.quote_plus(args.brick))
+ "%s.status" % urllib.parse.quote_plus(args.brick))
status_file_pre = status_file + ".pre"
mkdirp(os.path.join(session_dir, args.volume), exit_on_err=True,
logger=logger)
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
index 3e7a729338c..2b782c8dca4 100644
--- a/tools/glusterfind/src/main.py
+++ b/tools/glusterfind/src/main.py
@@ -503,13 +503,13 @@ def write_output(outfile, outfilemerger, field_separator):
continue
if row_2_rep and row_2_rep != "":
- f.write(u"{0}{1}{2}{3}{4}\n".format(row[0],
+ f.write("{0}{1}{2}{3}{4}\n".format(row[0],
field_separator,
p_rep,
field_separator,
row_2_rep))
else:
- f.write(u"{0}{1}{2}\n".format(row[0],
+ f.write("{0}{1}{2}\n".format(row[0],
field_separator,
p_rep))
diff --git a/tools/glusterfind/src/nodeagent.py b/tools/glusterfind/src/nodeagent.py
index e921bc0df43..c337964c7db 100644
--- a/tools/glusterfind/src/nodeagent.py
+++ b/tools/glusterfind/src/nodeagent.py
@@ -14,7 +14,7 @@ import sys
import os
import logging
from argparse import ArgumentParser, RawDescriptionHelpFormatter
-import urllib
+import urllib.request, urllib.parse, urllib.error
from errno import ENOTEMPTY
from utils import setup_logger, mkdirp, handle_rm_error
@@ -49,7 +49,7 @@ def mode_create(args):
session_dir = os.path.join(conf.get_opt("session_dir"),
args.session)
status_file = os.path.join(session_dir, args.volume,
- "%s.status" % urllib.quote_plus(args.brick))
+ "%s.status" % urllib.parse.quote_plus(args.brick))
mkdirp(os.path.join(session_dir, args.volume), exit_on_err=True,
logger=logger)
@@ -64,7 +64,7 @@ def mode_create(args):
def mode_post(args):
session_dir = os.path.join(conf.get_opt("session_dir"), args.session)
status_file = os.path.join(session_dir, args.volume,
- "%s.status" % urllib.quote_plus(args.brick))
+ "%s.status" % urllib.parse.quote_plus(args.brick))
mkdirp(os.path.join(session_dir, args.volume), exit_on_err=True,
logger=logger)
diff --git a/tools/glusterfind/src/utils.py b/tools/glusterfind/src/utils.py
index c24258e6ef8..b376241820b 100644
--- a/tools/glusterfind/src/utils.py
+++ b/tools/glusterfind/src/utils.py
@@ -36,10 +36,10 @@ class RecordType(object):
def cache_output(func):
def wrapper(*args, **kwargs):
global cache_data
- if cache_data.get(func.func_name, None) is None:
- cache_data[func.func_name] = func(*args, **kwargs)
+ if cache_data.get(func.__name__, None) is None:
+ cache_data[func.__name__] = func(*args, **kwargs)
- return cache_data[func.func_name]
+ return cache_data[func.__name__]
return wrapper
diff --git a/xlators/features/glupy/examples/negative.py b/xlators/features/glupy/examples/negative.py
index e44ff4deed2..543f3109502 100644
--- a/xlators/features/glupy/examples/negative.py
+++ b/xlators/features/glupy/examples/negative.py
@@ -62,7 +62,7 @@ class xlator (Translator):
if cache.has_key(pargfid):
cache[pargfid].add(name)
else:
- cache[pargfid] = set([name])
+ cache[pargfid] = {name}
del self.requests[key]
dl.unwind_lookup(frame,cookie,this,op_ret,op_errno,
inode,buf,xdata,postparent)
diff --git a/xlators/features/glupy/src/glupy/__init__.py b/xlators/features/glupy/src/glupy/__init__.py
index b9fc3700fa6..16ff3101de8 100644
--- a/xlators/features/glupy/src/glupy/__init__.py
+++ b/xlators/features/glupy/src/glupy/__init__.py
@@ -240,8 +240,8 @@ def _init_op (a_class, fop, cbk, wind, unwind):
# Decorators, used by translators. We could pass the signatures as
# parameters, but it's actually kind of nice to keep them around for
# inspection.
- a_class.fop_type = apply(CFUNCTYPE,a_class.fop_sig)
- a_class.cbk_type = apply(CFUNCTYPE,a_class.cbk_sig)
+ a_class.fop_type = CFUNCTYPE(*a_class.fop_sig)
+ a_class.cbk_type = CFUNCTYPE(*a_class.cbk_sig)
# Dispatch-function registration.
fop.restype = None
fop.argtypes = [ c_long, a_class.fop_type ]