def _send_changes(self, users):
        """Sends changes to users if bot have configured,

        Also, this method increments version number in the bot's state.
        """

        if self.changelog_notifications:
            changes = changelog.load()
            new_version = V(__version__)
            old_version = V(self.state['version'])

            if old_version < new_version:
                post = [
                    'Bot was upgraded to a new version %s.' % __version__,
                    'Compared with the previous version it has following changes:'
                ]
                for version, version_string, messages in changes:
                    if version <= old_version:
                        break

                    post.append('\nVersion %s:' % version_string)
                    for line in messages:
                        post.append('  * ' + line)

                for user in users:
                    self.send_message(user.jid,
                                      '\n'.join(post),
                                      mfrom=self.jid,
                                      mtype='chat')
        self.state['version'] = __version__
Пример #2
0
def _loose_compare(v1, v2, fn):
    v1_parts = len(v1.split('.'))
    v2_parts = len(v2.split('.'))
    parts_to_keep = min(v1_parts, v2_parts)
    v1 = '.'.join(v1.split('.')[:parts_to_keep])
    v2 = '.'.join(v2.split('.')[:parts_to_keep])
    return fn(V(v1), V(v2))
Пример #3
0
    def getFastToc(self, runner, toc_pickle, device):
        """
        Retrieve the normal TOC table from a toc pickle or the drive.
        Also retrieves the cdrdao version

        @rtype: tuple of L{table.Table}, str
        """
        def function(r, t):
            r.run(t)

        ptoc = cache.Persister(toc_pickle or None)
        if not ptoc.object:
            from pkg_resources import parse_version as V
            version = cdrdao.getCDRDAOVersion()
            if V(version) < V('1.2.3rc2'):
                sys.stdout.write(
                    'Warning: cdrdao older than 1.2.3 has a '
                    'pre-gap length bug.\n'
                    'See http://sourceforge.net/tracker/?func=detail'
                    '&aid=604751&group_id=2171&atid=102171\n')
            t = cdrdao.ReadTOCTask(device)
            ptoc.persist(t.table)
        toc = ptoc.object
        assert toc.hasTOC()
        return toc
    def check(self, package_name, package_version, **extra_data):
        """Return a UpdateResult object if there is a newer version."""
        data = extra_data
        data['package_name'] = package_name
        data['package_version'] = package_version
        data['python_version'] = sys.version.split()[0]
        data['platform'] = platform.platform(True)

        try:
            headers = {'content-type': 'application/json'}
            response = requests.put(self.url,
                                    json.dumps(data),
                                    timeout=1,
                                    headers=headers)
            data = response.json()
        except (requests.exceptions.RequestException, ValueError):
            return None

        if not data or not data.get('success') or (V(package_version) >= V(
                data['data']['version'])):
            return None

        return UpdateResult(package_name,
                            running=package_version,
                            available=data['data']['version'],
                            release_date=data['data']['upload_time'])
Пример #5
0
def supported(package, version):
    """Determine if version +version+ of +package+ is still supported.

    Returns True if it is; False otherwise.
    """
    versions = all()[package]
    return any([V(version) >= V(v) for v in versions])
Пример #6
0
def test_pyqt4():
    from PyQt4.QtCore import QT_VERSION_STR
    from PyQt4.Qt import PYQT_VERSION_STR
    from sip import SIP_VERSION_STR
    print("Qt version:", QT_VERSION_STR)
    print("SIP version:", SIP_VERSION_STR)
    print("PyQt version:", PYQT_VERSION_STR)
    assert V(PYQT_VERSION_STR) >= V('4.10.0')
Пример #7
0
def check_matplotlib_version(requiredversion):

    matplotlibversion = matplotlib.__version__
    from pkg_resources import parse_version as V  # nice

    if V(matplotlibversion) < V(requiredversion):
        print(
            f"Matplotlib version {requiredversion} is required but version {matplotlibversion} is installed."
        )
        print("I'm sorry, but you'll have to update matplotlib.")
        sys.exit(1)
