changeset 27:1b4a20ee4b42

Made the Windows guard function fit the other function patterns. IN: -
author John Schneiderman <JohnMS@CodeGNU.com>
date Thu, 31 Jul 2014 20:51:22 -0500
parents 795d652ed4f3
children 13f4dad3c9ad
files src/manager.py
diffstat 1 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/manager.py	Thu Jul 31 20:40:48 2014 -0500
+++ b/src/manager.py	Thu Jul 31 20:51:22 2014 -0500
@@ -463,31 +463,31 @@
 	# Ensure the repository details isn't accidentally modified.
 	os.chmod(config, hgrcMode & (~stat.S_IWUSR & ~stat.S_IWGRP & ~stat.S_IWOTH))
 
-	# Ensure the repository isn't accidentally deleted, moved, or blocked.
+	# Ensure the repository isn't accidentally deleted, moved, or blocked in Windows.
 	if "win32" == sys.platform:
-		status = __guardWindowsRepository(repo)
-		if 0 != status:
-			exit(status)
+		if __guardWindowsRepository(repo):
+			print 'Secured repository store in Windows.'
+		else:
+			print >>sys.stderr, 'Failed to secure repository store in Windows.'
+			return False
 	return True
 
 def __guardWindowsRepository(repo):
-	""" Guards the supplied repository when on a Windows system.
+	""" Guards the supplied repository for a repository on a Windows system.
 
 	 @param[in] repo	The targeted repository for which to secure.
 
-	 @return The exit status value from securing the repository. The value will
-	  be zero upon success, all other values indicate failure.
+	 @return When the process is successful gives true, else-wise false.
 	"""
 	import subprocess
 	import os
-	import sys
 
-	status = subprocess.call(["attrib.exe", '+H', '+I', '+S', settings.RepositoryPath + os.sep + repo.StorageName + os.sep + '.hg'])
-	if 0 == status:
-		print "Secured repository store."
-	else:
-		print >>sys.stderr, "Failed to secure repository store.", status
-	return status
+	try:
+		status = subprocess.call(["attrib.exe", '+H', '+I', '+S', settings.RepositoryPath + os.sep + repo.StorageName + os.sep + '.hg'])
+	except OSError as e:
+		print >>sys.stderr, "Windows Guard error({0}): {1}".format(e.errno, e.strerror)
+		return False
+	return (0 == status)
 
 def __registerRepository(repo):
 	""" Adds the registration details of the repository.