1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-07 07:05:48 +00:00

first commit

This commit is contained in:
deadc0de6
2017-03-07 19:19:00 +01:00
commit a356979555
13 changed files with 1327 additions and 0 deletions

29
dotdrop/utils.py Normal file
View File

@@ -0,0 +1,29 @@
"""
author: deadc0de6 (https://github.com/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()
return ''.join([x.decode("utf-8") for x in p.stdout.readlines()])
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-')