Пример #8
0
 def getFastToc(self, runner, device):
     """Retrieve the normal TOC table from the drive.
     Also warn about buggy cdrdao versions.
     """
     from pkg_resources import parse_version as V
     version = cdrdao.getCDRDAOVersion()
     if V(version) < V('1.2.3rc2'):
         logger.warning('cdrdao older than 1.2.3 has a pre-gap length bug.'
                        ' See http://sourceforge.net/tracker/?func=detail&aid=604751&group_id=2171&atid=102171')  # noqa: E501
     toc = cdrdao.ReadTOCTask(device).table
     assert toc.hasTOC()
     return toc
Пример #9
0
def get_git_sha1():
    try:
        import git
        required_version = '0.3.7'
        if V(git.__version__) < V(required_version):
            raise ImportError('could not import gitpython>=%s' %
                              required_version)
    except ImportError as e:
        print >> sys.stderr, e
        return None
    repo = git.Repo(os.path.dirname(__file__))
    sha1 = repo.iter_commits().next().hexsha
    return sha1
 def setUp(self):
     super(self.__class__, self).setUp()
     self.client = Client(self.env.host,
                          dbname=self.env.dbname,
                          user=self.env.user,
                          pwd=self.env.password,
                          protocol=self.env.protocol,
                          port=self.env.port)
     if self.client.server_version == V('7.0'):
         self.report_name = 'sale.order'
     elif self.client.server_version >= V('11.0'):
         raise unittest.SkipTest(
             'reports service was removed in Odoo 11.0+')
     else:  # >7.0
         self.report_name = 'sale.report_saleorder'
Пример #11
0
 def workflow_signal(self, obj_id, signal):
     """ Triggers specified signal for object's workflow
     """
     assert self.client.server_version < V('11.0'), (
         "Not supported for Odoo 11.0+")
     assert isinstance(obj_id, numbers.Integral), "obj_id must be integer"
     assert isinstance(signal, six.string_types), "signal must be string"
     return self.client.execute_wkf(self.name, signal, obj_id)
Пример #12
0
    def get_version(self):
        with open('Makefile', 'r') as f:
            for line in f:
                if line.startswith('VERSION = '):
                    version = line.split('=')[1].strip()
                elif line.startswith('PATCHLEVEL = '):
                    patchlevel = line.split('=')[1].strip()
                    break

        self.verstr = version + '.' + patchlevel
        # With v2014.04 the u-boot Makefile knows the 'tools-only' target.
        if V(self.verstr) < V('2014.04'):
            TUI.printf("Only U-Boot >= 2014.04 is supported.\n"
                       "This is version '%s'" % self.verstr)

        if V(self.verstr) >= V('2017.09'):
            self.deb['envtools'] = 'envtools'
        else:
            self.deb['envtools'] = 'env'
Пример #13
0
    def getFastToc(self, runner, toc_pickle, device):
        """
        Retrieve the normal TOC table from a toc pickle or the drive.
        Also retrieves the cdrdao version

        @rtype: tuple of L{table.Table}, str
        """
        def function(r, t):
            r.run(t)

        ptoc = cache.Persister(toc_pickle or None)
        if not ptoc.object:
            tries = 0
            while True:
                tries += 1
                t = cdrdao.ReadTOCTask(device=device)
                try:
                    function(runner, t)
                    break
                except:
                    if tries > 3:
                        raise
                    self.debug('failed to read TOC after %d tries, retrying' %
                               tries)

            version = t.tasks[1].parser.version
            from pkg_resources import parse_version as V
            # we've built a cdrdao 1.2.3rc2 modified package with the patch
            if V(version) < V('1.2.3rc2p1'):
                self.stdout.write(
                    'Warning: cdrdao older than 1.2.3 has a '
                    'pre-gap length bug.\n'
                    'See http://sourceforge.net/tracker/?func=detail'
                    '&aid=604751&group_id=2171&atid=102171\n')
            ptoc.persist(t.table)
        toc = ptoc.object
        assert toc.hasTOC()
        return toc
Пример #14
0
    def workflow(self):
        """ Returns Record instance of "workflow" object
            related to this Object

            If there are no workflow for an object then False will be returned
        """
        if self._workflow is None and self.client.server_version < V('11.0'):
            wkf_obj = self.service.get_obj('workflow')
            # TODO: implement correct behavior for situations with few
            # workflows for same model.
            wkf_records = wkf_obj.search_records([('osv', '=', self.name)])
            if wkf_records and len(wkf_records) > 1:  # pragma: no cover
                raise ObjectException(
                    "More then one workflow per model not supported "
                    "be current version of openerp_proxy!")
            self._workflow = wkf_records and wkf_records[0] or False
        return self._workflow
