oerppy-hackers team mailing list archive
-
oerppy-hackers team
-
Mailing list archive
-
Message #00028
[Branch ~oerppy-hackers/oerppy/trunk] Rev 48: Added a permissions change to the config file.
------------------------------------------------------------
revno: 48
committer: duncan@xxxxxxxxxx
branch nick: trunk
timestamp: Thu 2011-06-09 14:58:42 -0600
message:
Added a permissions change to the config file.
modified:
oerppy/tests/test_util.py
oerppy/util.py
--
lp:oerppy
https://code.launchpad.net/~oerppy-hackers/oerppy/trunk
Your team oerppy Hackers is subscribed to branch lp:oerppy.
To unsubscribe from this branch go to https://code.launchpad.net/~oerppy-hackers/oerppy/trunk/+edit-subscription
=== modified file 'oerppy/tests/test_util.py'
--- oerppy/tests/test_util.py 2011-06-09 03:06:38 +0000
+++ oerppy/tests/test_util.py 2011-06-09 20:58:42 +0000
@@ -1,4 +1,4 @@
-import datetime, os, tempfile, unittest
+import datetime, os, stat, tempfile, unittest
from urlparse import urlparse
from oerppy import const, util
@@ -14,6 +14,12 @@
data = util.read_config(self.src, self.fullpath)
self.assertEqual(data, open(self.src).read())
+ def test_write_config(self):
+ tempdir = tempfile.mkdtemp()
+ config_file = util.write_default_config(tempdir)
+ mode = stat.S_IMODE(os.stat(config_file).st_mode)
+ self.assertEqual(mode, int("0600", 8))
+
class ParseUrlTestCase(unittest.TestCase):
"""
=== modified file 'oerppy/util.py'
--- oerppy/util.py 2011-06-09 20:28:52 +0000
+++ oerppy/util.py 2011-06-09 20:58:42 +0000
@@ -20,8 +20,13 @@
"""
src_file = os.path.abspath(const.CONFIG_TEMPLATE)
if not os.path.isfile(src_file):
- raise exceptions.OpenERPPyConfigError(
- "Could not locate default configuration file '%s'." % src_file)
+ src_file = const.CONFIG_TEMPLATE
+ if not os.path.isfile(src_file):
+ src_file = os.path.join("..", const.CONFIG_TEMPLATE)
+ if not os.path.isfile(src_file):
+ raise exceptions.OpenERPPyConfigError(
+ "Could not locate default configuration "
+ "file '%s'." % src_file)
src = open(src_file)
data = src.read()
src.close()
@@ -32,7 +37,9 @@
dest = open(dest_file, "w+")
dest.write(data)
dest.close()
- # XXX set the perms on it to 600
+ # set the perms on it to 600
+ os.chmod(dest_file, 0600)
+ return dest_file
def read_config(default_config="", dest_dir=""):