Bump to 1.3.11-2
[gc-dialer] / dialcentral / dialcentral_qt.py
index a464ad6..eba726c 100755 (executable)
@@ -19,6 +19,7 @@ import alarm_handler
 from util import qtpie
 from util import qwrappers
 from util import qui_utils
+from util import linux as linux_utils
 from util import misc as misc_utils
 
 import session
@@ -30,8 +31,7 @@ _moduleLogger = logging.getLogger(__name__)
 class Dialcentral(qwrappers.ApplicationWrapper):
 
        _DATA_PATHS = [
-               os.path.join(os.path.dirname(__file__), "../share"),
-               os.path.join(os.path.dirname(__file__), "../data"),
+               os.path.join(os.path.dirname(__file__), "data"),
        ]
 
        def __init__(self, app):
@@ -49,8 +49,9 @@ class Dialcentral(qwrappers.ApplicationWrapper):
 
        def load_settings(self):
                try:
+                       settingsPath = linux_utils.get_resource_path("config", constants.__app_name__, "settings.ini")
                        config = ConfigParser.SafeConfigParser()
-                       config.read(constants._user_settings_)
+                       config.read(settingsPath)
                except IOError, e:
                        _moduleLogger.info("No settings")
                        return
@@ -71,7 +72,8 @@ class Dialcentral(qwrappers.ApplicationWrapper):
 
                self._mainWindow.save_settings(config)
 
-               with open(constants._user_settings_, "wb") as configFile:
+               settingsPath = linux_utils.get_resource_path("config", constants.__app_name__, "settings.ini")
+               with open(settingsPath, "wb") as configFile:
                        config.write(configFile)
 
        def get_icon(self, name):
@@ -104,7 +106,7 @@ class Dialcentral(qwrappers.ApplicationWrapper):
 
        @property
        def fsContactsPath(self):
-               return os.path.join(constants._data_path_, "contacts")
+               return linux_utils.get_resource_path("data", constants.__app_name__, "contacts")
 
        @property
        def streamHandler(self):
@@ -259,7 +261,8 @@ class MainWindow(qwrappers.WindowWrapper):
                self._window.resized.connect(self._on_window_resized)
                self._errorLog = self._app.errorLog
 
-               self._session = session.Session(self._errorLog, constants._data_path_)
+               cachePath = linux_utils.get_resource_path("cache", constants.__app_name__)
+               self._session = session.Session(self._errorLog, cachePath)
                self._session.error.connect(self._on_session_error)
                self._session.loggedIn.connect(self._on_login)
                self._session.loggedOut.connect(self._on_logout)
@@ -312,7 +315,7 @@ class MainWindow(qwrappers.WindowWrapper):
                defaultTabIconWidth = max(defaultTabIconWidth, 32)
                defaultTabIconHeight = max(defaultTabIconHeight, 32)
                self._tabWidget.setIconSize(QtCore.QSize(defaultTabIconWidth, defaultTabIconHeight))
-               self._tabWidget.currentChanged.connect(self._on_tab_changed)
+               self._tabWidget.currentChanged[int].connect(self._on_tab_changed)
                self._tabWidget.setContentsMargins(0, 0, 0, 0)
 
                self._layout.addWidget(self._tabWidget)
@@ -421,15 +424,13 @@ class MainWindow(qwrappers.WindowWrapper):
                        orientation = config.get(constants.__pretty_app_name__, "orientation")
                except ConfigParser.NoOptionError, e:
                        _moduleLogger.info(
-                               "Settings file %s is missing option %s" % (
-                                       constants._user_settings_,
+                               "Settings file is missing option %s" % (
                                        e.option,
                                ),
                        )
                except ConfigParser.NoSectionError, e:
                        _moduleLogger.info(
-                               "Settings file %s is missing section %s" % (
-                                       constants._user_settings_,
+                               "Settings file is missing section %s" % (
                                        e.section,
                                ),
                        )
@@ -444,15 +445,13 @@ class MainWindow(qwrappers.WindowWrapper):
                        self._updateVoicemailOnMissedCall = config.getboolean("2 - Account Info", "updateVoicemailOnMissedCall")
                except ConfigParser.NoOptionError, e:
                        _moduleLogger.info(
-                               "Settings file %s is missing option %s" % (
-                                       constants._user_settings_,
+                               "Settings file is missing option %s" % (
                                        e.option,
                                ),
                        )
                except ConfigParser.NoSectionError, e:
                        _moduleLogger.info(
-                               "Settings file %s is missing section %s" % (
-                                       constants._user_settings_,
+                               "Settings file is missing section %s" % (
                                        e.section,
                                ),
                        )
@@ -477,16 +476,14 @@ class MainWindow(qwrappers.WindowWrapper):
                                        settingValue = config.get(sectionName, settingName)
                                except ConfigParser.NoOptionError, e:
                                        _moduleLogger.info(
-                                               "Settings file %s is missing section %s" % (
-                                                       constants._user_settings_,
+                                               "Settings file is missing section %s" % (
                                                        e.section,
                                                ),
                                        )
                                        return
                                except ConfigParser.NoSectionError, e:
                                        _moduleLogger.info(
-                                               "Settings file %s is missing section %s" % (
-                                                       constants._user_settings_,
+                                               "Settings file is missing section %s" % (
                                                        e.section,
                                                ),
                                        )
@@ -762,14 +759,25 @@ class MainWindow(qwrappers.WindowWrapper):
 
 def run():
        try:
-               os.makedirs(constants._data_path_)
+               os.makedirs(linux_utils.get_resource_path("config", constants.__app_name__))
+       except OSError, e:
+               if e.errno != 17:
+                       raise
+       try:
+               os.makedirs(linux_utils.get_resource_path("cache", constants.__app_name__))
+       except OSError, e:
+               if e.errno != 17:
+                       raise
+       try:
+               os.makedirs(linux_utils.get_resource_path("data", constants.__app_name__))
        except OSError, e:
                if e.errno != 17:
                        raise
 
+       logPath = linux_utils.get_resource_path("cache", constants.__app_name__, "%s.log" % constants.__app_name__)
        logFormat = '(%(relativeCreated)5d) %(levelname)-5s %(threadName)s.%(name)s.%(funcName)s: %(message)s'
        logging.basicConfig(level=logging.DEBUG, format=logFormat)
-       rotating = logging.handlers.RotatingFileHandler(constants._user_logpath_, maxBytes=512*1024, backupCount=1)
+       rotating = logging.handlers.RotatingFileHandler(logPath, maxBytes=512*1024, backupCount=1)
        rotating.setFormatter(logging.Formatter(logFormat))
        root = logging.getLogger()
        root.addHandler(rotating)