Exemple #1
0
def sanity_check():
	"Sanity Check for script."
	config.count_application_runs += 1
	_warnings = []
	
	### LOCAL CHECKS ###
	
	# Windows version check
	winver = sys.getwindowsversion()
	log.debug('Running iQuality v%s (r%d) on Windows %d.%d.%d %s' % (__version__, __rev__, winver.major, winver.minor, winver.build, winver.service_pack))
	
	# Python version check
	if sys.version_info < (2, 6) or sys.version_info >= (3, 0):
		msg = "must use python 2.7"
		log.critical(msg)
		raise Exception(msg)
	log.debug('CPython version is %d.%d.%d' % (sys.version_info.major, sys.version_info.minor, sys.version_info.micro))
	log.debug('PyQt version is %s, Qt version is %s' % (QtCore.PYQT_VERSION_STR, QtCore.QT_VERSION_STR))
		
	# youtube-dl check
	try:
		import youtube_dl
		log.debug("youtube-dl version is %s" % youtube_dl.__version__)
	except ImportError:
		log.warning("Could not load the youtube-dl module")
		
	# Phonon version check
	try:
		from PyQt4.phonon import Phonon
		if Phonon.BackendCapabilities.isMimeTypeAvailable('video/x-flv'):
			log.debug('Phonon version is %s. video/x-flv is supported.' % Phonon.phononVersion())
		else:
			log.warning('Phonon version is %s. video/x-flv is not supported.' % Phonon.phononVersion())
	except ImportError:
		log.warning("Could not load the phonon module")
	
	# Free space check
	freespace = utils.get_free_space(config.temp_dir)
	if freespace < 200*1024**2: # 200 MB
		drive = os.path.splitdrive(config.temp_dir)[0]
		log.warning("There are less than 200MB available in drive %s (%.2fMB left)." % (drive, freespace/1024.0**2))
		_warnings.append(NoSpaceWarning(drive, freespace))

	# iTunes' availablity check
	itunesPath = r'%s\My Documents\My Music\iTunes\iTunes Media\Automatically Add to iTunes' % utils.get_home_dir()
	if not os.path.exists(itunesPath):
		config.is_itunes_installed = False
		if config.post_download_action == 'addItunes':
			config.post_download_action = 'ask'
		log.warning("iTunes Media not found. setting is_itunes_installed to False")
		
	# Context Menu check
	try: # IMPROVE: REMOVE THE TRY-EXCEPT BLOCK
		if config.id3editor_in_context_menu and not utils.check_context_menu_status():
			log.debug("Registering Context Menu Object...")
			try:
				utils.register_with_context_menu()
			except WindowsError, e:
				if e.winerror == 5: # Access is denied
					log.debug("Access is denied. Setting id3editor_in_context_menu to False.")
					config.id3editor_in_context_menu = False
				else:
					raise
		if not config.id3editor_in_context_menu and utils.check_context_menu_status():
			log.debug("Unregistering Context Menu Object...")
			try:
				utils.unregister_with_context_menu()
			except WindowsError, e:
				if e.winerror == 5: # Access is denied
					log.debug("Access is denied. Setting id3editor_in_context_menu to True.")
					config.id3editor_in_context_menu = True
				else:
					raise
