aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2010-07-14 11:32:24 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2010-07-14 11:32:24 -0300
commit77f0b6480f107b81de5bae1c4fde99f814ce0cf1 (patch)
tree5c4e1b4b63c060abfff39bd722f0335dbccc87ce /g_octave
parentported setup.py (diff)
downloadg-octave-77f0b6480f107b81de5bae1c4fde99f814ce0cf1.tar.gz
g-octave-77f0b6480f107b81de5bae1c4fde99f814ce0cf1.tar.bz2
g-octave-77f0b6480f107b81de5bae1c4fde99f814ce0cf1.zip
ported log.py and config.py
Diffstat (limited to 'g_octave')
-rw-r--r--g_octave/config.py17
-rw-r--r--g_octave/log.py6
2 files changed, 16 insertions, 7 deletions
diff --git a/g_octave/config.py b/g_octave/config.py
index 9dd91f3..7265b7b 100644
--- a/g_octave/config.py
+++ b/g_octave/config.py
@@ -11,13 +11,20 @@
:license: GPL-2, see LICENSE for more details.
"""
+from __future__ import absolute_import
+
__all__ = ['Config']
-import ConfigParser
import json
import os
-from exception import ConfigException
+from .compat import py3k
+from .exception import ConfigException
+
+if py3k:
+ import configparser
+else:
+ import ConfigParser as configparser
class Config(object):
@@ -40,7 +47,7 @@ class Config(object):
def __init__(self, fetch_phase=False, config_file=None, create_dirs=True):
# Config Parser
- self._config = ConfigParser.ConfigParser(self._defaults)
+ self._config = configparser.ConfigParser(self._defaults)
self._fetch_phase = fetch_phase
@@ -62,8 +69,8 @@ class Config(object):
for dir in [_db, _overlay]:
if not os.path.exists(dir) and create_dirs:
- os.makedirs(dir, 0755)
-
+ os.makedirs(dir, 0o755)
+
self.overlay_bootstrap()
self._cache = {}
diff --git a/g_octave/log.py b/g_octave/log.py
index d824feb..c28bcde 100644
--- a/g_octave/log.py
+++ b/g_octave/log.py
@@ -10,10 +10,12 @@
:license: GPL-2, see LICENSE for more details.
"""
+from __future__ import print_function, absolute_import
+
import logging
import sys
-from config import Config
+from .config import Config
conf = Config(fetch_phase=True)
@@ -33,7 +35,7 @@ class Log(object):
has_file = conf.log_file is not None and conf.log_file != ''
has_level = conf.log_level is not None and conf.log_level != ''
if not has_file:
- print >> sys.stderr, 'WARNING: no "log_file" configured. logging disabled.'
+ print('WARNING: no "log_file" configured. logging disabled.', file=sys.stderr)
if not has_file or not has_level:
class NullHandler(logging.Handler):
def emit(self, record):