Skip to content

Commit a5318c6

Browse files
authored
Merge 6504430 into b47fdc5
2 parents b47fdc5 + 6504430 commit a5318c6

File tree

527 files changed

+37640
-32211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

527 files changed

+37640
-32211
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ e6a639bfe237ff7f98c4cbec2094a34ac4b879db
1111
# Lint the repository with Ruff
1212
d3ce6b8879b14464058d5eaf3f914f803e8f22ac
1313
8bdfbc2e8da78945e20c3b203b39b9a81227d596
14+
f0df00cfaf6d5db53ad25e794ab976f10b47e69d
15+
cdfc4e955c48cb8ab430a30068a4369a6771a70e
16+
b42f55898fce316f8465f29d648620ff381b63ee

appveyor/crowdinSync.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,12 @@
2020

2121

2222
def request(
23-
path: str,
24-
method=requests.get,
25-
headers: dict[str, str] | None = None,
26-
**kwargs
23+
path: str, method=requests.get, headers: dict[str, str] | None = None, **kwargs
2724
) -> requests.Response:
2825
if headers is None:
2926
headers = {}
3027
headers["Authorization"] = f"Bearer {AUTH_TOKEN}"
31-
r = method(
32-
f"https://api.crowdin.com/api/v2/{path}",
33-
headers=headers,
34-
**kwargs
35-
)
28+
r = method(f"https://api.crowdin.com/api/v2/{path}", headers=headers, **kwargs)
3629
# Convert errors to exceptions, but print the response before raising.
3730
try:
3831
r.raise_for_status()
@@ -50,32 +43,18 @@ def uploadSourceFile(crowdinFileID: int, localFilePath: str) -> None:
5043
fn = os.path.basename(localFilePath)
5144
print(f"Uploading {localFilePath} to Crowdin temporary storage as {fn}")
5245
with open(localFilePath, "rb") as f:
53-
r = request(
54-
"storages",
55-
method=requests.post,
56-
headers={"Crowdin-API-FileName": fn},
57-
data=f
58-
)
46+
r = request("storages", method=requests.post, headers={"Crowdin-API-FileName": fn}, data=f)
5947
storageID = r.json()["data"]["id"]
6048
print(f"Updating file {crowdinFileID} on Crowdin with storage ID {storageID}")
61-
r = projectRequest(
62-
f"files/{crowdinFileID}",
63-
method=requests.put,
64-
json={"storageId": storageID}
65-
)
49+
r = projectRequest(f"files/{crowdinFileID}", method=requests.put, json={"storageId": storageID})
6650
revisionId = r.json()["data"]["revisionId"]
6751
print(f"Updated to revision {revisionId}")
6852

6953

7054
def main():
71-
parser = argparse.ArgumentParser(
72-
description="Syncs translations with Crowdin."
73-
)
55+
parser = argparse.ArgumentParser(description="Syncs translations with Crowdin.")
7456
commands = parser.add_subparsers(dest="command", required=True)
75-
uploadCommand = commands.add_parser(
76-
"uploadSourceFile",
77-
help="Upload a source file to Crowdin."
78-
)
57+
uploadCommand = commands.add_parser("uploadSourceFile", help="Upload a source file to Crowdin.")
7958
uploadCommand.add_argument("crowdinFileID", type=int, help="The Crowdin file ID.")
8059
uploadCommand.add_argument("localFilePath", help="The path to the local file.")
8160
args = parser.parse_args()

appveyor/mozillaSyms.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
NVDA_LIB = os.path.join(NVDA_SOURCE, "lib")
1919
NVDA_LIB64 = os.path.join(NVDA_SOURCE, "lib64")
2020
ZIP_FILE = os.path.join(SCRIPT_DIR, "mozillaSyms.zip")
21-
URL = 'https://symbols.mozilla.org/upload/'
21+
URL = "https://symbols.mozilla.org/upload/"
2222

2323
# The dlls for which symbols are to be uploaded to Mozilla.
2424
# This only needs to include dlls injected into Mozilla products.
@@ -27,56 +27,59 @@
2727
"ISimpleDOM.dll",
2828
"nvdaHelperRemote.dll",
2929
]
30-
DLL_FILES = [f
30+
DLL_FILES = [
31+
f
3132
for dll in DLL_NAMES
3233
# We need both the 32 bit and 64 bit symbols.
33-
for f in (os.path.join(NVDA_LIB, dll), os.path.join(NVDA_LIB64, dll))]
34+
for f in (os.path.join(NVDA_LIB, dll), os.path.join(NVDA_LIB64, dll))
35+
]
36+
3437

