1. fak3
  2. gosvideo

Commits

fak3  committed f892f78

conf.py - verbose os.path error

  • Participants
  • Parent commits cb0fa19
  • Branches default

Comments (0)

Files changed (1)

File conf.py

View file
  • Ignore whitespace
+# -*- coding: utf-8 -*-
 
-# This file is part of Gosvideo. 
+# This file is part of Gosvideo.
 # Gosvideo is a tool for ordering and downloading video files from http://www.gosuslugi.ru/.
 
 # Copyright (C) 2012  Evstifeev Roman <someuniquename@gmail.com>
 # along with Gosvideo.  If not, see <http://www.gnu.org/licenses/>.
 # See file LICENSE.txt in the source code tree
 
-import os, sys
+import os, sys, logging
 from utils import safe_path
 
 DEBUG = False
 PROG_DIR = safe_path(os.path.dirname(__file__))
 
 if sys.platform == 'win32' and PROG_DIR.endswith('.exe'):
-    # this must be py2exe bundle, go one level up 
+    # this must be py2exe bundle, go one level up
     PROG_DIR = os.path.dirname(PROG_DIR)
-    
+
     # explicitly set certificates path for py2exe
-    os.environ['REQUESTS_CA_BUNDLE'] = os.path.join(PROG_DIR, 'certs', 'cacert.pem')
-    
+    try:
+        os.environ['REQUESTS_CA_BUNDLE'] = os.path.join(PROG_DIR, 'certs', 'cacert.pem')
+    except Exception as e:
+        logging.error(u'\n*** Произошла ошибка! ***')
+        logging.error(u'Невозможно запустить программу из текущей директроии %s', PROG_DIR)
+        logging.error(u'Вероятно полный путь содержит символы, которые невозможно перекодировать')
+        logging.error(u'Попробуйте переместить программу в корень диска %s', PROG_DIR[0:2])
+
     sys.path.insert(0, PROG_DIR) # "orders" package should be copied there to make south migrations work
-    
 
 rel = lambda *args: os.path.join(PROG_DIR, *args)
 
 
 SHARED_DIR = safe_path(os.path.expanduser('~/gosvideo'))
 
-if not os.path.exists(SHARED_DIR): 
+if not os.path.exists(SHARED_DIR):
     os.makedirs(SHARED_DIR)
-    
+
 srel = lambda *args: os.path.join(SHARED_DIR, *args)
 
 MIN_VIDEOLEN = 60*29 + 50
         #'ENGINE': 'django.db.backends.dummy',
         'NAME': srel('oders.sqlite'),
         #'TEST_NAME': srel('oders_test.sqlite'),
-        'TEST_NAME': '/dev/shm/oders_test.sqlite',
+        'TEST_NAME': 'Z:/dev/shm/oders_test.sqlite' if sys.platform == 'win32' else '/dev/shm/oders_test.sqlite',
         #'NAME': '/dev/shm/oders2.sqlite',
         #'NAME': '/dev/shm/oders4.sqlite',
         #'OPTIONS': {
     from conf_local import *
 except ImportError:
     pass
-