|
@@ -32,16 +32,12 @@ $XONSH_APPEND_NEWLINE = True
|
|
|
|
|
|
import datetime as dt
|
|
|
import io
|
|
|
-import json
|
|
|
import os
|
|
|
import re
|
|
|
-import select
|
|
|
-import shlex
|
|
|
import shutil
|
|
|
import stat
|
|
|
import subprocess
|
|
|
import sys
|
|
|
-import threading
|
|
|
|
|
|
os.umask(stat.S_IWGRP | stat.S_IRWXO) # 027
|
|
|
# default locale
|
|
@@ -87,6 +83,7 @@ $DOCKER_CONTENT_TRUST = 1
|
|
|
class DockerImage:
|
|
|
|
|
|
def __init__(self, image):
|
|
|
+ import json
|
|
|
attrs, = json.loads(subprocess.check_output(['sudo', 'docker', 'image', 'inspect', image])
|
|
|
.decode(sys.stdout.encoding))
|
|
|
self._id = attrs['Id']
|
|
@@ -136,6 +133,7 @@ class StdoutTee:
|
|
|
|
|
|
def __enter__(self):
|
|
|
self._read_fd, self._write_fd = os.pipe()
|
|
|
+ import threading
|
|
|
self._thread = threading.Thread(target=self._loop)
|
|
|
self._thread.start()
|
|
|
return self
|
|
@@ -194,12 +192,14 @@ def locate(*patterns, match_all=True, ignore_case=True):
|
|
|
return $(locate @(params) -- @(patterns)).split('\n')[:-1]
|
|
|
|
|
|
def os_read_non_blocking(fd, buffer_size_bytes=8*1024, timeout_seconds=0.1):
|
|
|
+ import select
|
|
|
if fd in select.select([fd], [], [], timeout_seconds)[0]:
|
|
|
return os.read(fd, buffer_size_bytes)
|
|
|
else:
|
|
|
return None
|
|
|
|
|
|
def shlex_join(params):
|
|
|
+ import shlex
|
|
|
return ' '.join(shlex.quote(p) for p in params)
|
|
|
|
|
|
def timestamp_now_utc():
|