Init: mediaserver

This commit is contained in:
2023-02-08 12:13:28 +01:00
parent 848bc9739c
commit f7c23d4ba9
31914 changed files with 6175775 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
"""Retrieve collection detail."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import json
import os
import re
import sys
import yaml
# See semantic versioning specification (https://semver.org/)
NUMERIC_IDENTIFIER = r'(?:0|[1-9][0-9]*)'
ALPHANUMERIC_IDENTIFIER = r'(?:[0-9]*[a-zA-Z-][a-zA-Z0-9-]*)'
PRE_RELEASE_IDENTIFIER = r'(?:' + NUMERIC_IDENTIFIER + r'|' + ALPHANUMERIC_IDENTIFIER + r')'
BUILD_IDENTIFIER = r'[a-zA-Z0-9-]+' # equivalent to r'(?:[0-9]+|' + ALPHANUMERIC_IDENTIFIER + r')'
VERSION_CORE = NUMERIC_IDENTIFIER + r'\.' + NUMERIC_IDENTIFIER + r'\.' + NUMERIC_IDENTIFIER
PRE_RELEASE = r'(?:-' + PRE_RELEASE_IDENTIFIER + r'(?:\.' + PRE_RELEASE_IDENTIFIER + r')*)?'
BUILD = r'(?:\+' + BUILD_IDENTIFIER + r'(?:\.' + BUILD_IDENTIFIER + r')*)?'
SEMVER_REGULAR_EXPRESSION = r'^' + VERSION_CORE + PRE_RELEASE + BUILD + r'$'
def validate_version(version):
"""Raise exception if the provided version is not None or a valid semantic version."""
if version is None:
return
if not re.match(SEMVER_REGULAR_EXPRESSION, version):
raise Exception('Invalid version number "{0}". Collection version numbers must '
'follow semantic versioning (https://semver.org/).'.format(version))
def read_manifest_json(collection_path):
"""Return collection information from the MANIFEST.json file."""
manifest_path = os.path.join(collection_path, 'MANIFEST.json')
if not os.path.exists(manifest_path):
return None
try:
with open(manifest_path) as manifest_file:
manifest = json.load(manifest_file)
collection_info = manifest.get('collection_info') or dict()
result = dict(
version=collection_info.get('version'),
)
validate_version(result['version'])
except Exception as ex: # pylint: disable=broad-except
raise Exception('{0}: {1}'.format(os.path.basename(manifest_path), ex))
return result
def read_galaxy_yml(collection_path):
"""Return collection information from the galaxy.yml file."""
galaxy_path = os.path.join(collection_path, 'galaxy.yml')
if not os.path.exists(galaxy_path):
return None
try:
with open(galaxy_path) as galaxy_file:
galaxy = yaml.safe_load(galaxy_file)
result = dict(
version=galaxy.get('version'),
)
validate_version(result['version'])
except Exception as ex: # pylint: disable=broad-except
raise Exception('{0}: {1}'.format(os.path.basename(galaxy_path), ex))
return result
def main():
"""Retrieve collection detail."""
collection_path = sys.argv[1]
try:
result = read_manifest_json(collection_path) or read_galaxy_yml(collection_path) or dict()
except Exception as ex: # pylint: disable=broad-except
result = dict(
error='{0}'.format(ex),
)
print(json.dumps(result))
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,38 @@
<#
.SYNOPSIS
Gets the lines to hit from a sourcefile for coverage stubs.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromRemainingArguments)]
[String[]]
$Path
)
$stubInfo = @(foreach ($sourcePath in $Path) {
# Default is to just no lines for missing files
[Collections.Generic.HashSet[int]]$lines = @()
if (Test-Path -LiteralPath $sourcePath) {
$code = [ScriptBlock]::Create([IO.File]::ReadAllText($sourcePath))
# We set our breakpoints with this predicate so our stubs should match
# that logic.
$predicate = {
$args[0] -is [System.Management.Automation.Language.CommandBaseAst]
}
$cmds = $code.Ast.FindAll($predicate, $true)
# We only care about unique lines not multiple commands on 1 line.
$lines = @(foreach ($cmd in $cmds) {
$cmd.Extent.StartLineNumber
})
}
[PSCustomObject]@{
Path = $sourcePath
Lines = $lines
}
})
ConvertTo-Json -InputObject $stubInfo -Depth 2 -Compress

View File

@@ -0,0 +1,23 @@
"""Show openssl version."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import json
# noinspection PyBroadException
try:
from ssl import OPENSSL_VERSION_INFO
VERSION = list(OPENSSL_VERSION_INFO[:3])
except Exception: # pylint: disable=broad-except
VERSION = None
def main():
"""Main program entry point."""
print(json.dumps(dict(
version=VERSION,
)))
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,14 @@
"""Detect the real python interpreter when running in a virtual environment created by the 'virtualenv' module."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import json
try:
from sys import real_prefix
except ImportError:
real_prefix = None
print(json.dumps(dict(
real_prefix=real_prefix,
)))

View File

@@ -0,0 +1,20 @@
"""Show availability of PyYAML and libyaml support."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import json
try:
import yaml
except ImportError:
yaml = None
try:
from yaml import CLoader
except ImportError:
CLoader = None
print(json.dumps(dict(
yaml=bool(yaml),
cloader=bool(CLoader),
)))