You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sometimes, InputApi users need to create temporary files, write to them and
pass them to another process, like this:
with input_api.tempfile.NamedTemporaryFile() as f:
f.write('foo')
input_api.subprocess.check_output(['/path/to/script',
'--reading-from', f.name])
While this works fine on Unix, on Windows subprocess cannot open and read
the file while we have it open for writing.
To work around this, we now offer a CreateTemporaryFile() that wraps a call
to tempfile.NamedTemporaryFile(delete=False), and we then take care of
removing all files created this way at the end of a presubmit run.
The idea is for users to do something like this:
with input_api.CreateTemporaryFile() as f:
f.write('foo')
f.close()
input_api.subprocess.check_output(['/path/to/script',
'--reading-from', f.name])
with the temporary file being removed automatically in a transparent fashion
later.
Bug: 780629
Change-Id: I0d705a5d52928a43f39a51f94a2c48d277bd5ced
Reviewed-on: https://chromium-review.googlesource.com/758637
Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>
Reviewed-by: Aaron Gable <agable@chromium.org>
|
8 years ago | |
|---|---|---|
| .. | ||
| gstools | ||
| bot_update_coverage_test.py | 8 years ago | |
| checkout_test.py | 8 years ago | |
| download_from_google_storage_unittest.py | 8 years ago | |
| fix_encoding_test.py | ||
| gclient_eval_unittest.py | 8 years ago | |
| gclient_scm_test.py | 8 years ago | |
| gclient_smoketest.py | 8 years ago | |
| gclient_test.py | 8 years ago | |
| gclient_utils_test.py | 8 years ago | |
| git_cache_test.py | ||
| git_cl_creds_check_report.txt | 8 years ago | |
| git_cl_test.py | 8 years ago | |
| git_common_test.py | ||
| git_dates_test.py | ||
| git_drover_test.py | ||
| git_footers_test.py | 8 years ago | |
| git_hyper_blame_test.py | 8 years ago | |
| git_number_test.py | ||
| git_rebase_update_test.py | ||
| gsutil_test.py | 8 years ago | |
| owners_finder_test.py | ||
| owners_unittest.py | 8 years ago | |
| patch_test.py | ||
| presubmit_unittest.py | 8 years ago | |
| recipes_test.py | ||
| scm_unittest.py | ||
| subprocess2_test.py | ||
| upload_to_google_storage_unittest.py | 8 years ago | |
| watchlists_unittest.py | ||