Пример #15
0
    def setUp(self):
        super(Test_32_ExtWorkFlow, self).setUp()

        self.client = Client(self.env.host,
                             dbname=self.env.dbname,
                             user=self.env.user,
                             pwd=self.env.password,
                             protocol=self.env.protocol,
                             port=self.env.port)

        if self.client.server_version >= V('9.0'):
            self.skipTest('No workflow tests for Odoo version 9.0')
        self.object = self.client.get_obj('sale.order')
        self.record = self.object.browse(1)
        self.obj_ids = self.object.search([], limit=10)
        self.recordlist = self.object.read_records(self.obj_ids)

        self.object_no_wkf = self.client.get_obj('res.partner')
        self.record_no_wkf = self.object_no_wkf.browse(1)
        self.obj_ids_no_wkf = self.object_no_wkf.search([], limit=10)
        self.recordlist_no_wkf = self.object_no_wkf.read_records(self.obj_ids_no_wkf)
Пример #16
0
print_cache = CACHE.print_cache
clear_cache = CACHE.clear_cache

from .compatibility import lru_cache
from functools import update_wrapper

try:
    import fastcache
    from warnings import warn

    # the version attribute __version__ is not present for all versions
    if not hasattr(fastcache, "__version__"):
        warn("fastcache version >= 0.4.0 required", UserWarning)
        raise ImportError
        # ensure minimum required version of fastcache is present
    if V(fastcache.__version__) < V("0.4.0"):
        warn(
            "fastcache version >= 0.4.0 required, detected {}".format(
                fastcache.__version__
            ),
            UserWarning,
        )
        raise ImportError
    # Do not use fastcache if running under pypy
    import platform

    if platform.python_implementation() == "PyPy":
        raise ImportError

except ImportError:
Пример #17
0
def test_numpy():
    numpy_meta = GD("numpy")
    assert numpy_meta.parsed_version >= V('1.9.0')
Пример #18
0
def test_pyparsing():
    pyparsing_meta  = GD("pyparsing")
    assert pyparsing_meta.parsed_version == V('2.0.3')
Пример #19
0
def test_traits():
    traits_meta  = GD("traits")
    assert traits_meta.parsed_version >= V('4.4.0')
