VPlayer / main.py

# -*- coding: utf-8 -*-

##      main.py - main run file.
##
##
## Copyright (C) 2009 A2K <a2k0001@gmail.com>
##
## This file is part of VPlayer.
##
## VPlayer is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 3 or later.
##
## fapman is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with VPlayer.  If not, see <http://www.gnu.org/licenses/>.
##

import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)

try:
    import psyco
    psyco.full()
except ImportError:
    pass

import os
import sys
import locale
from vplayer import queries
from vplayer import common
from PyQt4 import QtGui, QtCore

from vplayer import translations_rc

def main():
    app = QtGui.QApplication(sys.argv)

    app.setOrganizationName("VPlayer")
    app.setOrganizationDomain("localhost")
    app.setApplicationName("VPlayer")
    app.setApplicationVersion("0.8")

    settings = QtCore.QSettings()

    translator = QtCore.QTranslator()
    trans = str(locale.getlocale()[0])
    translator.load(":/translations/vplayer_" + trans + ".qm")
    app.installTranslator(translator)

    configdir = common.get_config_dir()
    if not os.path.exists(configdir):
        try:
            os.mkdir(configdir)
        except:
            log.critical('Could not create config directory.')
            sys.exit(1)

    coversdir = common.get_covers_dir()
    if not os.path.exists(coversdir):
        try:
            os.mkdir(coversdir)
        except:
            log.critical('Could not create covers directory.')
            sys.exit(1)

    from vplayer.gui import MainWindow
    from vplayer.options import Options
    from vplayer.logininfo import LoginInfo


    if settings.value('caching/use').toBool():
        cdir = settings.value('caching/directory').toString()
        if not os.path.exists(cdir):
            log.info('Caching directory %s does not exist' % cdir)
            try:
                os.mkdir(cdir)
            except:
                log.error('WARNING: Caching directory not found, disabling caching')
                settings.setValue('caching/use', QtCore.QVariant(False))

    settings.sync()

    queries.open_database()
    queries.create_tables()

    myapp = MainWindow()
    myapp.show()
    code = app.exec_()
    sys.exit(code)

if __name__ == "__main__":
    main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.