Skip to content
This repository was archived by the owner on Feb 24, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cdtdiagnose.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def cmd(args, input=None, raiseOnFail=True):
)
args = parser.parse_args()

print "Running CDT diagnostics due to test failure."
print("Running CDT diagnostics due to test failure.")
log = []

def error(message, e):
log.append("CDT diagnostic: %s" % (message,))
log.append(str(e))
print "\n".join(log)
print("\n".join(log))
sys.exit(1)

now = datetime.datetime.now()
Expand All @@ -70,11 +70,11 @@ def error(message, e):

if args.directory is not None:
if not os.path.isdir(args.directory):
print "Specified target directory path is invalid, using default."
print("Specified target directory path is invalid, using default.")
else:
dirname = os.path.join(args.directory, dirname)

print "Saving diagnostic archive to: {}".format(dirname,)
print("Saving diagnostic archive to: {}".format(dirname,))
try:
os.mkdir(dirname)
except Exception as e:
Expand Down Expand Up @@ -138,4 +138,4 @@ def error(message, e):
except Exception as e:
error("Could not make diagnostics archive.", e)

print "Saved diagnostics to '%s'" % (archive_name,)
print("Saved diagnostics to '%s'" % (archive_name,))
46 changes: 23 additions & 23 deletions odsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@


def usage():
print """Usage: odsetup [options] create|create-users|remove
print("""Usage: odsetup [options] create|create-users|remove
Options:
-h Print this help and exit
-n node OpenDirectory node to target
Expand All @@ -281,18 +281,18 @@ def usage():
-x disable OD node checks
-v verbose logging
-V very verbose logging
"""
""")


def cmd(args, input=None, raiseOnFail=True):

if veryverbose:
print "-----"
print("-----")
if verbose:
print args.replace(diradmin_pswd, "xxxx")
print(args.replace(diradmin_pswd, "xxxx"))
if veryverbose and input:
print input
print "*****"
print(input)
print("*****")
if input:
p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
result = p.communicate(input)
Expand All @@ -301,8 +301,8 @@ def cmd(args, input=None, raiseOnFail=True):
result = p.communicate()

if veryverbose:
print "Output: %s" % (result[0],)
print "Code: %s" % (p.returncode,)
print("Output: %s" % result[0])
print("Code: %s" % p.returncode)
if raiseOnFail and p.returncode:
raise RuntimeError(result[1])
return result[0], p.returncode
Expand All @@ -319,9 +319,9 @@ def checkDataSource(node):
result = cmd("dscl localhost -list /LDAPv3")
result = ["/LDAPv3/{}".format(subnode) for subnode in result[0].splitlines()]
if len(result) > 1 or result[0] != node:
print "Error: Host is bound to other directory nodes: {}".format(result)
print "CalDAVTester will likely fail with other nodes present."
print "Please remove all nodes except the one being used for odsetup."
print("Error: Host is bound to other directory nodes: {}".format(result))
print("CalDAVTester will likely fail with other nodes present.")
print("Please remove all nodes except the one being used for odsetup.")
sys.exit(1)


Expand Down Expand Up @@ -552,8 +552,8 @@ def loadLists(path, records):

try:
plist = readPlistFromString(result[0])
except xml.parsers.expat.ExpatError, e:
print "Error (%s) parsing (%s)" % (e, result[0])
except xml.parsers.expat.ExpatError as e:
print("Error (%s) parsing (%s)" % (e, result[0]))
raise

for record in plist["result"]:
Expand All @@ -574,7 +574,7 @@ def doToAccounts(odf, protocol, f, users_only=False):
if count > 1:
for ctr in range(1, count + 1):
attrs = {}
for key, value in record[3].iteritems():
for key, value in record[3].items():
if value.find("%02d") != -1:
value = value % (ctr,)
attrs[key] = value
Expand All @@ -598,7 +598,7 @@ def doGroupMemberships(odf):

for groupname, users, nestedgroups in memberships:
if verbose:
print "Group membership: {}".format(groupname)
print("Group membership: {}".format(groupname))

# Get group record
group = odf.lookupRecordName(kDSStdRecordTypeGroups, groupname)
Expand All @@ -620,7 +620,7 @@ def doGroupMemberships(odf):
def createUser(odf, path, user):

if verbose:
print "Create user: {}/{}".format(path, user[0])
print("Create user: {}/{}".format(path, user[0]))

if path in (kDSStdRecordTypeUsers, kDSStdRecordTypeGroups,):
createUserViaDS(odf, path, user)
Expand All @@ -643,7 +643,7 @@ def createUserViaDS(odf, path, user):
record = odf.createRecord(path, user[0], user[1], user[2])
else:
if verbose:
print "%s/%s already exists" % (path, user[0],)
print("%s/%s already exists" % (path, user[0],))

# Now read the guid for this record
if user[0] in guids:
Expand Down Expand Up @@ -692,7 +692,7 @@ def createUserViaGateway(path, user):
def removeUser(odf, path, user):

if verbose:
print "Remove user: {}/{}".format(path, user[0])
print("Remove user: {}/{}".format(path, user[0]))

if path in (kDSStdRecordTypeUsers, kDSStdRecordTypeGroups,):
removeUserViaDS(odf, path, user)
Expand Down Expand Up @@ -815,7 +815,7 @@ def manageRecords(odf, path, user):
elif option == "-x":
node_check = False
else:
print "Unrecognized option: %s" % (option,)
print("Unrecognized option: %s" % option)
usage()
raise ValueError

Expand All @@ -824,15 +824,15 @@ def manageRecords(odf, path, user):

# Process arguments
if len(args) == 0:
print "No arguments given. One of 'create' or 'remove' must be present."
print("No arguments given. One of 'create' or 'remove' must be present.")
usage()
raise ValueError
elif len(args) > 1:
print "Too many arguments given. Only one of 'create' or 'remove' must be present."
print("Too many arguments given. Only one of 'create' or 'remove' must be present.")
usage()
raise ValueError
elif args[0] not in ("create", "create-users", "remove"):
print "Wrong arguments given: %s" % (args[0],)
print("Wrong arguments given: %s" % args[0])
usage()
raise ValueError

Expand Down Expand Up @@ -880,6 +880,6 @@ def manageRecords(odf, path, user):
loadLists(kDSStdRecordTypeResources, resources)
doToAccounts(odf, protocol, removeUser)

except Exception, e:
except Exception:
traceback.print_exc()
sys.exit(1)
10 changes: 4 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
# limitations under the License.
##

from __future__ import print_function

from os.path import dirname, abspath, join as joinpath
from setuptools import setup, find_packages as setuptools_find_packages
import errno
Expand Down Expand Up @@ -62,7 +60,7 @@ def git_info(wc_path):
except subprocess.CalledProcessError:
return None

branch = branch.strip()
branch = branch.decode().strip()

try:
revision = subprocess.check_output(
Expand All @@ -76,7 +74,7 @@ def git_info(wc_path):
except subprocess.CalledProcessError:
return None

revision = revision.strip()
revision = revision.decode().strip()

try:
tag = subprocess.check_output(
Expand All @@ -90,7 +88,7 @@ def git_info(wc_path):
except subprocess.CalledProcessError:
tag = None
else:
tag = tag.strip()
tag = tag.decode().strip()

return dict(
project=base_project,
Expand Down Expand Up @@ -166,7 +164,7 @@ def version():

description = "CalDAV/CardDAV protocol test suite"

long_description = file(joinpath(dirname(__file__), "README.md")).read()
long_description = open(joinpath(dirname(__file__), "README.md")).read()

url = "https://github.com/apple/ccs-caldavtester"

Expand Down
Loading