diff --git a/python/sample.py b/python/sample.py
index 75666308..961214c0 100644
--- a/python/sample.py
+++ b/python/sample.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from __future__ import print_function
import pydmlite
def test():
@@ -7,8 +8,8 @@ def test():
try:
pluginManager = pydmlite.PluginManager()
pluginManager.loadConfiguration(configFile)
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
return
try:
@@ -18,28 +19,28 @@ def test():
group.setUnsigned("gid", 0)
securityContext.user.setUnsigned("uid", 0)
securityContext.groups.append(group)
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
return
try:
stackInstance = pydmlite.StackInstance(pluginManager)
stackInstance.setSecurityContext(securityContext)
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
return
try:
catalog = stackInstance.getCatalog()
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
return
try:
f = catalog.extendedStat("/", True)
- print f.stat.st_ino
- print f.stat.st_size
- except Exception, e:
- print e
+ print(f.stat.st_ino)
+ print(f.stat.st_size)
+ except Exception as e:
+ print(e)
return
test()
diff --git a/shell/src/argus.py b/shell/src/argus.py
index 308dcaa6..b382145d 100644
--- a/shell/src/argus.py
+++ b/shell/src/argus.py
@@ -200,8 +200,8 @@ class ArgusBan(object):
if [x.text for x in actions] != ['.*']: continue
# ignore policies with permit rules
rules = policy.findall("{%(xacml)s}Rule" % ArgusBan._PAP_NS)
- if len(filter(lambda x: x.get('Effect') == 'Permit', rules)) > 0: continue
- for rules in filter(lambda x: x.get('Effect') == 'Deny', rules):
+ if len([x for x in rules if x.get('Effect') == 'Permit']) > 0: continue
+ for rules in [x for x in rules if x.get('Effect') == 'Deny']:
for subject_match in rules.findall("{%(xacml)s}Target/{%(xacml)s}Subjects/{%(xacml)s}Subject/{%(xacml)s}SubjectMatch" % ArgusBan._PAP_NS):
subject_type = subject_match.find("{%(xacml)s}SubjectAttributeDesignator" % ArgusBan._PAP_NS)
subject_value = subject_match.find("{%(xacml)s}AttributeValue" % ArgusBan._PAP_NS)
diff --git a/shell/src/dmlite-mysql-dirspaces.py b/shell/src/dmlite-mysql-dirspaces.py
index 8a74bc60..e1df54e2 100755
--- a/shell/src/dmlite-mysql-dirspaces.py
+++ b/shell/src/dmlite-mysql-dirspaces.py
@@ -305,7 +305,7 @@ class CachedFullPath(object):
elif currid in id2parent:
if currid in revids:
revids.reverse()
- fullpath = '/'.join(map(lambda x: id2name[x], revids))
+ fullpath = '/'.join([id2name[x] for x in revids])
_log.info("db inconsistency: detected directory loop for fileid %i parent %i %s", fileid, currid, fullpath)
for revid in revids: self._cache[revid] = None
revids = []
@@ -318,7 +318,7 @@ class CachedFullPath(object):
if fileid != 0:
if fileid != currid:
revids.reverse()
- fullpath = '/'.join(map(lambda x: id2name[x], revids))
+ fullpath = '/'.join([id2name[x] for x in revids])
_log.info("db inconsistency: could not find path for fileid %i parent %i (most likely the entry is orphan, path %s)", fileid, currid, fullpath)
else:
_log.info("db inconsistency: could not find path for fileid %i (most likely the entry is orphan)", fileid)
@@ -337,7 +337,7 @@ class CachedFullPath(object):
self._cache[revid] = self._cache[currid] + revids[:i+1]
if not self._fileid_only:
if revid in self._cache_path: continue
- pathsuffix = '/'.join(map(lambda x: id2name[x], revids[:i+1]))
+ pathsuffix = '/'.join([id2name[x] for x in revids[:i+1]])
if currid == 0:
self._cache_path[revid] = pathsuffix
elif currid in self._cache_path:
@@ -449,7 +449,7 @@ def get_quotatoken_data(conn):
# sort quotatokens by path length with longest first
# (this ordering is assumed by code calling this function)
- for row in sorted(filter(lambda x: x[0] != None, rows), key=lambda x: len(x[0]), reverse=True):
+ for row in sorted([x for x in rows if x[0] != None], key=lambda x: len(x[0]), reverse=True):
path, poolname, u_token, s_token, t_space, g_space, u_space = row
ret.append((path, poolname, u_token, s_token, t_space, g_space, u_space))
@@ -572,7 +572,7 @@ def fix_spacetokens_by_path(conn_data, skip=[], updatedb=False):
_log.warn("skipping fileid %i, unable to reconstruct its parent %i path (dpm-dbck can correct this problem)", fileid, pfileid)
continue
- qt_selected = filter(lambda x: path.startswith(x[0]), qt)
+ qt_selected = [x for x in qt if path.startswith(x[0])]
if len(qt_selected) == 0:
_log.warn("skipping %s/%s with fileid %i, because it doen't match any quotatoken path", path, name, fileid)
continue
@@ -904,9 +904,9 @@ def fix_dir_size(conn_data, updatelevels, updatedb=False):
if len(curr_psize) > 0:
# try to get real paths for updated directories
- pathnames = pathname.get_ids_multi(curr_psize.keys())
+ pathnames = pathname.get_ids_multi(list(curr_psize.keys()))
pathrealname = CachedFullPath(conn_path)
- pathrealnames = pathrealname.get_path_multi(curr_psize.keys())
+ pathrealnames = pathrealname.get_path_multi(list(curr_psize.keys()))
for fileid in pathnames.keys():
if fileid in pathrealnames:
pathnames[fileid] = pathrealnames[fileid]
@@ -1000,7 +1000,7 @@ def fix_spacetokens_size(conn_data, updatedb=False):
parent_already_accounted = True
if parent_already_accounted: continue
accounted_dirs.append(longer_path)
- path2subid[path] = map(lambda x: path2id[x], accounted_dirs)
+ path2subid[path] = [path2id[x] for x in accounted_dirs]
updated = 0
conn.autocommit(False)
@@ -1013,18 +1013,18 @@ def fix_spacetokens_size(conn_data, updatedb=False):
id2size = {}
qtsubdirids = path2subid[path]
cursor = conn.cursor()
- cursor.execute("SELECT fileid, filesize FROM Cns_file_metadata WHERE fileid IN ({0}) FOR UPDATE".format(','.join(map(lambda x: str(x), [pathid] + qtsubdirids))))
+ cursor.execute("SELECT fileid, filesize FROM Cns_file_metadata WHERE fileid IN ({0}) FOR UPDATE".format(','.join([str(x) for x in [pathid] + qtsubdirids])))
for row in cursor:
fileid, filesize = row
id2size[fileid] = filesize
cursor_dpm = conn_dpm.cursor()
cursor_dpm.execute("SELECT t_space, u_space FROM dpm_space_reserv WHERE path = %s FOR UPDATE", (path, ))
t_space, u_space = cursor_dpm.fetchone()
- pathfreespace = t_space - (id2size[pathid] - sum(map(lambda x: id2size[x], qtsubdirids)))
+ pathfreespace = t_space - (id2size[pathid] - sum([id2size[x] for x in qtsubdirids]))
if u_space != pathfreespace:
_log.info("%supdate spacetoken %s[%s] %.02f%% relative change %i from %i to %i = t_space(%i) - (dirsize(%i) - sum(%s))",
dry_run, path2st[path], path, 100. * (u_space - pathfreespace) / pathfreespace, u_space - pathfreespace, u_space,
- pathfreespace, t_space, id2size[pathid], ','.join(map(lambda x: "{0}({1})".format(id2path[x], id2size[x]), qtsubdirids)))
+ pathfreespace, t_space, id2size[pathid], ','.join(["{0}({1})".format(id2path[x], id2size[x]) for x in qtsubdirids]))
if updatedb:
cursor_dpm.execute("BEGIN") # be explicit
cursor_dpm.execute("UPDATE dpm_space_reserv SET u_space = %s WHERE path = %s", (pathfreespace, path))
@@ -1241,7 +1241,7 @@ if __name__ == '__main__':
_log.error("unknown fix \"%s\", use --help command line option to get more informations", fix)
sys.exit(1)
- if not options.force and len(filter(lambda x: x.endswith('offline'), fix_names)):
+ if not options.force and len([x for x in fix_names if x.endswith('offline')]):
_log.info('DPM must be offline for requested safe DB updates')
# try to open TCP connections to the DPM headnode service ports
diff --git a/shell/src/dmlite-prom.py b/shell/src/dmlite-prom.py
index 2629c3b4..ab9bf211 100755
--- a/shell/src/dmlite-prom.py
+++ b/shell/src/dmlite-prom.py
@@ -15,12 +15,13 @@ import os, sys, re
import optparse
import socket
import logging, logging.handlers
-from io import StringIO
try:
- from urllib.parse import urlparse
+ from io import StringIO
+except ImportError:
+ from StringIO import StringIO
+try:
from urllib.request import urlopen
except ImportError:
- from urlparse import urlparse
from urllib2 import urlopen
__version__ = '0.0.1'
diff --git a/shell/src/dmlite-shell b/shell/src/dmlite-shell
index 2eec3ed8..26d3ec4b 100755
--- a/shell/src/dmlite-shell
+++ b/shell/src/dmlite-shell
@@ -16,6 +16,11 @@ import atexit
import argparse
import logging, logging.handlers
+try:
+ input = raw_input # Redefine for Python 2
+except NameError:
+ pass
+
__version__ = '1.13.3'
_log = logging.getLogger('dmlite-shell')
@@ -149,9 +154,9 @@ def main():
# get next command
try:
if sys.__stdin__.isatty():
- cmdline = raw_input('> ')
+ cmdline = input('> ')
else:
- cmdline = raw_input()
+ cmdline = input()
cmdline = cmdline.strip()
except EOFError:
# all commands from input have been executed, exit...
diff --git a/shell/src/dpm-storage-summary.cgi b/shell/src/dpm-storage-summary.cgi
index 10bc471a..208dbf55 100755
--- a/shell/src/dpm-storage-summary.cgi
+++ b/shell/src/dpm-storage-summary.cgi
@@ -25,7 +25,10 @@ from __future__ import division
import os, sys, time
import socket
-import StringIO
+try:
+ import io as StringIO
+except ImportError:
+ import StringIO
import json
import logging
import logging.handlers
diff --git a/shell/src/dpm-storage-summary.py b/shell/src/dpm-storage-summary.py
index 5670dfef..ff932643 100755
--- a/shell/src/dpm-storage-summary.py
+++ b/shell/src/dpm-storage-summary.py
@@ -23,7 +23,7 @@ _log = logging.getLogger('DPMSRR')
# The top level object
-class storageService:
+class storageService(object):
def __init__(self, config):
self.config = config
diff --git a/shell/src/infoutils.py b/shell/src/infoutils.py
index bfc1e3d9..7e00b196 100755
--- a/shell/src/infoutils.py
+++ b/shell/src/infoutils.py
@@ -1,3 +1,4 @@
+from __future__ import division
import json
import re
import subprocess
@@ -10,7 +11,7 @@ import rpm
from dmliteshell import executor
-class SystemInfo:
+class SystemInfo(object):
"""All necessary info on the DPM and the system"""
def __init__(self, config=None):
@@ -36,7 +37,7 @@ class SystemInfo:
if mi.count() != 1:
return None
else:
- entry = mi.next()
+ entry = next(mi)
return str(entry['version'])
def nameversion(self, packages):
@@ -107,20 +108,20 @@ class SystemInfo:
totalgroups = set([])
for space, qt in jgqt.items():
if isinstance(qt["groups"], dict):
- groups = qt["groups"].values()
+ groups = list(qt["groups"].values())
if isinstance(qt["groups"], list):
groups = qt["groups"]
# don't show "root" qt group unless it is the only group asociated
# with this space, because ldif code rely on non-empty groups
if len(groups) > 1: groups.remove("root")
qt["groups"] = groups
- map(totalgroups.add, groups)
+ list(map(totalgroups.add, groups))
totalcapacity += int(qt["quotatktotspace"])
totalused += int(qt["pathusedspace"])
return jgqt, totalcapacity, totalused, list(totalgroups)
-class Entry:
+class Entry(object):
"""Base class for all GLUE2 entries"""
def __init__(self):
@@ -248,9 +249,9 @@ class StorageServiceCapacity(Entry):
self.name = "GLUE2StorageServiceCapacityID"
self.Attributes["GLUE2StorageServiceCapacityID"] = [hostname + "/StorageServiceCapacity"]
self.Attributes["GLUE2StorageServiceCapacityType"] = ["online"]
- self.Attributes["GLUE2StorageServiceCapacityFreeSize"] = [str((tot - used) / 1024**3)]
- self.Attributes["GLUE2StorageServiceCapacityTotalSize"] = [str(tot / 1024**3)]
- self.Attributes["GLUE2StorageServiceCapacityUsedSize"] = [str(used / 1024**3)]
+ self.Attributes["GLUE2StorageServiceCapacityFreeSize"] = [str((tot - used) // 1024**3)]
+ self.Attributes["GLUE2StorageServiceCapacityTotalSize"] = [str(tot // 1024**3)]
+ self.Attributes["GLUE2StorageServiceCapacityUsedSize"] = [str(used // 1024**3)]
self.Attributes["GLUE2StorageServiceCapacityStorageServiceForeignKey"] = ["Undefined"]
self.Attributes["ObjectClass"] = ["GLUE2StorageServiceCapacity"]
@@ -265,9 +266,9 @@ class DataStore(Entry):
Entry.__init__(self)
self.name = "GLUE2ResourceID"
self.Attributes["GLUE2ResourceID"] = [hostname + "/DataStore"]
- self.Attributes["GLUE2DataStoreTotalSize"] = [str(tot / 1024**3)]
- self.Attributes["GLUE2DataStoreUsedSize"] = [str(used / 1024**3)]
- self.Attributes["GLUE2DataStoreFreeSize"] = [str((tot - used) / 1024**3)]
+ self.Attributes["GLUE2DataStoreTotalSize"] = [str(tot // 1024**3)]
+ self.Attributes["GLUE2DataStoreUsedSize"] = [str(used // 1024**3)]
+ self.Attributes["GLUE2DataStoreFreeSize"] = [str((tot - used) // 1024**3)]
self.Attributes["GLUE2DataStoreType"] = ["disk"]
self.Attributes["GLUE2DataStoreLatency"] = ["online"]
self.Attributes["GLUE2DataStoreStorageManagerForeignKey"] = ["Undefined"]
@@ -344,9 +345,9 @@ class ShareCapacity(Entry):
Entry.__init__(self)
self.name = "GLUE2StorageShareCapacityID"
self.Attributes["GLUE2StorageShareCapacityID"] = [hostname + "/Capacity/" + qtname]
- self.Attributes["GLUE2StorageShareCapacityTotalSize"] = [str(qtspace / 1024**3)]
- self.Attributes["GLUE2StorageShareCapacityUsedSize"] = [str(pathused / 1024**3)]
- self.Attributes["GLUE2StorageShareCapacityFreeSize"] = [str((qtspace - pathused) / 1024**3)]
+ self.Attributes["GLUE2StorageShareCapacityTotalSize"] = [str(qtspace // 1024**3)]
+ self.Attributes["GLUE2StorageShareCapacityUsedSize"] = [str(pathused // 1024**3)]
+ self.Attributes["GLUE2StorageShareCapacityFreeSize"] = [str((qtspace - pathused) // 1024**3)]
self.Attributes["GLUE2StorageShareCapacityType"] = ["online"]
self.Attributes["GLUE2StorageShareCapacityStorageShareForeignKey"] = ["Undefined"]
self.Attributes["ObjectClass"] = ["GLUE2StorageShareCapacity"]
diff --git a/shell/src/interpreter.py b/shell/src/interpreter.py
index d18f918b..94e86ba7 100644
--- a/shell/src/interpreter.py
+++ b/shell/src/interpreter.py
@@ -1,3 +1,6 @@
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import division
# interpreter.py
import pydmlite
@@ -10,19 +13,28 @@ import re
import time
import dateutil.parser
import pycurl
-import urllib
-from dbutils import DPMDB
+try:
+ from urllib.parse import unquote
+except ImportError:
+ from urllib import unquote
+from .dbutils import DPMDB
import threading
-import Queue
+try:
+ import queue as Queue
+except ImportError:
+ import Queue
import signal
import socket
-from executor import DomeExecutor
+from .executor import DomeExecutor
import json
import pprint
-import StringIO
+try:
+ import io as StringIO
+except ImportError:
+ import StringIO
from M2Crypto import X509
-import utils
-import argus
+from . import utils
+from . import argus
try:
import dpm2
@@ -38,7 +50,7 @@ activitystatus = {'UNKNOWN': 0, 'ONLINE': 1, 'DOWN': 2}
activitystatusbycode = dict((v, k) for k, v in activitystatus.items())
-class DMLiteInterpreter:
+class DMLiteInterpreter(object):
"""
A class taking commands as strings and passing them to DMLite via pydmlite.
"""
@@ -260,7 +272,7 @@ class DMLiteInterpreter:
return flist
-class ShellCommand:
+class ShellCommand(object):
"""
An abstract class for deriving classes for supported shell commands.
"""
@@ -507,7 +519,7 @@ class ShellCommand:
if not lastgiven.startswith('/'):
lastgiven = './' + lastgiven
gfolder, gfilestart = os.path.split(lastgiven)
- groot, gdirs, gfiles = os.walk(gfolder).next()
+ groot, gdirs, gfiles = next(os.walk(gfolder))
gfiles = gfiles + list((d + '/') for d in gdirs)
l = list(f for f in gfiles if f.startswith(gfilestart))
elif ptype == 'd': # dmlite file or folder
@@ -1005,7 +1017,7 @@ class InfoCommand(ShellCommand):
self.ok('GUID: ' + str(f.guid))
self.ok('Ino: ' + str(f.stat.st_ino))
- self.ok('Mode: ' + oct(f.stat.st_mode))
+ self.ok('Mode: ' + '0%o' % f.stat.st_mode)
self.ok('# of Links: ' + str(f.stat.st_nlink))
try:
@@ -2631,7 +2643,7 @@ class Response(object):
for marker in self.markers:
if 'success' in marker.lower():
return 0
- elif any(map(lambda x: x in marker.lower(), ['failed', 'aborted', 'failure'])):
+ elif any([x in marker.lower() for x in ['failed', 'aborted', 'failure']]):
return marker
def printMarkers(self):
@@ -2739,7 +2751,7 @@ class Replicate(object):
pass
destination = loc[0].url.toString()
- destination = urllib.unquote(destination)
+ destination = unquote(destination)
#create correct destination url and SFN
sfn = destination[0:destination.index(':') + 1] + destination[destination.index(':') + 1:destination.index('?')]
destination = destination[0:destination.index(':') + 1] + str(http_port) + destination[destination.index(':') + 1:len(destination)]
@@ -3263,18 +3275,18 @@ class DrainReplicas(object):
fileSize = fileSize + file.size
if self.parameters['move']:
self.interpreter.ok("Total replicas to move: " + str(numFiles))
- self.interpreter.ok("Total capacity to move: " + str(fileSize / 1024) + " KB")
+ self.interpreter.ok("Total capacity to move: " + str(fileSize // 1024) + " KB")
else:
self.interpreter.ok("Total replicas installed in the FS to drain: " + str(numFiles))
- self.interpreter.ok("Total capacity installed in the FS to drain: " + str(fileSize / 1024) + " KB")
+ self.interpreter.ok("Total capacity installed in the FS to drain: " + str(fileSize // 1024) + " KB")
#in case the size is != 100, we should limit the number of replicas to drain
sizeToDrain = fileSize
if self.parameters['size'] != 100:
- sizeToDrain = sizeToDrain * self.parameters['size'] / 100
+ sizeToDrain = sizeToDrain * self.parameters['size'] // 100
if not self.parameters['move']:
self.interpreter.ok("Percentage of capacity to drain: " + str(self.parameters['size']) + " %")
- self.interpreter.ok("Total capacity to drain: " + str(sizeToDrain / 1024) + " KB")
+ self.interpreter.ok("Total capacity to drain: " + str(sizeToDrain // 1024) + " KB")
for file in self.fileReplicas:
if (self.parameters['group'] != "ALL"):
diff --git a/src/dome/cli/dome.py b/src/dome/cli/dome.py
index 56af6f63..95be9127 100755
--- a/src/dome/cli/dome.py
+++ b/src/dome/cli/dome.py
@@ -4,11 +4,12 @@
This file implements the Dome CLI.
The CLI provides an easy access to many features of the Dome Service
"""
+from __future__ import print_function
+from __future__ import absolute_import
import os
-import ConfigParser
import sys
from optparse import OptionParser
-from executor import DomeExecutor
+from .executor import DomeExecutor
def main():
# parse options
@@ -31,7 +32,7 @@ def main():
if options.execute:
if not options.url:
- print "Please specify the url via --url option"
+ print("Please specify the url via --url option")
sys.exit(1)
executor = DomeExecutor("/etc/grid-security/dpmmgr/dpmcert.pem", "/etc/grid-security/dpmmgr/dpmkey.pem",
"/etc/grid-security/certificates", options.clientDN, options.clientAddr)
@@ -40,81 +41,81 @@ def main():
if options.execute == 'get':
if not options.lfn:
- print "Please specify the LFN via --lfn option"
+ print("Please specify the LFN via --lfn option")
sys.exit(1)
if not options.pfn:
- print "Please specify the PFN via --pfn option"
+ print("Please specify the PFN via --pfn option")
sys.exit(1)
if not options.server:
- print "Please specify the Server via --server option"
+ print("Please specify the Server via --server option")
sys.exit(1)
if not options.fs:
- print "Please specify the Filesystem via --fs option"
+ print("Please specify the Filesystem via --fs option")
sys.exit(1)
executor.get(options.url,options.lfn, options.pfn,options.server,options.fs)
if options.execute == 'put':
if not options.lfn:
- print "Please specify the LFN via --lfn option"
+ print("Please specify the LFN via --lfn option")
sys.exit(1)
executor.put(options.url,options.lfn)
elif options.execute == 'putdone':
if not options.pfn:
- print "Please specify the PFN via --pfn option"
+ print("Please specify the PFN via --pfn option")
sys.exit(1)
if not options.size:
- print "Please specify the Server via --size option"
+ print("Please specify the Server via --size option")
sys.exit(1)
executor.putDone(options.url, options.pfn,options.size)
elif options.execute == 'getspaceinfo':
executor.getSpaceInfo(options.url)
elif options.execute == 'statpool':
if not options.pool:
- print "Please specify the Pool to stat via --pool option"
+ print("Please specify the Pool to stat via --pool option")
sys.exit(1)
executor.statPool(options.url,options.pool)
elif options.execute == 'getquotatoken':
if not options.lfn:
- print "Please specify the LFN via --lfn option"
+ print("Please specify the LFN via --lfn option")
sys.exit(1)
executor.getquotatoken(options.url,options.lfn)
elif options.execute == 'setquotatoken':
if not options.lfn:
- print "Please specify the LFN via --lfn option"
+ print("Please specify the LFN via --lfn option")
sys.exit(1)
if not options.pool:
- print "Please specify the Pool to set the quota token via --pool option"
+ print("Please specify the Pool to set the quota token via --pool option")
sys.exit(1)
if not options.space:
- print "Please specify the Space for the quota token via --space option"
+ print("Please specify the Space for the quota token via --space option")
sys.exit(1)
if not options.desc:
- print "Please specify the Space for the quota token description via --desc option"
+ print("Please specify the Space for the quota token description via --desc option")
sys.exit(1)
executor.setquotatoken(options.url,options.lfn,options.pool, options.space,options.desc)
elif options.execute == 'delquotatoken':
if not options.lfn:
- print "Please specify the LFN via --lfn option"
+ print("Please specify the LFN via --lfn option")
sys.exit(1)
if not options.pool:
- print "Please specify the Pool to set the quota token via --pool option"
+ print("Please specify the Pool to set the quota token via --pool option")
sys.exit(1)
executor.delquotatoken(options.url,options.lfn,options.pool)
elif options.execute == 'getdirspaces':
if not options.lfn:
- print "Please specify the LFN via --lfn option"
+ print("Please specify the LFN via --lfn option")
sys.exit(1)
executor.getdirspaces(options.url,options.lfn)
elif options.execute == "pfnrm":
if not options.pfn:
- print "Please specify the PFN via --pfn option"
+ print("Please specify the PFN via --pfn option")
sys.exit(1)
executor.pfnrm(options.url,options.pfn)
elif options.execute == "delreplica":
if not options.pfn:
- print "Please specify the PFN via --pfn option"
+ print("Please specify the PFN via --pfn option")
sys.exit(1)
if not options.server:
- print "Please specify the Server via --server option"
+ print("Please specify the Server via --server option")
sys.exit(1)
executor.delreplica(options.url,options.pfn,options.server)
diff --git a/src/dome/cli/executor.py b/src/dome/cli/executor.py
index 53e541bc..46cdde32 100644
--- a/src/dome/cli/executor.py
+++ b/src/dome/cli/executor.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from subprocess import Popen, PIPE, STDOUT
from pipes import quote
import os
diff --git a/tests/dpm/dpm-tester.py b/tests/dpm/dpm-tester.py
index 7308b010..0d637b61 100755
--- a/tests/dpm/dpm-tester.py
+++ b/tests/dpm/dpm-tester.py
@@ -2,7 +2,10 @@
from __future__ import print_function, division, absolute_import
import gfal2
-import StringIO
+try:
+ import io as StringIO
+except ImportError:
+ import StringIO
import traceback
import datetime
import time
@@ -13,7 +16,10 @@ import inspect
import os
import filecmp
import hashlib
-import urllib
+try:
+ from urllib.parse import quote, unquote
+except ImportError:
+ from urllib import quote, unquote
import signal
import stat
import sys
@@ -22,7 +28,10 @@ import textwrap
import json
import subprocess
import random
-from urlparse import urlparse
+try:
+ from urllib.parse import urlparse
+except ImportError:
+ from urlparse import urlparse
EX_OK = 0
EX_WARNING = 1
@@ -164,7 +173,7 @@ def get_test_number():
return TEST_NUMBER
-class TestResult:
+class TestResult(object):
"""A class to store and display the results from a single test run"""
def __init__(self, prefix, name):
self.prefix = prefix
@@ -221,7 +230,7 @@ class TestResult:
@staticmethod
def show_skipped(prefix, name, indent=""):
if USE_XML:
- print("""<testcase name="{0:02d} {1}" classname="{2}" time="0">""".format(get_test_number(), urllib.quote(name), prefix))
+ print("""<testcase name="{0:02d} {1}" classname="{2}" time="0">""".format(get_test_number(), quote(name), prefix))
print("""<skipped/></testcase>""")
return
@@ -247,7 +256,7 @@ class TestResult:
return strio.getvalue()
def show_xml(self):
- print("""<testcase name="{0:02d} {1}" classname="{2}" time="{3}">""".format(get_test_number(), urllib.quote(self.name), self.prefix,
+ print("""<testcase name="{0:02d} {1}" classname="{2}" time="{3}">""".format(get_test_number(), quote(self.name), self.prefix,
duration_in_sec(self.starttime, self.endtime)))
if not self.ok():
@@ -285,7 +294,7 @@ class ThreadExc(threading.Thread):
self.exception = e
# Wraps the result from the execution of a gfal function
-class GfalStatus:
+class GfalStatus(object):
def __init__(self, output, exception, traceback, timed_out):
self.output = output
self.traceback = traceback
@@ -404,7 +413,7 @@ class DomeCredentials(object):
self.clientDN = clientDN
self.clientAddress = clientAddress
-class DomeTalker:
+class DomeTalker(object):
"""Issues requests to Dome"""
@staticmethod
@@ -446,7 +455,7 @@ class DomeTalker:
result.write(f("Davix exit code: {proc.returncode}"))
return result
-class DomeTester:
+class DomeTester(object):
def __init__(self, uri):
self.uri = uri
self.ctx = gfal2.creat_context()
@@ -534,7 +543,7 @@ def ensure_safe_path(path):
# assumption: second will always contain a single chunk, ie don't pass
# "/dir1/" along with "/dir2/file"
def path_join(first, second):
- second = urllib.quote(second)
+ second = quote(second)
if first.endswith("/"):
return first + second
@@ -568,7 +577,7 @@ def hammer_tester(functions, arguments):
if result.alive(): result.success()
return result
-class ProtocolTester:
+class ProtocolTester(object):
def __init__(self, testcase):
self.ctx = gfal2.creat_context()
@@ -906,7 +915,7 @@ def calculate_checksum(checksumtype, filename):
if checksumtype == "md5":
return hashlib.md5(open(filename, 'rb').read()).hexdigest()
-class Runner:
+class Runner(object):
def __init__(self, function, args, name):
self.function = function
self.args = args
@@ -927,7 +936,7 @@ class Runner:
# Run a series of tests, optionally with initialization and cleanup.
# You can also nest orchestrators together, but be careful.
-class Orchestrator:
+class Orchestrator(object):
def __init__(self, prefix=""):
self.prefix = prefix
self.initialization = []
@@ -1145,10 +1154,10 @@ def build_target_url(args, scheme):
return path_join(build_base_url(args, scheme), args.testdir)
def extract_path(url):
- return urllib.unquote(urlparse(url).path)
+ return unquote(urlparse(url).path)
def extract_file(url):
- return urllib.unquote(url.split("/")[-1])
+ return unquote(url.split("/")[-1])
def single_protocol_tests(args, scope):
tester = ProtocolTester(scope)
diff --git a/tests/python/catalog.py b/tests/python/catalog.py
index e77e73d1..c329f4c5 100644
--- a/tests/python/catalog.py
+++ b/tests/python/catalog.py
@@ -20,7 +20,7 @@ class TestDmliteCatalog(unittest.TestCase):
self.manager = pydmlite.PluginManager()
try :
self.manager.loadConfiguration(self.conf_file)
- except Exception, err:
+ except Exception as err:
self.fail("%s" % err)
self.stack = pydmlite.StackInstance(self.manager)
self.creds = pydmlite.SecurityCredentials()
@@ -30,7 +30,7 @@ class TestDmliteCatalog(unittest.TestCase):
try:
self.stack.setSecurityCredentials(self.creds)
- except Exception, err:
+ except Exception as err:
self.fail("%s" % err)
def tearDown(self):
@@ -72,17 +72,17 @@ class TestDmliteCatalog(unittest.TestCase):
catalog = self.stack.getCatalog()
try:
catalog.changeDir(self.path)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
try:
- catalog.makeDir(self.newdir,0775) # create a test dir
- except Exception, err:
+ catalog.makeDir(self.newdir,0o775) # create a test dir
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
try:
- catalog.setMode(self.newdir,0777) # change mode from 0775 to 0777
- except Exception, err:
+ catalog.setMode(self.newdir,0o777) # change mode from 0775 to 0777
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
return 0
@@ -91,7 +91,7 @@ class TestDmliteCatalog(unittest.TestCase):
mydirpath = self.path + "/" + self.newdir
try:
xstat = catalog.extendedStat(mydirpath, True)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
self.assertEquals(xstat.name,self.newdir) # checking the directory name
@@ -106,18 +106,18 @@ class TestDmliteCatalog(unittest.TestCase):
self.assertTrue(deltatimed < 4) # checking the time to create the directory
self.assertEquals(xstat.stat.st_blksize,0)
self.assertEquals(xstat.stat.st_size, 0)
- self.assertEquals(str(oct(xstat.stat.st_mode)),"040777") # checking the mode
+ self.assertEquals(xstat.stat.st_mode, 0o40777) # checking the mode
def test_rmdir(self):
catalog = self.stack.getCatalog()
try:
catalog.changeDir(self.path)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
arg = self.path + "/" + self.rmdir
try:
catalog.removeDir(arg)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
return 0
@@ -125,22 +125,22 @@ class TestDmliteCatalog(unittest.TestCase):
catalog = self.stack.getCatalog()
try:
catalog.changeDir(self.path)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
try:
- catalog.create(self.newfile, 0775) # create a test file
- except Exception, err:
+ catalog.create(self.newfile, 0o775) # create a test file
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
try:
xstat = catalog.extendedStat(self.newfile, True)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(erra))
return 1
try:
- catalog.setMode(self.newfile,0777) # change mode from 0775 to 0777
- except Exception, err:
+ catalog.setMode(self.newfile,0o777) # change mode from 0775 to 0777
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
return 0
@@ -149,7 +149,7 @@ class TestDmliteCatalog(unittest.TestCase):
filevername = self.path + "/" + self.newfile
try:
xstat = catalog.extendedStat(filevername,True)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(erra))
return 1
self.assertFalse(xstat.stat.isDir())
@@ -159,7 +159,7 @@ class TestDmliteCatalog(unittest.TestCase):
self.assertTrue(xstat.stat.isReg())
self.assertTrue(stat.S_ISREG(xstat.stat.st_mode))
self.assertEquals(xstat.name, self.newfile) # checking the file name
- self.assertEquals(str(oct(xstat.stat.st_mode)),"0100777") # checking the file mode
+ self.assertEquals(xstat.stat.st_mode, 0o100777) # checking the file mode
self.assertTrue(xstat.stat.st_ino > 0)
self.assertEquals(xstat.stat.st_nlink, 1)
deltatime = time.time() - xstat.stat.getMTime()
@@ -173,18 +173,18 @@ class TestDmliteCatalog(unittest.TestCase):
catalog = self.stack.getCatalog()
try:
catalog.changeDir(self.path)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
try:
catalog.symlink(self.newfile, self.newlink)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
name = self.path + "/" + self.newlink
try:
filename = catalog.readLink(name)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
return 0
@@ -192,7 +192,7 @@ class TestDmliteCatalog(unittest.TestCase):
catalog = self.stack.getCatalog()
try:
xstat = catalog.extendedStat(self.newlink,False)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
self.assertFalse(xstat.stat.isDir())
@@ -200,7 +200,7 @@ class TestDmliteCatalog(unittest.TestCase):
self.assertTrue(xstat.stat.isLnk())
self.assertEquals(xstat.name,self.newlink) # checking the link name
self.assertEquals(catalog.readLink(self.newlink),self.newfile) # checking of the link (newlink->newfile)
- self.assertEquals(str(oct(xstat.stat.st_mode)),"0120777") # checking the link mode
+ self.assertEquals(xstat.stat.st_mode, 0o120777) # checking the link mode
self.assertTrue(xstat.stat.st_ino > 0)
self.assertEquals(xstat.stat.st_nlink, 1)
deltatimel = time.time() - xstat.stat.getMTime()
@@ -212,12 +212,12 @@ class TestDmliteCatalog(unittest.TestCase):
catalog = self.stack.getCatalog()
try:
catalog.changeDir(self.path)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
try:
catalog.unlink (self.newlink)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
return 0
@@ -226,17 +226,17 @@ class TestDmliteCatalog(unittest.TestCase):
catalog = self.stack.getCatalog()
try:
catalog.changeDir(self.path)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
try:
xstat = catalog.extendedStat(self.newfile,True)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
return 1
try:
catalog.unlink(self.newfile)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('file is removed: %s\n' % str(err))
return 1
return 0
diff --git a/tests/python/catalog_first.py b/tests/python/catalog_first.py
index eb75bb1f..4a544e5b 100755
--- a/tests/python/catalog_first.py
+++ b/tests/python/catalog_first.py
@@ -13,7 +13,7 @@ class TestDmliteCatalog(unittest.TestCase):
self.manager = pydmlite.PluginManager()
try :
self.manager.loadConfiguration(self.conf_file)
- except Exception, err:
+ except Exception as err:
self.fail("%s" % err)
self.stack = pydmlite.StackInstance(self.manager)
self.creds = pydmlite.SecurityCredentials()
@@ -23,7 +23,7 @@ class TestDmliteCatalog(unittest.TestCase):
try:
self.stack.setSecurityCredentials(self.creds)
- except Exception, err:
+ except Exception as err:
self.fail("%s" % err)
def tearDown(self):
diff --git a/tests/python/dm-ls.py b/tests/python/dm-ls.py
index c0420283..c6a152fe 100755
--- a/tests/python/dm-ls.py
+++ b/tests/python/dm-ls.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import print_function
import pydmlite
import sys
import time
@@ -10,14 +11,14 @@ if __name__ == "__main__":
l=0
# print len
if len < 3 or sys.argv[1] == "-h":
- print "Usage:", sys.argv[0], "[-l] <configuration file> <path>"
+ print("Usage:", sys.argv[0], "[-l] <configuration file> <path>")
sys.exit(1)
# print sys.argv[1]
if sys.argv[1] == "-l" :
l=1
try :
manager.loadConfiguration(sys.argv[l+1])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
stack = pydmlite.StackInstance(manager)
@@ -29,7 +30,7 @@ if __name__ == "__main__":
try:
stack.setSecurityCredentials(creds)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
catalog = stack.getCatalog()
@@ -46,10 +47,10 @@ if __name__ == "__main__":
# print "\t%s" % xstat.name, " is link to ", filename
ltime = time.localtime(xstat.stat.getMTime())
date=datetime(ltime[0],ltime[1],ltime[2],ltime[3],ltime[4],ltime[5])
- print "%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" %xstat.name, "->",filename
+ print("%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" %xstat.name, "->",filename)
sys.exit(0)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
flag = xstat.stat.isDir()
@@ -59,7 +60,7 @@ if __name__ == "__main__":
catalog = stack.getCatalog()
try :
mydir = catalog.openDir(inputname)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
while True:
@@ -83,13 +84,13 @@ if __name__ == "__main__":
filename = catalog.readLink(name)
ltime = time.localtime(xstat.stat.getMTime())
date=datetime(ltime[0],ltime[1],ltime[2],ltime[3],ltime[4],ltime[5])
- print "%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % f.name, "->",filename
+ print("%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % f.name, "->",filename)
continue
ltime = time.localtime(xstat.stat.getMTime())
date=datetime(ltime[0],ltime[1],ltime[2],ltime[3],ltime[4],ltime[5])
- print "%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % f.name
+ print("%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % f.name)
else :
- print "\t%s" % f.name
+ print("\t%s" % f.name)
except:
catalog.closeDir(mydir)
break
@@ -97,8 +98,8 @@ if __name__ == "__main__":
if l>0 :
ltime = time.localtime(xstat.stat.getMTime())
date=datetime(ltime[0],ltime[1],ltime[2],ltime[3],ltime[4],ltime[5])
- print "%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % xstat.name
+ print("%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % xstat.name)
else :
- print "\t%s" % xstat.name
+ print("\t%s" % xstat.name)
sys.exit(0)
diff --git a/tests/python/dm-mkdir.py b/tests/python/dm-mkdir.py
index d5fe47da..c6d165b6 100755
--- a/tests/python/dm-mkdir.py
+++ b/tests/python/dm-mkdir.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import print_function
import pydmlite
import sys
@@ -8,12 +9,12 @@ if __name__ == "__main__":
l=0
# print len
if len < 3 or sys.argv[1] == "-h":
- print "Usage:", sys.argv[0], " <configuration file> <path> <dir> [<mode>]"
+ print("Usage:", sys.argv[0], " <configuration file> <path> <dir> [<mode>]")
sys.exit(1)
# print sys.argv[1]
try :
manager.loadConfiguration(sys.argv[1])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
@@ -29,22 +30,22 @@ if __name__ == "__main__":
catalog = stack.getCatalog()
try:
catalog.changeDir(sys.argv[2])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
try:
- catalog.makeDir(sys.argv[3],0777)
- except Exception, err:
+ catalog.makeDir(sys.argv[3],0o777)
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
- print sys.argv[3]," was created"
+ print(sys.argv[3]," was created")
if len == 5 :
try:
mode = int(sys.argv[4],8)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
- print sys.argv[3],"%o" % mode
+ print(sys.argv[3],"%o" % mode)
catalog.setMode(sys.argv[3],mode)
# arg = sys.argv[2] + "/" + sys.argv[3]
# catalog.removeDir(arg)
diff --git a/tests/python/dm-mkfile.py b/tests/python/dm-mkfile.py
index 380c5931..607318f4 100755
--- a/tests/python/dm-mkfile.py
+++ b/tests/python/dm-mkfile.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import print_function
import pydmlite
import sys
import time
@@ -9,11 +10,11 @@ if __name__ == "__main__":
len = len(sys.argv)
l=0
if len < 4 or sys.argv[1] == "-h":
- print "Usage:", sys.argv[0], " <configuration file> <path> <file> [<mode>]"
+ print("Usage:", sys.argv[0], " <configuration file> <path> <file> [<mode>]")
sys.exit(1)
try:
manager.loadConfiguration(sys.argv[1])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
stack = pydmlite.StackInstance(manager)
@@ -25,36 +26,36 @@ if __name__ == "__main__":
try:
stack.setSecurityCredentials(creds)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
catalog = stack.getCatalog()
try:
catalog.changeDir(sys.argv[2])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
try:
- catalog.create(sys.argv[3], 0775) # create a test file
- except Exception, err:
+ catalog.create(sys.argv[3], 0o775) # create a test file
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
try:
xstat = catalog.extendedStat(sys.argv[3], True)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
ltime = time.localtime(xstat.stat.getMTime())
- print "create a test file", "\t%s" % xstat.name
+ print("create a test file", "\t%s" % xstat.name)
date=datetime(ltime[0],ltime[1],ltime[2],ltime[3],ltime[4],ltime[5])
- print "%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % xstat.name
+ print("%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % xstat.name)
if len == 5 :
try :
mode = int(sys.argv[4],8)
# print "%o" % mode
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
@@ -64,6 +65,6 @@ if __name__ == "__main__":
# print "%o" % xstat.stat.st_mode
ltime = time.localtime(xstat.stat.getMTime())
date=datetime(ltime[0],ltime[1],ltime[2],ltime[3],ltime[4],ltime[5])
- print "change mode from 775 to ", "%o" % mode
- print "%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % xstat.name
+ print("change mode from 775 to ", "%o" % mode)
+ print("%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % xstat.name)
sys.exit(0)
diff --git a/tests/python/dm-mklink.py b/tests/python/dm-mklink.py
index e54b9d37..2f776fe4 100755
--- a/tests/python/dm-mklink.py
+++ b/tests/python/dm-mklink.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import print_function
import pydmlite
import sys
@@ -8,12 +9,12 @@ if __name__ == "__main__":
l=0
# print len
if len < 5 or sys.argv[1] == "-h":
- print "Usage:", sys.argv[0], " <configuration file> <path> <dir/file> <ln> "
+ print("Usage:", sys.argv[0], " <configuration file> <path> <dir/file> <ln> ")
sys.exit(1)
# print sys.argv[1]
try :
manager.loadConfiguration(sys.argv[1])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
@@ -29,17 +30,17 @@ if __name__ == "__main__":
catalog = stack.getCatalog()
try:
catalog.changeDir(sys.argv[2])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
try:
catalog.symlink(sys.argv[3],sys.argv[4])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
name = sys.argv[2] + sys.argv[4]
filename = catalog.readLink(name)
- print sys.argv[4], "->",filename
+ print(sys.argv[4], "->",filename)
# catalog.setMode(sys.argv[4],120777)
# arg = sys.argv[2] + "/" + sys.argv[3]
# catalog.removeDir(arg)
diff --git a/tests/python/dm-physicallocation.py b/tests/python/dm-physicallocation.py
index 1b468bb1..a0133bee 100755
--- a/tests/python/dm-physicallocation.py
+++ b/tests/python/dm-physicallocation.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import print_function
import pydmlite
import sys
@@ -6,11 +7,11 @@ if __name__ == "__main__":
manager = pydmlite.PluginManager()
if len(sys.argv) < 3:
- print "Usage:", sys.argv[0], "<configuration file> <path>"
+ print("Usage:", sys.argv[0], "<configuration file> <path>")
sys.exit(1)
try :
manager.loadConfiguration(sys.argv[1])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
stack = pydmlite.StackInstance(manager)
@@ -21,18 +22,18 @@ if __name__ == "__main__":
creds.fqans.append("dteam")
try :
stack.setSecurityCredentials(creds)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
poolManager = stack.getPoolManager()
try :
location = poolManager.whereToRead(sys.argv[2])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
for l in location:
- print "Chunk: %s:%s (%d-%d)" % (l.host, l.path, l.offset, l.offset + l.size)
+ print("Chunk: %s:%s (%d-%d)" % (l.host, l.path, l.offset, l.offset + l.size))
for k in l.getKeys():
- print "\t%s: %s" % (k, l.getString(k))
+ print("\t%s: %s" % (k, l.getString(k)))
sys.exit(0)
diff --git a/tests/python/dm-rmdir.py b/tests/python/dm-rmdir.py
index 59971fe8..6eb950a0 100755
--- a/tests/python/dm-rmdir.py
+++ b/tests/python/dm-rmdir.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import print_function
import pydmlite
import sys
@@ -8,12 +9,12 @@ if __name__ == "__main__":
l=0
# print len
if len < 3 or sys.argv[1] == "-h":
- print "Usage:", sys.argv[0], " <configuration file> <path> <dir> "
+ print("Usage:", sys.argv[0], " <configuration file> <path> <dir> ")
sys.exit(1)
# print sys.argv[1]
try :
manager.loadConfiguration(sys.argv[1])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
@@ -29,14 +30,14 @@ if __name__ == "__main__":
catalog = stack.getCatalog()
try:
catalog.changeDir(sys.argv[2])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
arg = sys.argv[2] + "/" + sys.argv[3]
try :
catalog.removeDir(arg)
- print arg," was removed"
+ print(arg," was removed")
sys.exit(0)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
diff --git a/tests/python/dm-rmfile.py b/tests/python/dm-rmfile.py
index 4a2f1dfc..de68ef2b 100755
--- a/tests/python/dm-rmfile.py
+++ b/tests/python/dm-rmfile.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import print_function
import pydmlite
import sys
import time
@@ -9,11 +10,11 @@ if __name__ == "__main__":
len = len(sys.argv)
l=0
if len < 4 or sys.argv[1] == "-h":
- print "Usage:", sys.argv[0], " <configuration file> <path> <file> "
+ print("Usage:", sys.argv[0], " <configuration file> <path> <file> ")
sys.exit(1)
try:
manager.loadConfiguration(sys.argv[1])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
stack = pydmlite.StackInstance(manager)
@@ -25,31 +26,31 @@ if __name__ == "__main__":
try:
stack.setSecurityCredentials(creds)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
catalog = stack.getCatalog()
try:
catalog.changeDir(sys.argv[2])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
try:
xstat = catalog.extendedStat(sys.argv[3], True)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
ltime = time.localtime(xstat.stat.getMTime())
- print "file exists: "
+ print("file exists: ")
date=datetime(ltime[0],ltime[1],ltime[2],ltime[3],ltime[4],ltime[5])
- print "%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % xstat.name
+ print("%o" % xstat.stat.st_mode, "\t", "\t", xstat.stat.st_uid, "\t", xstat.stat.st_gid, '\t', xstat.stat.st_size, "\t", date, "\t%s" % xstat.name)
catalog.unlink(sys.argv[3])
try:
xstat = catalog.extendedStat(sys.argv[3], True)
- except Exception, err:
+ except Exception as err:
sys.stderr.write('file is removed: %s\n' % str(err))
sys.exit(0)
# sys.exit(0)
diff --git a/tests/python/dm-rmlink.py b/tests/python/dm-rmlink.py
index 1091ea7c..3104444a 100755
--- a/tests/python/dm-rmlink.py
+++ b/tests/python/dm-rmlink.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import print_function
import pydmlite
import sys
@@ -8,12 +9,12 @@ if __name__ == "__main__":
l=0
# print len
if len < 3 or sys.argv[1] == "-h":
- print "Usage:", sys.argv[0], " <configuration file> <path> <ln> "
+ print("Usage:", sys.argv[0], " <configuration file> <path> <ln> ")
sys.exit(1)
# print sys.argv[1]
try :
manager.loadConfiguration(sys.argv[1])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
@@ -29,12 +30,12 @@ if __name__ == "__main__":
catalog = stack.getCatalog()
try:
catalog.changeDir(sys.argv[2])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
try :
catalog.unlink (sys.argv[3])
- except Exception, err:
+ except Exception as err:
sys.stderr.write('ERROR: %s\n' % str(err))
sys.exit(1)
# arg = sys.argv[2] + "/" + sys.argv[3]