From 33d4e0178b26dc4756a4b933a9f966379ce99453 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Tue, 12 Apr 2011 08:37:23 -0500 Subject: Init: Fix SyntaxError (Reported by emias on IRC) Python < 2.6 uses the '0600' format for specifying the mode while 2.6 and later allow the use of '0o600'. Since python 3 forces the latter, we can use the stat module to maintain compatibility with both. Signed-off-by: Sol Jerome --- src/lib/Server/Admin/Init.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index eddbd732a..9771fd10b 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -2,6 +2,7 @@ import getpass import os import random import socket +import stat import string import subprocess import Bcfg2.Server.Admin @@ -137,11 +138,7 @@ def create_key(hostname, keypath, certpath, country, state, location): keypath, certpath)) subprocess.call((ccstr), shell=True) - # py3k compatibility - try: - os.chmod(keypath, 0600) - except SyntaxError: - os.chmod(keypath, 0o600) + os.chmod(keypath, stat.S_IRUSR|stat.S_IWUSR) # 0600 def create_conf(confpath, confdata): @@ -159,11 +156,7 @@ def create_conf(confpath, confdata): return try: open(confpath, "w").write(confdata) - # py3k compatibility - try: - os.chmod(keypath, 0600) - except SyntaxError: - os.chmod(keypath, 0o600) + os.chmod(keypath, stat.S_IRUSR|stat.S_IWUSR) # 0600 except Exception, e: print("Error %s occured while trying to write configuration " "file to '%s'.\n" % -- cgit v1.2.3-1-g7c22