-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-cleanup
executable file
·37 lines (27 loc) · 961 Bytes
/
docker-cleanup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
from __future__ import print_function
import sys
import os
import glob
import docker_cleanup.main
def try_venv_or_exit(message):
"""Retry this command inside a venv or error out"""
if 'VIRTUAL_ENV' in os.environ:
# Already in a virtual environment.
print(message, file=sys.stderr)
sys.exit(1)
this_dir = os.path.dirname(__file__)
globs = glob.glob(os.path.join(this_dir, 'venv*/bin/docker-cleanup'))
if len(globs) != 1:
print(message, file=sys.stderr)
sys.exit(1)
print("Running command using venv: %s" % globs[0], file=sys.stderr)
os.execv(globs[0], sys.argv)
if __name__ == '__main__':
if sys.version_info < (3, 3):
try_venv_or_exit('docker-cleanup requires Python >= 3.3 to run.')
try:
import dateutil
except ImportError:
try_venv_or_exit('docker-cleanup requires python-dateutil to run.')
docker_cleanup.main.main()