summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-04-12 08:37:23 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-04-12 08:37:23 -0500
commit33d4e0178b26dc4756a4b933a9f966379ce99453 (patch)
tree70aca363db7712aca983578167bbae6cad844767 /src
parent73effe023b731a7252c6ab75e84f154ed939479a (diff)
downloadbcfg2-33d4e0178b26dc4756a4b933a9f966379ce99453.tar.gz
bcfg2-33d4e0178b26dc4756a4b933a9f966379ce99453.tar.bz2
bcfg2-33d4e0178b26dc4756a4b933a9f966379ce99453.zip
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 <sol.jerome@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Admin/Init.py13
1 files changed, 3 insertions, 10 deletions
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" %