Exemplo n.º 1
0
def detect(trypaths=None):
    """Check if we have calpy and if so, add its path to sys.path."""

    global calpy_path

    calpy = utils.checkExternal('calpy')
    if not calpy:
        return

    pf.message("You have calpy version %s" % calpy)
    path = ''
    calpy = calpy.split('-')[0]  # trim the version trailer
    if utils.checkVersion('calpy','0.3.4-rev3',external=True) >= 0:
        sta,out = utils.runCommand('calpy --whereami')
        if not sta:
            path = out
            pf.debug("I found calpy in %s" % path)
    if not path:
        if trypaths is None:
            trypaths = [ '/usr/local/lib', '/usr/local' ]
        for p in trypaths:
            path = '%s/calpy-%s' % (p,calpy)
            if os.path.exists(path):
                pf.debug('path exists: %s' % path)
                break
            else:
                pf.debug('path does not exist: %s' % path)
                path = ''
    if path:
        #path += '/calpy'
        pf.message("I found calpy in '%s'" % path)
        sys.path.append(path)

    calpy_path = path
Exemplo n.º 2
0
def initialize():
    """Initialize the image module."""
    global image_formats_qt, image_formats_qtr, image_formats_gl2ps, image_formats_fromeps, gl2ps, _producer, _gl2ps_types

    # Find interesting supporting software
    utils.hasExternal("ImageMagick")
    # Set some globals
    GD.debug("LOADING IMAGE FORMATS")
    image_formats_qt = map(str, QtGui.QImageWriter.supportedImageFormats())
    image_formats_qtr = map(str, QtGui.QImageReader.supportedImageFormats())
    if GD.cfg.get("imagesfromeps", False):
        GD.image_formats_qt = []

    if utils.hasModule("gl2ps"):

        import gl2ps

        _producer = GD.Version + " (http://pyformex.berlios.de)"
        _gl2ps_types = {"ps": gl2ps.GL2PS_PS, "eps": gl2ps.GL2PS_EPS, "tex": gl2ps.GL2PS_TEX, "pdf": gl2ps.GL2PS_PDF}
        if utils.checkVersion("gl2ps", "1.03") >= 0:
            _gl2ps_types.update({"svg": gl2ps.GL2PS_SVG, "pgf": gl2ps.GL2PS_PGF})
        image_formats_gl2ps = _gl2ps_types.keys()
        image_formats_fromeps = ["ppm", "png", "jpeg", "rast", "tiff", "xwd", "y4m"]
    if GD.options.debug:
        print "Qt image types for saving: ", image_formats_qt
        print "Qt image types for input: ", image_formats_qtr
        print "gl2ps image types:", image_formats_gl2ps
        print "image types converted from EPS:", image_formats_fromeps
Exemplo n.º 3
0
def detect(trypaths=None):
    """Check if we have calpy and if so, add its path to sys.path."""

    global calpy_path

    calpy = utils.checkExternal('calpy')
    if not calpy:
        return

    pf.message("You have calpy version %s" % calpy)
    path = ''
    calpy = calpy.split('-')[0]  # trim the version trailer
    if utils.checkVersion('calpy', '0.3.4-rev3', external=True) >= 0:
        sta, out = utils.runCommand('calpy --whereami')
        if not sta:
            path = out
            pf.debug("I found calpy in %s" % path)
    if not path:
        if trypaths is None:
            trypaths = ['/usr/local/lib', '/usr/local']
        for p in trypaths:
            path = '%s/calpy-%s' % (p, calpy)
            if os.path.exists(path):
                pf.debug('path exists: %s' % path)
                break
            else:
                pf.debug('path does not exist: %s' % path)
                path = ''
    if path:
        #path += '/calpy'
        pf.message("I found calpy in '%s'" % path)
        sys.path.append(path)

    calpy_path = path
Exemplo n.º 4
0
def Main():
    import message
    message.check()
    utils.checkVersion()
    vpn.CheckUsername()
    
    if not vpn.validToRun():
        utils.log('Login Error')
        return

    # utils.checkOS()

    addDir('-- Configure %s' % TITLE,   _SETTINGS,  isFolder=False)

    current = xbmcgui.Window(10000).getProperty('VPNICITY_LABEL')

    if len(current) > 0:
        abrv      = xbmcgui.Window(10000).getProperty('VPNICITY_ABRV')
        thumbnail = os.path.join(IMAGES, abrv.lower()+'.png')
        addDir('-- Disable %s %s' % (current, TITLE), _KILL, thumbnail=thumbnail, isFolder=False)

    mode     = _COUNTRY
    isFolder = True

    if ADDON.getSetting('AUTO') == 'true':
        mode     = _VPN
        isFolder = False

    countries = vpn.GetCountries()

    CreateFile('-Remove-')

    for country in countries:
        label = country[0]
        menu  = []
        menu.append((ENABLEAUTO % label, 'XBMC.RunPlugin(%s?mode=%d&abrv=%s)' % (sys.argv[0], _AUTO, urllib.quote_plus(country[2]))))
        thumbnail = os.path.join(IMAGES, country[2].lower()+'.png')
        addDir(label, mode, abrv=country[1], thumbnail=thumbnail, isFolder=isFolder, menu=menu)

        try:    CreateFile(country[0], country[1])
        except: pass
