Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
33 changes: 6 additions & 27 deletions appveyor/crowdinSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,12 @@


def request(
path: str,
method=requests.get,
headers: dict[str, str] | None = None,
**kwargs
path: str, method=requests.get, headers: dict[str, str] | None = None, **kwargs
) -> requests.Response:
if headers is None:
headers = {}
headers["Authorization"] = f"Bearer {AUTH_TOKEN}"
r = method(
f"https://api.crowdin.com/api/v2/{path}",
headers=headers,
**kwargs
)
r = method(f"https://api.crowdin.com/api/v2/{path}", headers=headers, **kwargs)
# Convert errors to exceptions, but print the response before raising.
try:
r.raise_for_status()
Expand All @@ -50,32 +43,18 @@ def uploadSourceFile(crowdinFileID: int, localFilePath: str) -> None:
fn = os.path.basename(localFilePath)
print(f"Uploading {localFilePath} to Crowdin temporary storage as {fn}")
with open(localFilePath, "rb") as f:
r = request(
"storages",
method=requests.post,
headers={"Crowdin-API-FileName": fn},
data=f
)
r = request("storages", method=requests.post, headers={"Crowdin-API-FileName": fn}, data=f)
storageID = r.json()["data"]["id"]
print(f"Updating file {crowdinFileID} on Crowdin with storage ID {storageID}")
r = projectRequest(
f"files/{crowdinFileID}",
method=requests.put,
json={"storageId": storageID}
)
r = projectRequest(f"files/{crowdinFileID}", method=requests.put, json={"storageId": storageID})
revisionId = r.json()["data"]["revisionId"]
print(f"Updated to revision {revisionId}")


def main():
parser = argparse.ArgumentParser(
description="Syncs translations with Crowdin."
)
parser = argparse.ArgumentParser(description="Syncs translations with Crowdin.")
commands = parser.add_subparsers(dest="command", required=True)
uploadCommand = commands.add_parser(
"uploadSourceFile",
help="Upload a source file to Crowdin."
)
uploadCommand = commands.add_parser("uploadSourceFile", help="Upload a source file to Crowdin.")
uploadCommand.add_argument("crowdinFileID", type=int, help="The Crowdin file ID.")
uploadCommand.add_argument("localFilePath", help="The path to the local file.")
args = parser.parse_args()
Expand Down
50 changes: 26 additions & 24 deletions appveyor/mozillaSyms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
NVDA_LIB = os.path.join(NVDA_SOURCE, "lib")
NVDA_LIB64 = os.path.join(NVDA_SOURCE, "lib64")
ZIP_FILE = os.path.join(SCRIPT_DIR, "mozillaSyms.zip")
URL = 'https://symbols.mozilla.org/upload/'
URL = "https://symbols.mozilla.org/upload/"

# The dlls for which symbols are to be uploaded to Mozilla.
# This only needs to include dlls injected into Mozilla products.
Expand All @@ -27,56 +27,59 @@
"ISimpleDOM.dll",
"nvdaHelperRemote.dll",
]
DLL_FILES = [f
DLL_FILES = [
f
for dll in DLL_NAMES
# We need both the 32 bit and 64 bit symbols.
for f in (os.path.join(NVDA_LIB, dll), os.path.join(NVDA_LIB64, dll))]
for f in (os.path.join(NVDA_LIB, dll), os.path.join(NVDA_LIB64, dll))
]


class ProcError(Exception):
def __init__(self, returncode, stderr):
self.returncode = returncode
self.stderr = stderr


def check_output(command):
proc = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True)
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout, stderr = proc.communicate()
if proc.returncode != 0:
raise ProcError(proc.returncode, stderr)
return stdout


def processFile(path):
print("dump_syms %s"%path)
print("dump_syms %s" % path)
try:
stdout = check_output([DUMP_SYMS, path])
except ProcError as e:
print('Error: running "%s %s": %s' % (DUMP_SYMS, path, e.stderr))
return None, None, None
bits = stdout.splitlines()[0].split(' ', 4)
bits = stdout.splitlines()[0].split(" ", 4)
if len(bits) != 5:
return None, None, None
_, platform, cpu_arch, debug_id, debug_file = bits
# debug_file will have a .pdb extension; e.g. nvdaHelperRemote.dll.pdb.
# The output file format should have a .sym extension instead.
# Strip .pdb and add .sym.
sym_file = debug_file[:-4] + '.sym'
sym_file = debug_file[:-4] + ".sym"
filename = os.path.join(debug_file, debug_id, sym_file)
debug_filename = os.path.join(debug_file, debug_id, debug_file)
return filename, stdout, debug_filename


def generate():
count = 0
with zipfile.ZipFile(ZIP_FILE, 'w', zipfile.ZIP_DEFLATED) as zf:
with zipfile.ZipFile(ZIP_FILE, "w", zipfile.ZIP_DEFLATED) as zf:
for f in DLL_FILES:
filename, contents, debug_filename = processFile(f)
if not (filename and contents):
print('Error dumping symbols')
print("Error dumping symbols")
raise RuntimeError
zf.writestr(filename, contents)
count += 1
print('Added %d files to %s' % (count, ZIP_FILE))
print("Added %d files to %s" % (count, ZIP_FILE))