3538
class ProcError(Exception):
3639
def __init__(self, returncode, stderr):
3740
self.returncode = returncode
3841
self.stderr = stderr
3942

43+
4044
def check_output(command):
41-
proc = subprocess.Popen(command,
42-
stdout=subprocess.PIPE,
43-
stderr=subprocess.PIPE,
44-
text=True)
45+
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
4546
stdout, stderr = proc.communicate()
4647
if proc.returncode != 0:
4748
raise ProcError(proc.returncode, stderr)
4849
return stdout
4950

51+
5052
def processFile(path):
51-
print("dump_syms %s"%path)
53+
print("dump_syms %s" % path)
5254
try:
5355
stdout = check_output([DUMP_SYMS, path])
5456
except ProcError as e:
5557
print('Error: running "%s %s": %s' % (DUMP_SYMS, path, e.stderr))
5658
return None, None, None
57-
bits = stdout.splitlines()[0].split(' ', 4)
59+
bits = stdout.splitlines()[0].split(" ", 4)
5860
if len(bits) != 5:
5961
return None, None, None
6062
_, platform, cpu_arch, debug_id, debug_file = bits
6163
# debug_file will have a .pdb extension; e.g. nvdaHelperRemote.dll.pdb.
6264
# The output file format should have a .sym extension instead.
6365
# Strip .pdb and add .sym.
64-
sym_file = debug_file[:-4] + '.sym'
66+
sym_file = debug_file[:-4] + ".sym"
6567
filename = os.path.join(debug_file, debug_id, sym_file)
6668
debug_filename = os.path.join(debug_file, debug_id, debug_file)
6769
return filename, stdout, debug_filename
6870

71+
6972
def generate():
7073
count = 0
71-
with zipfile.ZipFile(ZIP_FILE, 'w', zipfile.ZIP_DEFLATED) as zf:
74+
with zipfile.ZipFile(ZIP_FILE, "w", zipfile.ZIP_DEFLATED) as zf:
7275
for f in DLL_FILES:
7376
filename, contents, debug_filename = processFile(f)
7477
if not (filename and contents):
75-
print('Error dumping symbols')
78+
print("Error dumping symbols")
7679
raise RuntimeError
7780
zf.writestr(filename, contents)
7881
count += 1
79-
print('Added %d files to %s' % (count, ZIP_FILE))
82+
print("Added %d files to %s" % (count, ZIP_FILE))
8083

8184

8285
def upload():
@@ -85,37 +88,36 @@ def upload():
8588
if i > 0:
8689
print("Sleeping for 15 seconds before next attempt.")
8790
import time
91+
8892
time.sleep(15)
8993
try:
9094
r = requests.post(
9195
URL,
92-
files={'symbols.zip': open(ZIP_FILE, 'rb')},
93-
headers={'Auth-Token': os.getenv('mozillaSymsAuthToken')},
94-
allow_redirects=False
96+
files={"symbols.zip": open(ZIP_FILE, "rb")},
97+
headers={"Auth-Token": os.getenv("mozillaSymsAuthToken")},
98+
allow_redirects=False,
9599
)
96100
break # success
97101
except Exception as e:
98102
print(f"Attempt {i + 1} failed: {e!r}")
99103
errors.append(repr(e))
100104
else: # no break in for loop
101-
allErrors = "\n".join(
102-
f"Attempt {index + 1} error: \n{e}"
103-
for index, e in enumerate(errors)
104-
)
105+
allErrors = "\n".join(f"Attempt {index + 1} error: \n{e}" for index, e in enumerate(errors))
105106
raise RuntimeError(allErrors)
106107

107108
if 200 <= r.status_code < 300:
108-
print('Uploaded successfully!')
109+
print("Uploaded successfully!")
109110
elif r.status_code < 400:
110-
print('Error: bad auth token? (%d)' % r.status_code)
111+
print("Error: bad auth token? (%d)" % r.status_code)
111112
raise RuntimeError
112113
else:
113-
print('Error: %d' % r.status_code)
114+
print("Error: %d" % r.status_code)
114115
print(r.text)
115116
raise RuntimeError
116117
return 0
117118

