Beispiel #1
0
def get_library_path(parent=None):
    library_path = prefs['library_path']
    if library_path is None:  # Need to migrate to new database layout
        base = os.path.expanduser('~')
        if iswindows:
            base = winutil.special_folder_path(winutil.CSIDL_PERSONAL)
            if not base or not os.path.exists(base):
                from PyQt4.Qt import QDir
                base = unicode(QDir.homePath()).replace('/', os.sep)
        candidate = choose_dir(None, 'choose calibre library',
                _('Choose a location for your calibre e-book library'),
                default_dir=base)
        if not candidate:
            candidate = os.path.join(base, 'Calibre Library')
        library_path = os.path.abspath(candidate)
    if not os.path.exists(library_path):
        try:
            os.makedirs(library_path)
        except:
            error_dialog(parent, _('Failed to create library'),
                    _('Failed to create calibre library at: %r.')%library_path,
                    det_msg=traceback.format_exc(), show=True)
            library_path = choose_dir(parent, 'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
    return library_path
Beispiel #2
0
def get_library_path(parent=None):
    library_path = prefs['library_path']
    if library_path is None:  # Need to migrate to new database layout
        base = os.path.expanduser('~')
        if iswindows:
            base = winutil.special_folder_path(winutil.CSIDL_PERSONAL)
            if not base or not os.path.exists(base):
                from PyQt4.Qt import QDir
                base = unicode(QDir.homePath()).replace('/', os.sep)
        candidate = choose_dir(
            None,
            'choose calibre library',
            _('Choose a location for your calibre e-book library'),
            default_dir=base)
        if not candidate:
            candidate = os.path.join(base, 'Calibre Library')
        library_path = os.path.abspath(candidate)
    if not os.path.exists(library_path):
        try:
            os.makedirs(library_path)
        except:
            error_dialog(parent,
                         _('Failed to create library'),
                         _('Failed to create calibre library at: %r.') %
                         library_path,
                         det_msg=traceback.format_exc(),
                         show=True)
            library_path = choose_dir(
                parent,
                'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
    return library_path
Beispiel #3
0
 def setThemeFromGtk():
     f = QFile(QDir.homePath() + "/.gtkrc-2.0");
     if not f.open(QIODevice.ReadOnly | QIODevice.Text):
         return
     while not f.atEnd():
         l = f.readLine().trimmed();
         if l.startsWith("gtk-icon-theme-name="):
             s = QString(l.split('=')[-1]);
             syslog.syslog( syslog.LOG_DEBUG,
                            "DEBUG  setting gtk theme %s" % str(s));
             QIcon.setThemeName(s.remove('"'));
             break