def main(top_block_cls=top_block, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
python类StrictVersion()的实例源码
def main(top_block_cls=top_block, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
def main(top_block_cls=top_block, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
def main(top_block_cls=top_block, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
def main(top_block_cls=top_block, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
def main(top_block_cls=top_block, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
def main(top_block_cls=top_block, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
def _is_valid(self, *args, **kwargs):
"""Checks whether the supplied file can be read by this frontend.
"""
warn_h5py(args[0])
try:
f = h5.File(args[0], "r")
except (IOError, OSError, ImportError):
return False
requirements = ["openPMD", "basePath", "meshesPath", "particlesPath"]
attrs = list(f["/"].attrs.keys())
for i in requirements:
if i not in attrs:
f.close()
return False
known_versions = [StrictVersion("1.0.0"),
StrictVersion("1.0.1")]
if StrictVersion(f.attrs["openPMD"].decode()) in known_versions:
f.close()
return True
else:
f.close()
return False
def main(top_block_cls=secplus_rx, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
def _check_google_client_version():
try:
import pkg_resources
except ImportError:
raise ImportError('Could not import pkg_resources (setuptools).')
# Version 0.28.0 includes many changes compared to previous versions
# https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/bigquery/CHANGELOG.md
bigquery_client_minimum_version = '0.28.0'
_BIGQUERY_CLIENT_VERSION = pkg_resources.get_distribution(
'google-cloud-bigquery').version
if (StrictVersion(_BIGQUERY_CLIENT_VERSION) <
StrictVersion(bigquery_client_minimum_version)):
raise ImportError('pandas requires google-cloud-bigquery >= {0} '
'for Google BigQuery support, '
'current version {1}'
.format(bigquery_client_minimum_version,
_BIGQUERY_CLIENT_VERSION))
def export_views(self, state):
gltf_views = []
for key, value in self.buffer_views.items():
gltf = {
'byteLength': value['bytelength'],
'byteOffset': value['byteoffset'],
'name': key,
}
if state['version'] >= Version('2.0') and value['bytestride'] > 0:
gltf['byteStride'] = value['bytestride']
gltf['buffer'] = Reference('buffers', self.name, gltf, 'buffer')
state['references'].append(gltf['buffer'])
if value['target'] is not None:
gltf['target'] = value['target']
gltf_views.append(gltf)
state['input']['bufferViews'].append(SimpleID(key))
return gltf_views
def update_extensions(self):
self.ext_prop_to_exporter_map = {ext.ext_meta['name']: ext for ext in self.ext_exporters}
for exporter in self.ext_exporters:
exporter.ext_meta['enable'] = False
for prop in self.extension_props:
exporter = self.ext_prop_to_exporter_map[prop.name]
exporter.ext_meta['enable'] = prop.enable
self.extension_props.clear()
for exporter in self.ext_exporters:
prop = self.extension_props.add()
prop.name = exporter.ext_meta['name']
prop.enable = exporter.ext_meta['enable']
if exporter.ext_meta['name'] == 'KHR_technique_webgl':
prop.enable = Version(self.asset_version) < Version('2.0')
def check_min_versions():
ret = True
# pyaudio
vers_required = "0.2.7"
vers_current = pyaudio.__version__
if StrictVersion(vers_current) < StrictVersion(vers_required):
print("Error: minimum pyaudio vers: {}, current vers {}".format(vers_required, vers_current))
ret = False
# librosa
vers_required = "0.4.3"
vers_current = librosa.__version__
if StrictVersion(vers_current) < StrictVersion(vers_required):
print("Error: minimum librosa vers: {}, current vers {}".format(vers_required, vers_current))
ret = False
# numpy
vers_required = "1.9.0"
vers_current = np.__version__
if StrictVersion(vers_current) < StrictVersion(vers_required):
print("Error: minimum numpy vers: {}, current vers {}".format(vers_required, vers_current))
ret = False
return ret
def _check_compatibility(self):
from distutils.version import StrictVersion
cmd = [self.bins['iptables'], '--version']
rc, stdout, stderr = Iptables.module.run_command(cmd, check_rc=False)
if rc == 0:
result = re.search(r'^ip6tables\s+v(\d+\.\d+)\.\d+$', stdout)
if result:
version = result.group(1)
# CentOS 5 ip6tables (v1.3.x) doesn't support comments,
# which means it cannot be used with this module.
if StrictVersion(version) < StrictVersion('1.4'):
Iptables.module.fail_json(msg="This module isn't compatible with ip6tables versions older than 1.4.x")
else:
Iptables.module.fail_json(msg="Could not fetch iptables version! Is iptables installed?")
# Read rules from the json state file and return a dict.
def main(top_block_cls=top_block, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
if GUI:
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
def _check_version(self):
if self.version_check:
output = await run_subprocess([self.binary, '--version'])
match = self._version_re.search(output)
if not match:
raise ValueError(
'Could not determine version of geckodriver. To '
'disable version checking, set `version_check` to '
'`False`.'
)
version_str = match.group(1)
version = StrictVersion(version_str)
if version < StrictVersion('0.16.1'):
raise ValueError(
f'Geckodriver version {version_str} is too old. 0.16.1 or '
f'higher is required. To disable version checking, set '
f'`version_check` to `False`.'
)
def test_no_logs_on_empty_changelogs(self):
class LegacyInterface(RunnerInterfaceTestImpl): pass
class NewerInterface(RunnerInterfaceTestImpl): pass
LegacyInterface.version = lambda *_: StrictVersion("0.0.1")
NewerInterface.version = lambda *_: StrictVersion("0.0.2")
NewerInterface.changelog = lambda *_: None
self.test_interfaces = [LegacyInterface, NewerInterface]
uut = LegacyInterface('', [])
uut.logger = MagicMock()
uut._log_legacy_warning()
uut.logger.info.assert_not_called()
uut.logger.warning.assert_not_called()
def __init__(self, detectors_path: str, detector_id: str, java_options: List[str], requested_release: Optional[str] = None):
self.id = detector_id
self.base_name = detector_id.split("_", 1)[0]
self.path = join(detectors_path, self.id)
releases_index_path = join(self.path, Detector.RELEASES_FILE)
release = self._get_release(releases_index_path, requested_release)
release_tag = release.get("tag", "latest")
if "cli_version" in release:
cli_version = StrictVersion(release["cli_version"])
else:
raise ValueError("Missing CLI version for {}".format(detector_id))
self.md5 = release.get("md5", Detector.NO_MD5)
self.jar_path = join(self.path, self.base_name + ".jar")
self.jar_url = "{}/{}/{}/{}.jar".format(Detector.BASE_URL, release_tag, cli_version, self.base_name)
self.runner_interface = RunnerInterface.get(cli_version, self.jar_path, java_options)
def get_available_versions():
client = boto3.client('s3')
paginator = client.get_paginator('list_objects')
account_id = boto3.client('sts').get_caller_identity().get('Account')
region = boto3.session.Session().region_name
s3_bucket = f'{account_id}-{region}-pear-artifacts'
versions = list()
for page in paginator.paginate(Bucket=s3_bucket, Prefix='pear-website/', Delimiter='/'):
prefixes = page.get('CommonPrefixes')
try:
page_versions = [os.path.basename(os.path.dirname(prefix.get('Prefix'))) for prefix in prefixes]
except TypeError:
# When there are no prefixes.
page_versions = list()
versions.extend(page_versions)
versions.sort(key=StrictVersion)
return versions
def infos_from_giturl(url):
"""
retrieve the tag or branch from the URL parameter of the action
:param url: The URL parameter of the action
:return: tag or branch
"""
pattern = re.compile(
r'/(?P<owner>[^/]+)/(?P<name>[^/]+)/archive/(?P<tag>[^/]+)\.zip')
m = pattern.search(url)
if m:
d = m.groupdict()
if is_branch(d['tag']):
d['branch'] = d['tag']
d['version'] = None
d['branch_release'] = d['tag']
else:
d['branch'] = 'master'
d['branch_release'] = False
d['version'] = StrictVersion(d['tag'])
else:
d = dict(owner=None, name=None, tag=None,
branch=None, branch_release=None, version=None)
return d