-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathconfigtest.py
59 lines (49 loc) · 1.69 KB
/
configtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright The IETF Trust 2020, All Rights Reserved
# -*- coding: utf-8 -*-
import importlib
import sys
import warnings
errors = 0
sys.stderr.write("Checking installation of test and development packages:\n")
for (pname, mname) in [
('decorator', 'decorator'),
('dict2xml', 'dict2xml'),
('pypdf', 'pypdf'),
]:
try:
sys.stderr.write(" '%s'...\n" % pname)
m = importlib.import_module(mname)
except ImportError:
errors += 1
sys.stderr.write(" Missing package: '%s'\n" % (pname, ))
if errors:
sys.stderr.write("Not all test requirements are fulfilled\n")
sys.exit(errors)
try:
import fontconfig
except ImportError:
sys.stderr.write("Python-fontconfig not installed, will try to use fontconfig command-line tools\n"
"Install python-fontconfig for better performance.\n")
fontconfig = None
for (fname, fcount) in [
('Noto Serif', 72),
('Roboto Mono', 10)
]:
if fontconfig:
available = fontconfig.query(family=fname)
acount = len(available)
else:
# try external program
import subprocess
done = subprocess.run(["fc-list", fname], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if done.returncode == 0:
available = done.stdout.decode().splitlines()
acount = len(available)
else:
sys.exit(done.stderr)
if acount < fcount:
errors += 1
sys.stderr.write(" Missing fonts: found %s fonts for family %s, but expected at least %s\n" % (acount, fname, fcount))
if errors:
sys.stderr.write("Not all test requirements are fulfilled\n")
sys.exit(errors)