118-
if __name__ == '__main__':
119+
120+
if __name__ == "__main__":
119121
try:
120122
generate()
121123
upload()

appx/sconscript

Lines changed: 75 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,118 @@
11
###
2-
#This file is a part of the NVDA project.
3-
#URL: https://www.nvaccess.org/
4-
#Copyright 2018-2019 NV Access Limited
5-
#This program is free software: you can redistribute it and/or modify
6-
#it under the terms of the GNU General Public License version 2.0, as published by
7-
#the Free Software Foundation.
8-
#This program is distributed in the hope that it will be useful,
9-
#but WITHOUT ANY WARRANTY; without even the implied warranty of
10-
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11-
#This license can be found at:
12-
#http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
2+
# This file is a part of the NVDA project.
3+
# URL: https://www.nvaccess.org/
4+
# Copyright 2018-2019 NV Access Limited
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License version 2.0, as published by
7+
# the Free Software Foundation.
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
# This license can be found at:
12+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1313
###
1414

1515
import subprocess
1616
import versionInfo
1717
import os
1818

19-
Import([
20-
'env',
21-
'outFilePrefix',
22-
'isStoreSubmission',
23-
])
19+
Import(
20+
[
21+
"env",
22+
"outFilePrefix",
23+
"isStoreSubmission",
24+
]
25+
)
26+
2427

2528
def getCertPublisher(env):
2629
"""
2730
If no signing certificate is provided, then the given publisher is used as is.
2831
If a signing certificate is given, then the publisher is extracted from the certificate.
2932
"""
30-
certFilePath = env.get('certFile')
33+
certFilePath = env.get("certFile")
3134
if not certFilePath:
32-
return env['publisher']
33-
certPassword=env.get('certPassword','')
35+
return env["publisher"]
36+
certPassword = env.get("certPassword", "")
3437
if not os.path.isabs(certFilePath):
3538
# If path is not absolute it is assumed that it is being given relative to the top dir of the repo
36-
repoTopDir = Dir('#').abspath
39+
repoTopDir = Dir("#").abspath
3740
certFilePath = os.path.abspath(os.path.normpath(os.path.join(repoTopDir, certFilePath)))
38-
cmd=['certutil', '-dump', '-p', certPassword, certFilePath]
39-
lines=subprocess.run(cmd,check=True,capture_output=True,text=True).stdout.splitlines()
40-
linePrefix='Subject: '
41+
cmd = ["certutil", "-dump", "-p", certPassword, certFilePath]
42+
lines = subprocess.run(cmd, check=True, capture_output=True, text=True).stdout.splitlines()
43+
linePrefix = "Subject: "
4144
for line in lines:
4245
if line.startswith(linePrefix):
43-
subject=line[len(linePrefix):].rstrip()
46+
subject = line[len(linePrefix) :].rstrip()
4447
return subject
4548

46-
packageName="NVAccessLimited.NVDANonVisualDesktopAccess"
47-
packageVersion="%s.%s.%s.%s"%(versionInfo.version_year,versionInfo.version_major,env['version_build'],0)
49+
50+
packageName = "NVAccessLimited.NVDANonVisualDesktopAccess"
51+
packageVersion = "%s.%s.%s.%s" % (
52+
versionInfo.version_year,
53+
versionInfo.version_major,
54+
env["version_build"],
55+
0,
56+
)
4857
if isStoreSubmission:
49-
packageFileName=outFilePrefix+"_storeSubmission.appx"
58+
packageFileName = outFilePrefix + "_storeSubmission.appx"
5059
# NV Access Limited's Windows Store publisher ID
5160
# It is okay to be here as the only way to submit, validate and sign the package is via the NV Access store account.
52-
packagePublisher="CN=83B1DA31-9B66-442C-88AB-77B4B815E1DE"
53-
packagePublisherDisplayName="NV Access Limited"
54-
productName="NVDA Screen Reader (Windows Store Edition)"
55-
else: # not for submission, just side-loadable
56-
packageFileName=outFilePrefix+"_sideLoadable.appx"
57-
packagePublisher=getCertPublisher(env)
58-
packagePublisherDisplayName=env['publisher']
59-
productName="NVDA Screen Reader (Windows Desktop Bridge Edition)"
61+
packagePublisher = "CN=83B1DA31-9B66-442C-88AB-77B4B815E1DE"
62+
packagePublisherDisplayName = "NV Access Limited"
63+
productName = "NVDA Screen Reader (Windows Store Edition)"
64+
else: # not for submission, just side-loadable
65+
packageFileName = outFilePrefix + "_sideLoadable.appx"
66+
packagePublisher = getCertPublisher(env)
67+
packagePublisherDisplayName = env["publisher"]
68+
productName = "NVDA Screen Reader (Windows Desktop Bridge Edition)"
6069