Пример #20
0
    def do(self, args):
        prog = program.Program(record=self.getRootCommand().record)
        runner = task.SyncRunner()

        def function(r, t):
            r.run(t)

        # if the device is mounted (data session), unmount it
        device = self.parentCommand.options.device
        self.stdout.write('Checking device %s\n' % device)

        prog.loadDevice(device)
        prog.unmountDevice(device)

        version = None

        # first, read the normal TOC, which is fast
        ptoc = common.Persister(self.options.toc_pickle or None)
        if not ptoc.object:
            t = cdrdao.ReadTOCTask(device=device)
            function(runner, t)
            version = t.tasks[1].parser.version
            from pkg_resources import parse_version as V
            # we've built a cdrdao 1.2.3rc2 modified package with the patch
            if V(version) < V('1.2.3rc2p1'):
                self.stdout.write('''
Warning: cdrdao older than 1.2.3 has a pre-gap length bug.
See  http://sourceforge.net/tracker/?func=detail&aid=604751&group_id=2171&atid=102171
''')
            ptoc.persist(t.table)
        ittoc = ptoc.object
        assert ittoc.hasTOC()

        # already show us some info based on this
        prog.getRipResult(ittoc.getCDDBDiscId())
        self.stdout.write("CDDB disc id: %s\n" % ittoc.getCDDBDiscId())
        mbdiscid = ittoc.getMusicBrainzDiscId()
        self.stdout.write("MusicBrainz disc id %s\n" % mbdiscid)

        self.stdout.write("MusicBrainz lookup URL %s\n" %
                          ittoc.getMusicBrainzSubmitURL())

        prog.metadata = prog.getMusicBrainz(ittoc, mbdiscid,
                                            self.options.release)

        if not prog.metadata:
            # fall back to FreeDB for lookup
            cddbid = ittoc.getCDDBValues()
            cddbmd = prog.getCDDB(cddbid)
            if cddbmd:
                self.stdout.write('FreeDB identifies disc as %s\n' % cddbmd)

            if not self.options.unknown:
                prog.ejectDevice(device)
                return -1

        # now, read the complete index table, which is slower
        itable = prog.getTable(runner, ittoc.getCDDBDiscId(), device)

        assert itable.getCDDBDiscId() == ittoc.getCDDBDiscId(), \
            "full table's id %s differs from toc id %s" % (
                itable.getCDDBDiscId(), ittoc.getCDDBDiscId())
        assert itable.getMusicBrainzDiscId() == ittoc.getMusicBrainzDiscId(), \
            "full table's mb id %s differs from toc id mb %s" % (
            itable.getMusicBrainzDiscId(), ittoc.getMusicBrainzDiscId())
        assert itable.getAccurateRipURL() == ittoc.getAccurateRipURL(), \
            "full table's AR URL %s differs from toc AR URL %s" % (
            itable.getAccurateRipURL(), ittoc.getAccurateRipURL())

        prog.outdir = (self.options.output_directory or os.getcwd())
        prog.outdir = prog.outdir.decode('utf-8')
        # here to avoid import gst eating our options
        from morituri.common import encode
        profile = encode.PROFILES[self.options.profile]()

        # result

        prog.result.cdrdao_version = version
        prog.result.cdparanoia_version = cdparanoia.ParanoiaVersion()
        prog.result.offset = int(self.options.offset)
        prog.result.artist = prog.metadata and prog.metadata.artist \
            or 'Unknown Artist'
        prog.result.title = prog.metadata and prog.metadata.title \
            or 'Unknown Title'
        # cdio is optional for now
        try:
            import cdio
            _, prog.result.vendor, prog.result.model, prog.result.release = \
                cdio.Device(device).get_hwinfo()
        except ImportError:
            self.stdout.write(
                'WARNING: pycdio not installed, cannot identify drive\n')
            prog.result.vendor = 'Unknown'
            prog.result.model = 'Unknown'
            prog.result.release = 'Unknown'

        # FIXME: turn this into a method

        def ripIfNotRipped(number):
            # we can have a previous result
            trackResult = prog.result.getTrackResult(number)
            if not trackResult:
                trackResult = result.TrackResult()
                prog.result.tracks.append(trackResult)

            path = prog.getPath(prog.outdir, self.options.track_template,
                                mbdiscid, number) + '.' + profile.extension
            trackResult.number = number

            assert type(path) is unicode, "%r is not unicode" % path
            trackResult.filename = path
            if number > 0:
                trackResult.pregap = itable.tracks[number - 1].getPregap()

            # FIXME: optionally allow overriding reripping
            if os.path.exists(path):
                self.stdout.write('Verifying track %d of %d: %s\n' %
                                  (number, len(itable.tracks),
                                   os.path.basename(path).encode('utf-8')))
                if not prog.verifyTrack(runner, trackResult):
                    self.stdout.write('Verification failed, reripping...\n')
                    os.unlink(path)

            if not os.path.exists(path):
                tries = 0
                self.stdout.write('Ripping track %d of %d: %s\n' %
                                  (number, len(itable.tracks),
                                   os.path.basename(path).encode('utf-8')))
                while tries < MAX_TRIES:
                    tries += 1
                    try:
                        self.debug('ripIfNotRipped: track %d, try %d', number,
                                   tries)
                        prog.ripTrack(runner,
                                      trackResult,
                                      offset=int(self.options.offset),
                                      device=self.parentCommand.options.device,
                                      profile=profile,
                                      taglist=prog.getTagList(number),
                                      what='track %d of %d' %
                                      (number, len(itable.tracks)))
                        break
                    except Exception, e:
                        self.debug('Got exception %r on try %d', e, tries)

                if tries == MAX_TRIES:
                    self.error('Giving up on track %d after %d times' %
                               (number, tries))
                if trackResult.testcrc == trackResult.copycrc:
                    self.stdout.write('Checksums match for track %d\n' %
                                      number)
                else:
                    self.stdout.write(
                        'ERROR: checksums did not match for track %d\n' %
                        number)
                    raise

                self.stdout.write('Peak level: %.2f %%\n' %
                                  (math.sqrt(trackResult.peak) * 100.0, ))
                self.stdout.write('Rip quality: %.2f %%\n' %
                                  (trackResult.quality * 100.0, ))

            # overlay this rip onto the Table
            if number == 0:
                # HTOA goes on index 0 of track 1
                itable.setFile(1, 0, trackResult.filename,
                               ittoc.getTrackStart(1), number)
            else:
                itable.setFile(number, 1, trackResult.filename,
                               ittoc.getTrackLength(number), number)

            prog.saveRipResult()