Exemple #2
0
def sanity_check():
    "Sanity Check for script."
    config.count_application_runs += 1
    _warnings = []

    ### LOCAL CHECKS ###

    # Windows version check
    winver = sys.getwindowsversion()
    log.debug('Running iQuality v%s (r%d) on Windows %d.%d.%d %s' %
              (__version__, __rev__, winver.major, winver.minor, winver.build,
               winver.service_pack))

    # Python version check
    if sys.version_info < (2, 6) or sys.version_info >= (3, 0):
        msg = "must use python 2.7"
        log.critical(msg)
        raise Exception(msg)
    log.debug('CPython version is %d.%d.%d' %
              (sys.version_info.major, sys.version_info.minor,
               sys.version_info.micro))
    log.debug('PyQt version is %s, Qt version is %s' %
              (QtCore.PYQT_VERSION_STR, QtCore.QT_VERSION_STR))

    # youtube-dl check
    try:
        import youtube_dl
        log.debug("youtube-dl version is %s" % youtube_dl.__version__)
    except ImportError:
        log.warning("Could not load the youtube-dl module")

    # Phonon version check
    try:
        from PyQt4.phonon import Phonon
        if Phonon.BackendCapabilities.isMimeTypeAvailable('video/x-flv'):
            log.debug('Phonon version is %s. video/x-flv is supported.' %
                      Phonon.phononVersion())
        else:
            log.warning('Phonon version is %s. video/x-flv is not supported.' %
                        Phonon.phononVersion())
    except ImportError:
        log.warning("Could not load the phonon module")

    # Free space check
    freespace = utils.get_free_space(config.temp_dir)
    if freespace < 200 * 1024**2:  # 200 MB
        drive = os.path.splitdrive(config.temp_dir)[0]
        log.warning(
            "There are less than 200MB available in drive %s (%.2fMB left)." %
            (drive, freespace / 1024.0**2))
        _warnings.append(NoSpaceWarning(drive, freespace))

    # iTunes' availablity check
    itunesPath = r'%s\My Documents\My Music\iTunes\iTunes Media\Automatically Add to iTunes' % utils.get_home_dir(
    )
    if not os.path.exists(itunesPath):
        config.is_itunes_installed = False
        if config.post_download_action == 'addItunes':
            config.post_download_action = 'ask'
        log.warning(
            "iTunes Media not found. setting is_itunes_installed to False")

    # Context Menu check
    try:  # IMPROVE: REMOVE THE TRY-EXCEPT BLOCK
        if config.id3editor_in_context_menu and not utils.check_context_menu_status(
        ):
            log.debug("Registering Context Menu Object...")
            try:
                utils.register_with_context_menu()
            except WindowsError, e:
                if e.winerror == 5:  # Access is denied
                    log.debug(
                        "Access is denied. Setting id3editor_in_context_menu to False."
                    )
                    config.id3editor_in_context_menu = False
                else:
                    raise
        if not config.id3editor_in_context_menu and utils.check_context_menu_status(
        ):
            log.debug("Unregistering Context Menu Object...")
            try:
                utils.unregister_with_context_menu()
            except WindowsError, e:
                if e.winerror == 5:  # Access is denied
                    log.debug(
                        "Access is denied. Setting id3editor_in_context_menu to True."
                    )
                    config.id3editor_in_context_menu = True
                else:
                    raise
Exemple #3
0
def phononVersion ():
    return map (int, Phonon.phononVersion ().split ('.'))
"""
The actual exception dialog form.
"""
import logging
import re
import os
import platform

import sqlalchemy
import BeautifulSoup
from lxml import etree
from PyQt4 import Qt, QtCore, QtGui, QtWebKit

try:
    from PyQt4.phonon import Phonon
    PHONON_VERSION = Phonon.phononVersion()
except ImportError:
    PHONON_VERSION = u'-'
try:
    import migrate
    MIGRATE_VERSION = getattr(migrate, u'__version__', u'< 0.7')
except ImportError:
    MIGRATE_VERSION = u'-'
try:
    import chardet
    CHARDET_VERSION = chardet.__version__
except ImportError:
    CHARDET_VERSION = u'-'
try:
    import enchant
    ENCHANT_VERSION = enchant.__version__
Exemple #5
0
import logging
import re
import os
import platform

import bs4
import sqlalchemy
from lxml import etree

from openlp.core.common import RegistryProperties, is_linux

from PyQt4 import Qt, QtCore, QtGui, QtWebKit

try:
    from PyQt4.phonon import Phonon
    PHONON_VERSION = Phonon.phononVersion()
except ImportError:
    PHONON_VERSION = '-'
try:
    import migrate
    MIGRATE_VERSION = getattr(migrate, '__version__', '< 0.7')
except ImportError:
    MIGRATE_VERSION = '-'
try:
    import chardet
    CHARDET_VERSION = chardet.__version__
except ImportError:
    CHARDET_VERSION = '-'
try:
    import enchant
    ENCHANT_VERSION = enchant.__version__