1*3117ece4Schristos#!/usr/bin/env python3 2*3117ece4Schristos# ################################################################ 3*3117ece4Schristos# Copyright (c) Meta Platforms, Inc. and affiliates. 4*3117ece4Schristos# All rights reserved. 5*3117ece4Schristos# 6*3117ece4Schristos# This source code is licensed under both the BSD-style license (found in the 7*3117ece4Schristos# LICENSE file in the root directory of this source tree) and the GPLv2 (found 8*3117ece4Schristos# in the COPYING file in the root directory of this source tree). 9*3117ece4Schristos# You may select, at your option, one of the above-listed licenses. 10*3117ece4Schristos# ################################################################ 11*3117ece4Schristos 12*3117ece4Schristosimport os 13*3117ece4Schristosimport subprocess 14*3117ece4Schristosimport sys 15*3117ece4Schristos 16*3117ece4Schristosif len(sys.argv) != 3: 17*3117ece4Schristos print(f"Usage: {sys.argv[0]} FILE SIZE_LIMIT") 18*3117ece4Schristos sys.exit(1) 19*3117ece4Schristos 20*3117ece4Schristosfile = sys.argv[1] 21*3117ece4Schristoslimit = int(sys.argv[2]) 22*3117ece4Schristos 23*3117ece4Schristosif not os.path.exists(file): 24*3117ece4Schristos print(f"{file} does not exist") 25*3117ece4Schristos sys.exit(1) 26*3117ece4Schristos 27*3117ece4Schristossize = os.path.getsize(file) 28*3117ece4Schristos 29*3117ece4Schristosif size > limit: 30*3117ece4Schristos print(f"file {file} is {size} bytes, which is greater than the limit of {limit} bytes") 31*3117ece4Schristos sys.exit(1) 32