Exemplo n.º 5
0
def Main():   
    utils.checkVersion()
    vpn.CheckUsername()

    addDir('-- Configure %s' % TITLE,   _SETTINGS,  isFolder=False)

    current = xbmcgui.Window(10000).getProperty('VPNICITY_LABEL')

    if len(current) > 0:
        abrv      = xbmcgui.Window(10000).getProperty('VPNICITY_ABRV')
        thumbnail = os.path.join(IMAGES, abrv.lower()+'.png')
        addDir('-- Disable %s %s' % (current, TITLE), _KILL, thumbnail=thumbnail, isFolder=False)

    mode     = _COUNTRY
    isFolder = True

    if ADDON.getSetting('AUTO') == 'true':
        mode     = _VPN
        isFolder = False

    countries = vpn.GetCountries()
    for country in countries:
        thumbnail = os.path.join(IMAGES, country[2].lower()+'.png')
        addDir(country[0], mode, abrv=country[1], thumbnail=thumbnail, isFolder=isFolder)
Exemplo n.º 6
0
def initialize():
    """Initialize the image module."""
    global image_formats_qt, image_formats_qtr, image_formats_gl2ps, image_formats_fromeps, gl2ps, _producer, _gl2ps_types

    # Find interesting supporting software
    utils.hasExternal('imagemagick')
    # Set some globals
    pf.debug("Loading Image Formats", pf.DEBUG.IMAGE)
    image_formats_qt = map(str, QtGui.QImageWriter.supportedImageFormats())
    image_formats_qtr = map(str, QtGui.QImageReader.supportedImageFormats())
    ## if pf.cfg.get('imagesfromeps',False):
    ##     pf.image_formats_qt = []

    if utils.hasModule('gl2ps'):

        import gl2ps

        _producer = pf.Version + ' (%s)' % pf.cfg.get('help/website', '')
        _gl2ps_types = {
            'ps': gl2ps.GL2PS_PS,
            'eps': gl2ps.GL2PS_EPS,
            'tex': gl2ps.GL2PS_TEX,
            'pdf': gl2ps.GL2PS_PDF,
        }
        if utils.checkVersion('gl2ps', '1.03') >= 0:
            _gl2ps_types.update({
                'svg': gl2ps.GL2PS_SVG,
                'pgf': gl2ps.GL2PS_PGF,
            })
        image_formats_gl2ps = _gl2ps_types.keys()
        image_formats_fromeps = [
            'ppm', 'png', 'jpeg', 'rast', 'tiff', 'xwd', 'y4m'
        ]
    pf.debug(
        """
Qt image types for saving: %s
Qt image types for input: %s
gl2ps image types: %s
image types converted from EPS: %s""" %
        (image_formats_qt, image_formats_qtr, image_formats_gl2ps,
         image_formats_fromeps), pf.DEBUG.IMAGE | pf.DEBUG.INFO)
Exemplo n.º 7
0
def initialize():
    """Initialize the image module."""
    global image_formats_qt,image_formats_qtr,image_formats_gl2ps,image_formats_fromeps,gl2ps,_producer,_gl2ps_types
    
    # Find interesting supporting software
    utils.hasExternal('ImageMagick')
    # Set some globals
    pf.debug("LOADING IMAGE FORMATS")
    image_formats_qt = map(str,QtGui.QImageWriter.supportedImageFormats())
    image_formats_qtr = map(str,QtGui.QImageReader.supportedImageFormats())
    ## if pf.cfg.get('imagesfromeps',False):
    ##     pf.image_formats_qt = []

    if utils.hasModule('gl2ps'):

        import gl2ps

        _producer = pf.Version + ' (http://pyformex.berlios.de)'
        _gl2ps_types = {
            'ps':gl2ps.GL2PS_PS,
            'eps':gl2ps.GL2PS_EPS,
            'tex':gl2ps.GL2PS_TEX,
            'pdf':gl2ps.GL2PS_PDF,
            }
        if utils.checkVersion('gl2ps','1.03') >= 0:
            _gl2ps_types.update({
                'svg':gl2ps.GL2PS_SVG,
                'pgf':gl2ps.GL2PS_PGF,
                })
        image_formats_gl2ps = _gl2ps_types.keys()
        image_formats_fromeps = [ 'ppm', 'png', 'jpeg', 'rast', 'tiff',
                                     'xwd', 'y4m' ]
    pf.debug("""
Qt image types for saving: %s
Qt image types for input: %s
gl2ps image types: %s
image types converted from EPS: %s""" % (image_formats_qt,image_formats_qtr,image_formats_gl2ps,image_formats_fromeps))
Exemplo n.º 8
0
##

"""A collection of numerical array utilities.

These are general utility functions that depend only on the :mod:`numpy`
array model. All pyformex modules needing :mod:`numpy` should import
everything from this module::

   from arraytools import * 
"""

from numpy import *
from utils import deprecation,checkVersion


if checkVersion('python','2.5') < 0:
    print("""
This version of pyFormex was developed for Python 2.5.
We advice you to upgrade your Python version.
Getting pyFormex to run on Python 2.4 should be possible with a
a few adjustements. Make it run on a lower version is problematic.
""")
    sys.exit()
    
if checkVersion('python','2.6') >= 0:
    print("""
This version of pyFormex was developed for Python 2.5.
There should not be any major problem with running on version 2.6,
but if you encounter some problems, please contact the developers at
pyformex.berlios.de.
""")
Exemplo n.º 9
0
##

"""A collection of numerical array utilities.

These are general utility functions that depend only on the :mod:`numpy`
array model. All pyformex modules needing :mod:`numpy` should import
everything from this module::

  from arraytools import * 
"""

from numpy import *
import utils


if utils.checkVersion('python','2.6') >= 0:
    from itertools import combinations,permutations
else:
    # Provide our own implementation of combinations,permutations
    def combinations(iterable, r):
        # combinations('ABCD', 2) --> AB AC AD BC BD CD
        # combinations(range(4), 3) --> 012 013 023 123
        pool = tuple(iterable)
        n = len(pool)
        if r > n:
            return
        indices = range(r)
        yield tuple(pool[i] for i in indices)
        while True:
            for i in reversed(range(r)):
                if indices[i] != i + n - r: