cros_sdk: use osutils helpers to read/write
This fixes missing context manager with the open calls, and simplifies
the code a bit by using our helpers.
BUG=b:234353695
TEST=`cros_sdk` still works and can update this file
Change-Id: Ib8f6da802076a8e45d2194cf2be1160a3b5f3a6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3721762
Tested-by: Mike Frysinger <vapier@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Cindy Lin <xcl@google.com>
Reviewed-by: Cindy Lin <xcl@google.com>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index 59e3708..5093c74 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -207,11 +207,11 @@
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
resource.setrlimit(resource.RLIMIT_NOFILE,
(max(soft, file_limit), max(hard, file_limit)))
- max_map_count = int(open('/proc/sys/vm/max_map_count').read())
+ max_map_count = int(osutils.ReadFile('/proc/sys/vm/max_map_count'))
if max_map_count < file_limit:
logging.notice(
'Raising vm.max_map_count from %s to %s', max_map_count, file_limit)
- open('/proc/sys/vm/max_map_count', 'w').write(f'{file_limit}\n')
+ osutils.WriteFile('/proc/sys/vm/max_map_count', str(file_limit))
return cros_build_lib.dbg_run(cmd, check=False)