61-
signExec = env['signExec'] if (bool(env['certFile']) ^ bool(env['apiSigningToken'])) else None
70+
signExec = env["signExec"] if (bool(env["certFile"]) ^ bool(env["apiSigningToken"])) else None
6271

6372

6473
# Files from NVDA's distribution that cannot be included in the appx due to policy or security restrictions
6574
excludedDistFiles = [
66-
'nvda_slave.exe',
67-
'nvda_noUIAccess.exe',
68-
'lib/IAccessible2Proxy.dll',
69-
'lib/ISimpleDOM.dll',
70-
'lib/NVDAHelperRemote.dll',
71-
'lib64/',
72-
'libArm64/',
73-
'uninstall.exe',
75+
"nvda_slave.exe",
76+
"nvda_noUIAccess.exe",
77+
"lib/IAccessible2Proxy.dll",
78+
"lib/ISimpleDOM.dll",
79+
"lib/NVDAHelperRemote.dll",
80+
"lib64/",
81+
"libArm64/",
82+
"uninstall.exe",
7483
]
7584

76-
# Create an appx manifest with version and publisher etc all filled in
77-
manifest=env.Substfile(
85+
# Create an appx manifest with version and publisher etc all filled in
86+
manifest = env.Substfile(
7887
"AppxManifest.xml",
79-
'manifest.xml.subst',
88+
"manifest.xml.subst",
8089
SUBST_DICT={
81-
'%packageName%':packageName,
82-
'%packageVersion%':packageVersion,
83-
'%packagePublisher%':packagePublisher,
84-
'%publisher%':packagePublisherDisplayName,
85-
'%productName%':productName,
86-
'%description%':versionInfo.description,
90+
"%packageName%": packageName,
91+
"%packageVersion%": packageVersion,
92+
"%packagePublisher%": packagePublisher,
93+
"%publisher%": packagePublisherDisplayName,
94+
"%productName%": productName,
95+
"%description%": versionInfo.description,
8796
},
8897
)
89-
# Make a copy of the dist dir produced by py2exe
98+
# Make a copy of the dist dir produced by py2exe
9099
# And also place some extra appx specific images in there
91-
appxContent=env.Command(
92-
target='content',
93-
source=[Dir("#dist"),Dir('#appx/appx_images'),manifest],
100+
appxContent = env.Command(
101+
target="content",
102+
source=[Dir("#dist"), Dir("#appx/appx_images"), manifest],
94103
action=[
95104
Delete("$TARGET"),
96-
Copy("$TARGET","${SOURCES[0]}"),
97-
Copy("${TARGET}\\appx_images","${SOURCES[1]}"),
98-
Copy("${TARGET}\\AppxManifest.xml","${SOURCES[2]}"),
99-
]+[Delete("${TARGET}/%s"%excludeFile) for excludeFile in excludedDistFiles],
105+
Copy("$TARGET", "${SOURCES[0]}"),
106+
Copy("${TARGET}\\appx_images", "${SOURCES[1]}"),
107+
Copy("${TARGET}\\AppxManifest.xml", "${SOURCES[2]}"),
108+
]
109+
+ [Delete("${TARGET}/%s" % excludeFile) for excludeFile in excludedDistFiles],
100110
)
101-
# Ensure that it is always copied as we can't tell if dist changed
111+
# Ensure that it is always copied as we can't tell if dist changed
102112
env.AlwaysBuild(appxContent)
103113
# Package the appx
104-
appx=env.Command(packageFileName,appxContent,"makeappx pack /p $TARGET /d $SOURCE")
114+
appx = env.Command(packageFileName, appxContent, "makeappx pack /p $TARGET /d $SOURCE")
105115
if signExec and not isStoreSubmission:
106-
env.AddPostAction(appx,signExec)
116+
env.AddPostAction(appx, signExec)
107117

108-
Return(['appx'])
118+
Return(["appx"])

0 commit comments

Comments
 (0)