def upload():
Expand All @@ -85,37 +88,36 @@ def upload():
if i > 0:
print("Sleeping for 15 seconds before next attempt.")
import time

time.sleep(15)
try:
r = requests.post(
URL,
files={'symbols.zip': open(ZIP_FILE, 'rb')},
headers={'Auth-Token': os.getenv('mozillaSymsAuthToken')},
allow_redirects=False
files={"symbols.zip": open(ZIP_FILE, "rb")},
headers={"Auth-Token": os.getenv("mozillaSymsAuthToken")},
allow_redirects=False,
)
break # success
except Exception as e:
print(f"Attempt {i + 1} failed: {e!r}")
errors.append(repr(e))
else: # no break in for loop
allErrors = "\n".join(
f"Attempt {index + 1} error: \n{e}"
for index, e in enumerate(errors)
)
allErrors = "\n".join(f"Attempt {index + 1} error: \n{e}" for index, e in enumerate(errors))
raise RuntimeError(allErrors)

if 200 <= r.status_code < 300:
print('Uploaded successfully!')
print("Uploaded successfully!")
elif r.status_code < 400:
print('Error: bad auth token? (%d)' % r.status_code)
print("Error: bad auth token? (%d)" % r.status_code)
raise RuntimeError
else:
print('Error: %d' % r.status_code)
print("Error: %d" % r.status_code)
print(r.text)
raise RuntimeError
return 0

if __name__ == '__main__':

if __name__ == "__main__":
try:
generate()
upload()
Expand Down
12 changes: 6 additions & 6 deletions extras/controllerClient/examples/example_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ def onMarkReached(name: str) -> int:


ssml = (
'<speak>'
'This is one sentence. '
"<speak>"
"This is one sentence. "
'<mark name="test" />'
'<prosody pitch="200%">This sentence is pronounced with higher pitch.</prosody>'
'<mark name="test2" />'
'This is a third sentence. '
"This is a third sentence. "
'<mark name="test3" />'
'This is a fourth sentence. We will stay silent for a second after this one.'
"This is a fourth sentence. We will stay silent for a second after this one."
'<break time="1000ms" />'
'<mark name="test4" />'
'This is a fifth sentence. '
"This is a fifth sentence. "
'<mark name="test5" />'
'</speak>'
"</speak>"
)
clientLib.nvdaController_setOnSsmlMarkReachedCallback(onMarkReached)
clientLib.nvdaController_speakSsml(ssml, -1, 0, False)
Expand Down
21 changes: 11 additions & 10 deletions projectDocs/dev/developerGuide/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import os
import sys

_appDir = os.path.abspath(os.path.join("..", "..", "..", "source"))

sys.path.insert(0, _appDir)
Expand All @@ -23,11 +24,13 @@
# by comTypes.
# This patch causes the error to be ignored, which matches the behavior at runtime.
import monkeyPatches.comtypesMonkeyPatches # noqa: E402

monkeyPatches.comtypesMonkeyPatches.replace_check_version()
monkeyPatches.comtypesMonkeyPatches.appendComInterfacesToGenSearchPath()

# Initialize languageHandler so that sphinx is able to deal with translatable strings.
import languageHandler # noqa: E402

languageHandler.setLanguage("en")

# Initialize globalVars.appArgs to something sensible.
Expand All @@ -47,6 +50,7 @@

# Import NVDA's versionInfo module.
import versionInfo # noqa: E402

# Set a suitable updateVersionType for the updateCheck module to be imported
versionInfo.updateVersionType = "stable"

Expand All @@ -58,34 +62,30 @@

# The major project version
version = versionInfo.formatVersionForGUI(
versionInfo.version_year,
versionInfo.version_major,
versionInfo.version_minor
versionInfo.version_year, versionInfo.version_major, versionInfo.version_minor
)

# The full version, including alpha/beta/rc tags
release = versionInfo.version

# -- General configuration ---------------------------------------------------

default_role = 'py:obj'
default_role = "py:obj"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
"sphinx.ext.autodoc",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
"_build"
]
exclude_patterns = ["_build"]


# -- Options for HTML output -------------------------------------------------
Expand All @@ -100,7 +100,7 @@

# Both the class’ and the __init__ method’s docstring are concatenated and inserted.
autoclass_content = "both"
autodoc_member_order = 'bysource'
autodoc_member_order = "bysource"
autodoc_mock_imports = [
"louis", # Not our project
]
Expand All @@ -110,5 +110,6 @@
from sphinx.ext.autodoc.mock import _make_subclass # noqa: E402

import config # noqa: E402

# Mock an instance of the configuration manager.
config.conf = _make_subclass("conf", "config")()
Loading