Python cairo.version() Examples

The following are 22 code examples of cairo.version(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cairo , or try the search function .
Example #1
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def check7_sqlite3(self):
        '''sqlite3
        #TODO need to add to required section readme

        https://stackoverflow.com/a/1546162
        '''
        self.append_text("\n")
        # Start check
        #SQLITE_MIN_VERSION = (0, 0, 0)

        try:
            import sqlite3
            # sqlite3.version - pysqlite version
            sqlite3_py_version_str = sqlite3.version
            # sqlite3.sqlite_version - sqlite version
            sqlite3_version_str = sqlite3.sqlite_version
        except ImportError:
            sqlite3_version_str = 'not found'
            sqlite3_py_version_str = 'not found'

        result = ("* SQLite Database library (sqlite3: " +
                  sqlite3_version_str + ") (Python-sqlite3: " +
                  sqlite3_py_version_str + ")")
        # End check
        self.append_text(result) 
Example #2
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def check13_pyicu(self):
        '''PyICU'''
        self.append_text("\n")
        # Start check

        try:
            import PyICU
            try:
                pyicu_str = PyICU.VERSION
                icu_str = PyICU.ICU_VERSION
            except Exception:  # any failure to 'get' the version
                pyicu_str = 'unknown version'
                icu_str = 'unknown version'

        except ImportError:
            pyicu_str = 'not found'
            icu_str = 'not found'

        result = "* PyICU " + pyicu_str + "(ICU " + icu_str + ")"
        # End check
        self.append_text(result) 
Example #3
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check12_graphviz(self):
        '''Graphviz

        Needs the liblasi library with utf-8 support to create ps/ps2 output

        GRAPHVIZ_MIN_VER = (2, 28)


        https://github.com/Alexpux/MINGW-packages/issues/737#issuecomment-147185667
        # bpisoj commented that Gramps needs a version of Graphviz that :
        [needs additional]...library be added to msys2-mingw stack as
        libann, libgts and liblasi?
        I am interested in last one as only that support utf-8 characters
        in ps/ps2 output.
        '''
        #self.append_text("\n")
        # Start check

        try:
            dotversion_str = Popen(['dot', '-V'],
                                   stderr=PIPE).communicate(input=None)[1]
            if isinstance(dotversion_str, bytes) and sys.stdin.encoding:
                dotversion_str = dotversion_str.decode(sys.stdin.encoding)
            if dotversion_str:
                dotversion_str = dotversion_str.replace('\n', '')[23:27]
        except Exception:
            dotversion_str = 'Graphviz not in system PATH'

        result = "Graphviz " + dotversion_str
        # End check
        self.append_text(result) 
Example #4
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check28_webconnectpacks(self):
        '''Webconnect Pack - needs the gramps addon : "libwebconnect"
            installed at the same time.

        libwebconnect is the support Library for web site collections.
        '''
        self.append_text("\n")
        self.render_text("""<b>08. <a href="https://gramps-project.org/wiki/"""
                         """index.php?title=Web_Connect_Pack">"""
                         """Addon:Webconnect Pack</a> :</b> """)
        # Start check

        try:
            import libwebconnect
            LIBWEBCONNECT_test = True
            LIBWEBCONNECT_result = "Installed"
            # TODO add version addon string.
        except Exception:
            LIBWEBCONNECT_test = False
            LIBWEBCONNECT_result = "Not found"

        if LIBWEBCONNECT_test:
            result = "(libwebconnect : " + LIBWEBCONNECT_result + ")(Success)"
        else:
            result = ("(libwebconnect : " + LIBWEBCONNECT_result +
                      ")(Requires the gramps addon listed under 'Plugin lib')")
        # End check
        self.append_text(result)
        #self.append_text("\n") 
Example #5
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check22_graphview(self):
        '''
        Graph View - Requires: PyGoocanvas and Goocanvas and
        graphviz (python-pygoocanvas, gir1.2-goocanvas-2.0)
        '''
        self.append_text("\n")
        self.render_text("""<b>02. <a href="https://gramps-project.org/wiki"""
                         """/index.php?title=Graph_View">"""
                         """Addon:Graph View</a> :</b> """)
        # Start check

        # check for GooCanvas
        try:
            try:
                gi.require_version('GooCanvas', '2.0')
            except Exception:
                print("Why, when same code works in Graphview")
            from gi.repository import GooCanvas
            goocanvas_ver = str(GooCanvas._version)
            #print("GooCanvas version:" + goocanvas_ver)
        except ImportError:
            goocanvas_ver = "Not installed"

        result = "(GooCanvas:" + goocanvas_ver + ")(PyGoocanvas: TBD?)"
        # End check
        self.append_text(result)
        self.append_text("(")
        self.check12_graphviz()
        self.append_text(")") 
Example #6
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check19_geocodeglib(self):
        '''geocodeglib
        # added to gramps master v5.1.0
        #TODO: add to gramps-v check

        https://github.com/gramps-project/gramps/blob/maintenance/gramps50/gramps/plugins/lib/maps/placeselection.py
        '''
        self.append_text("\n")
        # Start check
        geocodeglib_min_ver = "1.0"

        try:
            gi.require_version('GeocodeGlib', '1.0')
            from gi.repository import GeocodeGlib
            geocodeglib_ver = str(GeocodeGlib._version)
            GEOCODEGLIB = True
        except Exception:
            geocodeglib_ver = "Not found"
            GEOCODEGLIB = False

        if GEOCODEGLIB:
            result = ("* geocodeglib " + geocodeglib_ver +
                      " (Success version " + geocodeglib_min_ver +
                      " or greater installed.)")
        else:
            result = ("* geocodeglib " + geocodeglib_ver +
                      " (Requires version " + geocodeglib_min_ver +
                      " or greater installed.)")

        # End check
        self.append_text(result) 
Example #7
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check17_pillow(self):
        '''PILLOW
        Allows Production of jpg images from non-jpg images in LaTeX documents

        #TODO prculley mentions that : And PIL (Pillow) is also used by the
        main Gramps ([]narrativeweb and []other reports for image cropping)
        as well as [x]editexifmetadata and the
        new [x]latexdoc type addons (genealogytree).

        #TODO add check for PILLOW to "gramps -v"  section

        https://github.com/gramps-project/gramps/blob/maintenance/gramps50/gramps/plugins/docgen/latexdoc.py
        '''
        #self.append_text("\n")
        # Start check

        try:
            import PIL
            # from PIL import Image
            try:
                pil_ver = PIL.__version__
            except Exception:
                try:
                    pil_ver = str(PIL.PILLOW_VERSION)
                except Exception:
                    try:
                        #print(dir(PIL))
                        pil_ver = str(PIL.VERSION)
                    except Exception:
                        pil_ver = "Installed but does not supply version"
        except ImportError:
            pil_ver = "Not found"

        result = "(PILLOW " + pil_ver + ")"
        # End check
        self.append_text(result) 
Example #8
Source File: libcairodoc.py    From gprime with GNU General Public License v2.0 5 votes vote down vote up
def __write_text(self, text, mark=None, markup=False, links=False):
        """
        @param text: text to write.
        @param mark:  IndexMark to use for indexing
        @param markup: True if text already contains markup info.
                       Then text will no longer be escaped
        @param links:  True if URLs should be made clickable
        """
        if links == True:
            import cairo

            if cairo.cairo_version() < 11210 and self._links_error == False:
                # Cairo v1.12 is suppose to be the first version
                # that supports clickable links
                print("""
WARNING: This version of cairo (%s) does NOT support clickable links.
The first version that is suppose to is v1.12.  See the roadmap:

    http://www.cairographics.org/roadmap/

The work around is to save to another format that supports clickable
links (like ODF) and write PDF from that format.
                """ % cairo.version)
                self._links_error = True

        text = self.__markup(text, markup)

        if mark:
            self._active_element.add_mark(mark)

        self._active_element.add_text(text) 
Example #9
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check14_ghostscript(self):
        '''Ghostscript - need to add to strongly recomended or optional?
        section of readme

        Q:What does it do ?
        A:
        https://www.gramps-project.org/wiki/index.php?title=Gramps_5.0_Wiki_Manual_-_Reports_-_part_5#Graphviz_Layout
        *Number of Horizontal Pages: (1 default) Graphviz can create very
         large graphs by spreading the graph across a rectangular array of
         pages. This controls the number of pages in the array horizontally.
         Only valid for dot and pdf via Ghostscript.
        *Number of Vertical Pages: (1 default) Graphviz can create very large
         graphs by spreading the graph across a rectangular array of pages.
         This controls the number of pages in the array vertically.
         Only valid for dot and pdf via Ghostscript.
        '''
        self.append_text("\n")
        # Start check

        try:
            if win():
                try:
                    gsvers_str = Popen(['gswin32c', '--version'],
                                       stdout=PIPE).communicate(input=None)[0]
                except Exception:
                    gsvers_str = Popen(['gswin64c', '--version'],
                                       stdout=PIPE).communicate(input=None)[0]
            else:
                gsvers_str = Popen(['gs', '--version'],
                                   stdout=PIPE).communicate(input=None)[0]
            if isinstance(gsvers_str, bytes) and sys.stdin.encoding:
                gsvers_str = gsvers_str.decode(sys.stdin.encoding)
            if gsvers_str:
                gsvers_str = gsvers_str.replace('\n', '')
        except Exception:
            gsvers_str = 'Ghostscript not in system PATH'

        result = "* Ghostscript " + gsvers_str
        # End check
        self.append_text(result) 
Example #10
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check11_osmgpsmap(self):
        '''osmgpsmap'''
        # Start check
        OSMGPSMAP_MIN_VERSION = (1, 0)
        OSMGPSMAP_FOUND = False

        try:
            from gi import Repository
            repository = Repository.get_default()
            if repository.enumerate_versions("OsmGpsMap"):
                gi.require_version('OsmGpsMap', '1.0')
                from gi.repository import OsmGpsMap as osmgpsmap
                try:
                    osmgpsmap_str = osmgpsmap._version
                    OSMGPSMAP_FOUND = True
                except Exception:  # any failure to 'get' the version
                    osmgpsmap_str = 'unknown version'
            else:
                osmgpsmap_str = 'not found'

        except ImportError:
            osmgpsmap_str = 'not found'

        if OSMGPSMAP_FOUND:
            result = ("* osmgpsmap " + osmgpsmap_str + " (Success version " +
                      verstr(OSMGPSMAP_MIN_VERSION) +
                      " or greater installed.)")
        else:
            result = ("* osmgpsmap " + osmgpsmap_str + " (Requires version " +
                      verstr(OSMGPSMAP_MIN_VERSION) + " or greater)")

        # End check
        self.append_text(result) 
Example #11
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check31_EditExifMetadata(self):
        '''Edit Image Exif Metadata -

        requires:
        * PIL (Pillow)
        * pyexiv2  ( 0.2.0 )
        * exiv2

        https://github.com/gramps-project/addons-source/tree/master/EditExifMetadata
        '''
        self.append_text("\n")
        self.render_text("""<b>11. <a href="https://gramps-project.org/"""
                         """wiki/index.php?title=Edit_Image_Exif_Metadata">"""
                         """Addon:Edit Image Exif Metadata</a> :</b> """)

        # Start check
        self.check17_pillow()
        '''
        # validate that pyexiv2 is installed and its version...
        import pyexiv2

        # v0.1 has a different API to v0.2 and above
        if hasattr(pyexiv2, 'version_info'):
            OLD_API = False
        else:
        # version_info attribute does not exist prior to v0.2.0
            OLD_API = True

        # validate the exiv2 is installed and its executable
        system_platform = os.sys.platform
        if system_platform == "win32":
            EXIV2_FOUND = "exiv2.exe" if search_for("exiv2.exe") else False
        else:
            EXIV2_FOUND = "exiv2" if search_for("exiv2") else False
        if not EXIV2_FOUND:
            msg = 'You must have exiv2 and its development file installed.'
            raise SystemExit(msg)
        '''
        # End checks
        self.append_text(" ")
        self.check_gexiv2() 
Example #12
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check1_python(self):
        '''Check python version Gramps is currently running with against min
        version required

        #TODO - does not handle an older version of Gramps using python 2 on
        that a system that has python 3 installed (same for each of the other
        test)
        '''
        # Start check
        MIN_PYTHON_VERSION = (3, 3, 0)
        min_py_str = verstr(MIN_PYTHON_VERSION)

        # version to check against
        # Gramps running version of python
        py_str = '%d.%d.%d' % sys.version_info[:3]
        check1 = "* Python "

        if not sys.version_info >= MIN_PYTHON_VERSION:
            #print("Failed")
            messagefailed1 = " (Requires version "
            messagefailed3 = " or greater installed.)\n"

            messagefailed = messagefailed1 + min_py_str + messagefailed3

            result = check1 + py_str + messagefailed
        else:
            #print("Success")
            messagesuccess1 = " (Success version "
            messagesuccess3 = " or greater installed.)\n"

            messagesuccess = messagesuccess1 + min_py_str + messagesuccess3

            result = check1 + py_str + messagesuccess
        # End check
        self.append_text(result) 
Example #13
Source File: backend_cairo.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def draw_image(self, gc, x, y, im):
        # bbox - not currently used
        if sys.byteorder == 'little':
            im = im[:, :, (2, 1, 0, 3)]
        else:
            im = im[:, :, (3, 0, 1, 2)]
        if HAS_CAIRO_CFFI:
            # cairocffi tries to use the buffer_info from array.array
            # that we replicate in ArrayWrapper and alternatively falls back
            # on ctypes to get a pointer to the numpy array. This works
            # correctly on a numpy array in python3 but not 2.7. We replicate
            # the array.array functionality here to get cross version support.
            imbuffer = ArrayWrapper(im.flatten())
        else:
            # pycairo uses PyObject_AsWriteBuffer to get a pointer to the
            # numpy array; this works correctly on a regular numpy array but
            # not on a py2 memoryview.
            imbuffer = im.flatten()
        surface = cairo.ImageSurface.create_for_data(
            imbuffer, cairo.FORMAT_ARGB32,
            im.shape[1], im.shape[0], im.shape[1]*4)
        ctx = gc.ctx
        y = self.height - y - im.shape[0]

        ctx.save()
        ctx.set_source_surface(surface, float(x), float(y))
        if gc.get_alpha() != 1.0:
            ctx.paint_with_alpha(gc.get_alpha())
        else:
            ctx.paint()
        ctx.restore() 
Example #14
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def check16_rcs(self):
        '''GNU Revision Control System (RCS)

        The GNU Revision Control System (RCS) can be used to manage multiple
        revisions of your family trees. Only rcs is needed, NO python bindings
        are required. See info at
        https://gramps-project.org/wiki/index.php?title=Gramps_5.0_Wiki_Manual_-_Manage_Family_Trees#Archiving_a_Family_Tree

        #TODO add check for rcs to "gramps -v"  section

        https://github.com/gramps-project/gramps/blob/maintenance/gramps50/gramps/gui/dbman.py

        # (check if on windows and ignore?)

        $ rcs -V
        RCS version 5.7.1

        $ rcs --version
        rcs (GNU RCS) 5.9.4
        Copyright (C) 2010-2015 Thien-Thi Nguyen
        Copyright (C) 1990-1995 Paul Eggert
        Copyright (C) 1982,1988,1989 Walter F. Tichy, Purdue CS
        License GPLv3+: GNU GPL version 3 or later
        <http://gnu.org/licenses/gpl.html>
        This is free software: you are free to change and redistribute it.
        There is NO WARRANTY, to the extent permitted by law.
        '''
        self.append_text("\n")
        # Start check
        RCS_MIN_VER = (5, 9, 4)
        rcs_ver_str = verstr(RCS_MIN_VER)
        #print("os.environ: %s " % os.environ)
        try:
            if win():
                _RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0
                RCS_RESULT = "installed"
                #print("rcs -V : " + os.system("rcs -V"))
                if _RCS_FOUND and "TZ" not in os.environ:
                    # RCS requires the "TZ" variable be set.
                    os.environ["TZ"] = str(time.timezone)
            else:
                _RCS_FOUND = os.system("rcs -V >/dev/null 2>/dev/null") == 0
                #print("xx rcs -V : " + os.system("rcs -V"))
                RCS_RESULT = "installed"
        except Exception:
            _RCS_FOUND = False
            RCS_RESULT = "Not found"

        #Test
        if _RCS_FOUND:  # TODO actually test for version
            result = ("* rcs %s TBD (Success version %s or greater installed."
                      " If not on Microsoft Windows)" %
                      (RCS_RESULT, rcs_ver_str))
        else:
            result = ("* rcs %s TBD (Requires version %s or greater installed."
                      " If not on Microsoft Windows)" %
                      (RCS_RESULT, rcs_ver_str))

        # End check
        self.append_text(result) 
Example #15
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def check30_PostgreSQL(self):
        '''
        PostgreSQL Database

        requires: PostgreSQL -
        requires: psycopg2 - Python-PostgreSQL Database Adapter

        # https://pypi.python.org/pypi/psycopg2

        # https://gramps-project.org/wiki/index.php?title=DB-API_Database_Backend#Postgresql

        # https://github.com/gramps-project/addons-source/tree/maintenance/gramps50/PostgreSQL

        https://stackoverflow.com/a/39451451

        How get PostgreSQL version using psycopg2?

        According to documentation it is server_version property of connection:

        conn = psycopg2.connect(settings.DB_DSN)
        >>> conn.server_version
        90504
        The number is formed by converting the major, minor, and revision
        numbers into two-decimal-digit numbers and appending them together.
        For example, version 8.1.5 will be returned as 80105.

        command line:
        psql -V
        '''
        self.append_text("\n")
        self.render_text("""<b>10. <a href="https://gramps-project.org/wiki"""
                         """/index.php?title=DB-API_Database_Backend#"""
                         """Postgresql">Addon:PostgreSQL</a></b>"""
                         """ Database library Support : """)
        # Start check
        try:
            import psycopg2
            psycopg2_ver = str(psycopg2.__version__)
            #print(dir(psycopg2))
            #print("psycopg2" + psycopg2_ver)
            try:
                libpq_ver = str(psycopg2.__libpq_version__)
            except AttributeError:
                libpq_ver = "Not found."
        except ImportError:
            psycopg2_ver = "Not found."
            libpq_ver = "Not found."

        result = ("(PostgreSQL " + libpq_ver + ")(psycopg2 : " +
                  psycopg2_ver + ")")
        # End checks
        self.append_text(result) 
Example #16
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def check33_lxmlgramplet(self):
        ''' Lxml Gramplet - Gramplet for testing lxml and XSLT

        lxml gramplet is an experimental gramplet working under POSIX
        platform(s), which reads, writes (not the original one; safe read
        only state), transforms content of our Gramps XML file on the fly
        without an import into our database (Gramps session).

        https://www.gramps-project.org/wiki/index.php?title=Lxml_Gramplet
        https://github.com/gramps-project/addons-source/tree/master/lxml

        requires:
        * lxml is a Pythonic binding for the C libraries libxml2 and libxslt.
        It is known for good performances by using C-level (Cython).
        '''
        self.append_text("\n")
        self.render_text("""<b>13. <a href="https://www.gramps-project.org/"""
                         """wiki/index.php?title=Lxml_Gramplet">"""
                         """Addon:Lxml Gramplet</a> :</b> """)
        # Start check
        LXML_OK = False

        REQ_LXML_VERSION = "3.3.3"
        try:
            from lxml import etree  # objectify
            LXML_OK = True
            # current code is working with:
            # LIBXML_VERSION (2, 9, 1))
            # LIBXSLT_VERSION (1, 1, 28))
            LXML_VERSION = etree.LXML_VERSION
            LIBXML_VERSION = etree.LIBXML_VERSION
            LIBXSLT_VERSION = etree.LIBXSLT_VERSION
            #print("lxml found")
        except ImportError:
            LXML_OK = False
            #print('No lxml')

        # test version
        if LXML_OK:
            #print("Success")
            result = (" (lxml: " + verstr(LXML_VERSION) +
                      ")(libxml: " + verstr(LIBXML_VERSION) +
                      ")(libxslt: " + verstr(LIBXSLT_VERSION) + ")")
        else:
            #print("Failed")
            result = (" (lxml: Not found. Requires version " +
                      REQ_LXML_VERSION + " or greater installed.)")
        # End checks
        self.append_text(result) 
Example #17
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def check29_tmgimporter(self):
        '''
        TMG Importer Addon

        Import from an Whollygenes - The Master Genealogist (TMG)
        Project backup file(*.SQZ)

        requires DBF 0.96.8 or greater to function

        Please install DBF from https://pypi.python.org/pypi/dbf

        # initial reason I made this prerequistes addon.
        '''
        self.append_text("\n")
        self.render_text("""<b>09. <a href="https://gramps-project.org/wiki"""
                         """/index.php?title=Addon:TMGimporter">"""
                         """Addon:TMG Importer</a> :</b> """)
        # Start check
        DBF_MIN_VERSION = (0, 96, 8)

        try:
            # External Library: dbf.pypi
            # https://pypi.python.org/pypi/dbf
            import dbf
            dbf_ver = dbf.version
            dbf_ver_str = str(dbf_ver)
            #print("DBF version = ", dbf_ver)
            dbfavailable = "DBF installed"
        except ImportError:
            dbf_ver = (0, 0, 0)
            dbf_ver_str = "Not found"
            dbfavailable = "Not found"
        # test version
        if not dbf_ver >= DBF_MIN_VERSION:
            #print("Failed")
            result = (" (DBF " + dbfavailable + ".)(Requires version " +
                      verstr(DBF_MIN_VERSION) + " or greater installed.)")
        else:
            #print("Success")
            result = (" (DBF " + dbf_ver_str +
                      " installed.)(Success version " +
                      verstr(DBF_MIN_VERSION) + " or greater installed.)")

        #result = "(DBF : " + dbf_ver + ")" + dbfavailable
        # End check
        self.append_text(result) 
Example #18
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def check24_networkchart(self):
        '''Network Chart - requires networkx 1.11, pygraphviz,
           (need to add to readme) '''
        self.append_text("\n")
        self.render_text("""<b>04. <a href="https://gramps-project.org/wiki"""
                         """/index.php?title=NetworkChart">"""
                         """Addon:Network Chart</a> :</b> """)
        # Start check
        # To get "libcgraph" for pygraphviz you first need to install
        # the development package of graphviz eg: graphviz-dev

        try:
            # import importlib
            # module1 = importlib.find_loader("networkx") is not None
            import networkx
            networkx_ver = str(networkx.__version__)
            #print("networkx version:" + networkx_ver)
        except Exception:
            networkx_ver = "Not installed"
            # module1 = "Not tested"

        try:
            # import importlib
            # module2 = importlib.find_loader("pydotplus") is not None
            import pydotplus
            pydotplus_ver = str(pydotplus.pyparsing_version)
            #print("pydotplus version:" + pydotplus_ver)
        except Exception:
            pydotplus_ver = "Not Installed"
            # module2 = "Not tested"

        try:
            # import importlib
            # module3 = importlib.find_loader("pygraphviz") is not None
            import pygraphviz
            pygraphviz_ver = str(pygraphviz.__version__)
            #print("pygraphviz version:" + pygraphviz_ver)
        except Exception:
            pygraphviz_ver = "Not Installed"
            # module3 = "Not tested"

        # End check
        self.append_text("(networkx " + networkx_ver + ")(")
        self.check12_graphviz()
        self.append_text(")\n")
        self.append_text("  and one of either: (pydotplus: " + pydotplus_ver +
                         ") or (pygraphviz: " + pygraphviz_ver + ")") 
Example #19
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def check5_pango(self):
        '''Check pango is installed with GObject Introspection bindings
        (the gi package)

        pangocairo - Allows you to use Pango with Cairo
        '''
        # Start check
        PANGO_MIN_VER = (1, 29, 3)  # TODO Find out min supported version

        try:
            from gi.repository import Pango
            try:
                pangover_str = Pango.version_string()
                #print("pangover_str " + pangover_str)
                pango_result = vertup(pangover_str)
            except Exception:  # any failure to 'get' the version
                pangover_str = 'unknown version'
                pango_result = (0, 0, 0)

        except ImportError:
            pangover_str = 'not found'
            pango_result = (0, 0, 0)

        # Test Pango
        if not pango_result >= PANGO_MIN_VER:
            #print("Failed")
            result = ("* Pango " + pangover_str + " (Requires version " +
                      verstr(PANGO_MIN_VER) + " or greater.)\n")
        else:
            #print("Success")
            result = ("* Pango " + pangover_str + " (Success version " +
                      verstr(PANGO_MIN_VER) + " or greater installed.)\n")

        # TODO add the following test to gramps -v
        try:
            # import cairo
            # from gi.repository import Pango
            from gi.repository import PangoCairo
            pangocairo_str = PangoCairo._version
            #print("pangocairo_str " + str(pangocairo_str))
        except ImportError:
            pangocairo_str = "Not found"

        '''
        # Test Pangocairo
        if not pango_result >= PANGO_MIN_VER:
            #print("Failed")
            result = ("* Pango " + pangover_str + " (Requires version " +
                      verstr(PANGO_MIN_VER) + " or greater.)\n")
        else:
            #print("Success")
            result = ("* Pango " + pangover_str + " (Success version " +
                      verstr(PANGO_MIN_VER) + " or greater installed.)\n")
        '''
        # to be added here
        result += "* PangoCairo " + str(pangocairo_str)
        # End check
        self.append_text(result) 
Example #20
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def check4_cairo(self):
        '''Check cairo installed with GObject Introspection bindings
        (the gi package)
        '''
        # Start check
        MIN_CAIRO_VERSION = (1, 13, 1)
        # min version that pycairo supports is 1.13.1
        MIN_PYCAIRO_VERSION = (1, 13, 3)

        try:
            import cairo
            try:
                cairover_str = cairo.cairo_version_string()
                cairover_tpl = vertup(cairover_str)

                pycairo_result = cairo.version_info
                pycairover_str = cairo.version
                #print("pycairo_result : " + str(pycairo_result))

                cairo_result = cairover_tpl
                #print("cairo_result : " + str(cairo_result))
            except Exception:  # any failure to 'get' the version
                pycairover_str = 'unknown version'
                cairover_str = 'unknown version'

        except ImportError:
            pycairover_str = 'not found'
            cairover_str = 'not found'

        # Test Cairo
        if not cairo_result >= MIN_CAIRO_VERSION:
            #print("Failed")
            result = ("* Cairo " + cairover_str + " (Requires version " +
                      verstr(MIN_CAIRO_VERSION) + " or greater.)\n")
        else:
            #print("Success")
            result = ("* Cairo " + cairover_str + " (Success version " +
                      verstr(MIN_CAIRO_VERSION) + " or greater installed.)\n")

        self.append_text(result)
        # Test pycairo
        if not pycairo_result >= MIN_PYCAIRO_VERSION:
            #print("Failed")
            result = ("* Pycairo " + pycairover_str + " (Requires " +
                      verstr(MIN_PYCAIRO_VERSION) + " or greater.)\n")
        else:
            #print("Success")
            result = ("* Pycairo " + pycairover_str + " (Success version " +
                      verstr(MIN_PYCAIRO_VERSION) +
                      " or greater installed.)\n")

        # End check
        self.append_text(result) 
Example #21
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def check3_pygobject(self):
        '''Check for pygobject

        pygobject 3.12 or greater - Python Bindings for GLib/GObject/GIO/GTK+
        https://wiki.gnome.org/Projects/PyGObject

         # pygobject 3.12+
        '''
        # Start check
        MIN_PYGOBJECT_VERSION = (3, 12, 0)

        try:
            from gi.repository import GObject
            try:
                pygobjectver_str = verstr(GObject.pygobject_version)
                pygobject_result = GObject.pygobject_version
            except Exception:  # any failure to 'get' the version
                pygobjectver_str = 'unknown version'
                pygobject_result = (0, 0, 0)

        except ImportError:
            pygobjectver_str = 'not found'
            pygobject_result = (0, 0, 0)

        '''
        # test for older pygobject for gtk 2
        # https://github.com/gramps-project/gramps/blob/maintenance/gramps34/src/gramps.py
        try:
            import gobject
            try:
                gobjectver_str = '%d.%d.%d' % gobject.pygobject_version
            except :# any failure to 'get' the version
                gobjectver_str = 'unknown version'

        except ImportError:
            gobjectver_str = 'not found'
        '''

        # Test
        if not pygobject_result >= MIN_PYGOBJECT_VERSION:
            #print("Failed")
            result = ("* PyGObject " + pygobjectver_str +
                      " (Requires version " +
                      verstr(MIN_PYGOBJECT_VERSION) + " or greater.)\n")
        else:
            #print("Success")
            result = ("* PyGObject " + pygobjectver_str +
                      " (Success version " +
                      verstr(MIN_PYGOBJECT_VERSION) +
                      " or greater installed.)\n")

        # End check
        self.append_text(result) 
Example #22
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def gramps_version(self):
        '''Report Currently installed Gramps Version

        #if current < installed version then mention current version?
        #if current == installed version then don't mention current version?
        #if current > installed version then don't mention current version
                                        running test or development version?

        https://gramps-project.org/wiki/index.php?title=Previous_releases_of_Gramps
        '''
        self.append_text("\n")
        # Start check
        LATEST_GRAMPS_VERSION = (5, 1, 2)
        LATEST_GRAMPS_DATE = "2020-01-10"
        latest_release_message = ("Gramps " + verstr(LATEST_GRAMPS_VERSION) +
                                  "  released " + LATEST_GRAMPS_DATE +
                                  " is the most current version.\n")

        try:
            try:
                from gramps.gen.const import VERSION, VERSION_TUPLE
                gramps_str = VERSION
                gramps_ver = VERSION_TUPLE
            except ImportError:
                # Gramps 3.x series
                from const import VERSION, VERSION_TUPLE
                gramps_str = VERSION
                gramps_ver = VERSION_TUPLE
        except ImportError:
            gramps_str = 'not found'

        # Test
        if not gramps_ver >= LATEST_GRAMPS_VERSION:
            # print("Failed")
            result = ("You have Gramps %s. Please make a backup and then "
                      "upgrade.\n%s" % (gramps_str, latest_release_message))
        else:
            if not gramps_ver == LATEST_GRAMPS_VERSION:
                result = ("You have Gramps %s installed; an unreleased "
                          "development version. Thank you for contributing and"
                          " testing; please report any issues. Backups are "
                          "your friend.\n" % (gramps_str))
                # print(gramps_ver)
            else:
                # print("Success")
                # TODO add further check that this is true?
                result = ("You have Gramps %s. Congratulations you have the"
                          " current version.\n" % (gramps_str))

        # End check
        self.render_text(result)
        #self.append_text(result)

    #Requirements