Skip to content

Commit 96fb871

Browse files
[treescript] fix android_l10n_sync checkout (#899)
1 parent 5b2ef18 commit 96fb871

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

treescript/src/treescript/gecko/android_l10n.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
#!/usr/bin/env python
22
"""Treescript android-l10n import and sync support.
33
"""
4-
import asyncio
54
import logging
65
import os
76
import shutil
87
import tempfile
9-
from compare_locales import parser, paths
8+
from compare_locales import paths
109

11-
from scriptworker_client.aio import retry_async
1210
from scriptworker_client.utils import run_command
1311

1412
from treescript.exceptions import CheckoutError
1513
from treescript.gecko import mercurial as vcs
16-
from treescript.util.task import CLOSED_TREE_MSG, DONTBUILD_MSG, get_dontbuild, get_ignore_closed_tree, get_android_l10n_import_info, get_android_l10n_sync_info, get_short_source_repo
14+
from treescript.util.task import (
15+
CLOSED_TREE_MSG,
16+
DONTBUILD_MSG,
17+
get_dontbuild,
18+
get_ignore_closed_tree,
19+
get_android_l10n_import_info,
20+
get_android_l10n_sync_info,
21+
get_short_source_repo,
22+
)
1723
from treescript.util.treestatus import check_treestatus
1824

1925
log = logging.getLogger(__name__)
@@ -161,15 +167,13 @@ async def android_l10n_import(config, task, repo_path):
161167

162168
description = "Import translations from android-l10n"
163169
task_info = get_android_l10n_import_info(task)
164-
from_repo_path = tempfile.mkdtemp()
165-
try:
170+
with tempfile.TemporaryDirectory() as tmp:
171+
from_repo_path = os.path.join(tmp, "android-l10n-import")
166172
from_repo_url = task_info["from_repo_url"]
167173
cmd = ["git", "clone", from_repo_url, from_repo_path]
168174
await run_command(cmd, exception=CheckoutError)
169175
search_path = None
170176
changes = await android_l10n_action(config, task, task_info, repo_path, from_repo_path, description, search_path, None, "dest_path")
171-
finally:
172-
shutil.rmtree(from_repo_path, ignore_errors=True)
173177

174178
return changes
175179

@@ -196,13 +200,11 @@ async def android_l10n_sync(config, task, repo_path):
196200

197201
description = "Merge android-l10n translations from mozilla-central"
198202
task_info = get_android_l10n_sync_info(task)
199-
from_repo_path = tempfile.mkdtemp()
200-
try:
203+
with tempfile.TemporaryDirectory() as tmp:
204+
from_repo_path = os.path.join(tmp, "android-l10n-sync")
201205
from_repo_url = task_info["from_repo_url"]
202206
await vcs.checkout_repo(config, task, from_repo_url, from_repo_path)
203207
search_path = from_repo_path
204208
changes = await android_l10n_action(config, task, task_info, repo_path, from_repo_path, description, search_path, from_repo_path, "toml_path")
205-
finally:
206-
shutil.rmtree(from_repo_path, ignore_errors=True)
207209

208210
return changes

0 commit comments

Comments
 (0)