def load():
    changes = yaml.load(
        open(os.path.join(os.path.dirname(__file__), 'changelog.yml')))
    changes = [(V(key), key, value) for key, value in changes.iteritems()]
    return sorted(changes, key=lambda x: x[0], reverse=True)
Пример #22
0
def test_xlrd():
    xlrd_meta = GD("xlrd")
    assert xlrd_meta.parsed_version >= V('0.9.2')
Пример #23
0
from pkg_resources import parse_version as V
import sys

try:
    import scipy
    enable_sparse = V(scipy.__version__) >= V('0.7')

    if not enable_sparse:
        sys.stderr.write(
            "WARNING: scipy version = %s."
            " We request version >=0.7.0 for the sparse code as it has"
            " bugs fixed in the sparse matrix code.\n" % scipy.__version__)
except ImportError:
    enable_sparse = False
    sys.stderr.write("WARNING: scipy can't be imported."
                     " We disable the sparse matrix code.")

if enable_sparse:
    from basic import *
    import sharedvar
    from sharedvar import sparse_constructor as shared
Пример #24
0
# Created on Wed Oct 29 16:55:39 2014

# Author: XiaoTao Wang
# Organization: HuaZhong Agricultural University

import xmlrpc.client
from pkg_resources import parse_version as V

__author__ = 'XiaoTao Wang'
__version__ = '0.4.2'
__license__ = 'GPLv3+'

## Check for update
try:
    pypi = xmlrpc.client.ServerProxy('http://pypi.python.org/pypi')
    available = pypi.package_releases('TADLib')
    if V(__version__) < V(available[0]):
        print('*' * 75)
        print('Version {0} is out of date, Version {1} is available.'.format(
            __version__, available[0]))
        print()
        print('*' * 75)
except:
    pass
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import cms
from django.db import migrations, models
from pkg_resources import parse_version as V

# Django CMS 3.3.1 is oldest release where the change affects.
# Refs https://github.com/divio/django-cms/commit/871a164
if V(cms.__version__) >= V('3.3.1'):
    field_kwargs = {'related_name': 'form_designer_form_cmsformdefinition'}
else:
    field_kwargs = {}


class Migration(migrations.Migration):
    dependencies = [
        ('cms', '0001_initial'),
        ('form_designer', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='CMSFormDefinition',
            fields=[
                ('cmsplugin_ptr',
                 models.OneToOneField(
                     serialize=False,
                     auto_created=True,
                     primary_key=True,
                     to='cms.CMSPlugin',
Пример #26
0
 def get_max_version(versions_list):
     curr_max = versions_list[0]
     for version in versions_list:
         if V(version) > V(curr_max):
             curr_max = version
     return curr_max
Пример #27
0
def test_openpyxl():
    openpyxl_meta = GD("openpyxl")
    assert openpyxl_meta.parsed_version >= V('1.8.5')
Пример #28
0
def test_pandas():
    pandas_meta = GD("pandas")
    assert pandas_meta.parsed_version >= V('0.14.0')
Пример #29
0
def test_pyper():
    '''version 1.1.2: the row index is not importet to Pandas DataFrames'''
    pyper_meta = GD("pyper")
    assert pyper_meta.parsed_version >= V('1.1.1')
Пример #30
0
def test_colormath():
    color_meta = GD("colormath")
    assert color_meta.parsed_version == V('2.1.0')