1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-05 17:53:52 +00:00
Files
dotdrop/dotdrop/utils.py
deadc0de6 a1c48de359 fix pep8
2017-03-15 18:00:40 +01:00

32 lines
733 B
Python

"""
author: deadc0de6 (https://github.com/deadc0de6)
Copyright (c) 2017, deadc0de6
utilities
"""
import subprocess
import tempfile
from logger import Logger
LOG = Logger()
def run(cmd, log=False, raw=True):
""" expects a list """
if log:
LOG.log('cmd: \"%s\"' % (' '.join(cmd)))
p = subprocess.Popen(cmd, shell=False,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if raw:
return p.stdout.readlines()
lines = [x.decode('utf-8', 'replace') for x in p.stdout.readlines()]
return ''.join(lines)
def diff(src, dst, log=False, raw=True):
return run(['diff', '-r', src, dst], log=log, raw=raw)
def get_tmpdir():
return tempfile.mkdtemp(prefix='dotdrop-')