mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-07 07:05:48 +00:00
first commit
This commit is contained in:
29
dotdrop/utils.py
Normal file
29
dotdrop/utils.py
Normal 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-')
|
||||
Reference in New Issue
Block a user