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