Skip to content

Commit

Permalink
Fix dangling file handles
Browse files Browse the repository at this point in the history
Summary: Not sure why these weren't closed properly before

Differential Revision: D33961678

fbshipit-source-id: d110cc971adc2f2fc9744fb48fa474862fd10e6b
  • Loading branch information
xiphirx authored and facebook-github-bot committed Feb 3, 2022
1 parent f088bf8 commit 4f33788
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions plugin/src/py/android_screenshot_tests/pull_screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def generate_html(
# and returns a url to an image from a previous run of the test,
# old_imgs_data a dict that will be used in the test_img_api url.
# Creates the html for showing a before and after comparison of the images.
screenshots = json.load(open(join(output_dir, "metadata.json")))
with open(join(output_dir, "metadata.json")) as m:
screenshots = json.load(m)
alternate = False
index_html = abspath(join(output_dir, "index.html"))
with codecs.open(index_html, mode="w", encoding="utf-8") as html:
Expand Down Expand Up @@ -530,7 +531,8 @@ def move_all_files_to_different_directory(source_dir, target_dir):


def _summary(dir):
metadataJson = json.load(open(join(dir, "metadata.json")))
with open(join(dir, "metadata.json")) as f:
metadataJson = json.load(f)
count = len(metadataJson)
print("Found %d screenshots" % count)

Expand Down
4 changes: 2 additions & 2 deletions plugin/src/py/android_screenshot_tests/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def _copy(self, name, w, h):
im.close()

def _get_metadata_json(self):
file = open(join(self._input, "metadata.json"), "r")
return json.load(file)
with open(join(self._input, "metadata.json"), "r") as f:
return json.load(f)

def _record(self):
metadata = self._get_metadata_json()
Expand Down

0 comments on commit 4f33788

Please sign in to comment.