Bug 1393657 - Use mozfile.TemporaryDirectory; r=glandium
authorGregory Szorc <gps@mozilla.com>
Thu, 24 Aug 2017 18:32:05 -0700
changeset 426286 2c8f9c706b62d90f64e39f0da9945bfa541175c1
parent 426285 46cb55bc06c848ad5503a711cb02763489fff0ae
child 426287 5503809c794a361f38489cda481a188dda8fe48d
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1393657
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1393657 - Use mozfile.TemporaryDirectory; r=glandium An inline comment wanted it. The change is trivial. MozReview-Commit-ID: CqyOYqNzwzr
build/pgo/profileserver.py
--- a/build/pgo/profileserver.py
+++ b/build/pgo/profileserver.py
@@ -1,21 +1,20 @@
 #!/usr/bin/python
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import json
 import os
-import shutil
-import tempfile
 
 from buildconfig import substs
 from mozbuild.base import MozbuildObject
+from mozfile import TemporaryDirectory
 from mozhttpd import MozHttpd
 from mozprofile import FirefoxProfile, Profile, Preferences
 from mozprofile.permissions import ServerLocations
 from mozrunner import FirefoxRunner, CLI
 
 PORT = 8888
 
 if __name__ == '__main__':
@@ -27,19 +26,17 @@ if __name__ == '__main__':
                      docroot=os.path.join(build.topsrcdir, "build", "pgo"))
     httpd.start(block=False)
 
     locations = ServerLocations()
     locations.add_host(host='127.0.0.1',
                        port=PORT,
                        options='primary,privileged')
 
-    # TODO: mozfile.TemporaryDirectory
-    profilePath = tempfile.mkdtemp()
-    try:
+    with TemporaryDirectory() as profilePath:
         # TODO: refactor this into mozprofile
         prefpath = os.path.join(
             build.topsrcdir, "testing", "profiles", "prefs_general.js")
         prefs = {}
         prefs.update(Preferences.read_prefs(prefpath))
         interpolation = {"server": "%s:%d" % httpd.httpd.server_address,
                          "OOP": "false"}
         prefs = json.loads(json.dumps(prefs) % interpolation)
@@ -84,10 +81,8 @@ if __name__ == '__main__':
         runner = FirefoxRunner(profile=profile,
                                binary=build.get_binary_path(
                                    where="staged-package"),
                                cmdargs=cmdargs,
                                env=env)
         runner.start(debug_args=debug_args, interactive=interactive)
         runner.wait()
         httpd.stop()
-    finally:
-        shutil.rmtree(profilePath)