mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 14:31:46 +00:00
clean run
This commit is contained in:
@@ -143,7 +143,7 @@ class Comparator:
|
||||
|
||||
def _diff(self, left, right, header=False):
|
||||
"""diff two files"""
|
||||
out = diff(modified=left, original=right, raw=False,
|
||||
out = diff(modified=left, original=right,
|
||||
diff_cmd=self.diff_cmd, debug=self.debug)
|
||||
if header:
|
||||
lshort = os.path.basename(left)
|
||||
|
||||
@@ -687,7 +687,7 @@ class Installer:
|
||||
if content:
|
||||
tmp = utils.write_to_tmpfile(content)
|
||||
src = tmp
|
||||
diff = utils.diff(modified=src, original=dst, raw=False,
|
||||
diff = utils.diff(modified=src, original=dst,
|
||||
diff_cmd=self.diff_cmd)
|
||||
if tmp:
|
||||
utils.removepath(tmp, logger=self.log)
|
||||
|
||||
@@ -153,7 +153,7 @@ class Templategen:
|
||||
self.log.dbg('using \"magic\" for filetype identification')
|
||||
except ImportError:
|
||||
_, filetype = utils.run(['file', '-b', '--mime-type', src],
|
||||
raw=False, debug=self.debug)
|
||||
debug=self.debug)
|
||||
if self.debug:
|
||||
self.log.dbg('using \"file\" for filetype identification')
|
||||
filetype = filetype.strip()
|
||||
|
||||
@@ -33,7 +33,7 @@ DONOTDELETE = [
|
||||
NOREMOVE = [os.path.normpath(p) for p in DONOTDELETE]
|
||||
|
||||
|
||||
def run(cmd, raw=True, debug=False, checkerr=False):
|
||||
def run(cmd, debug=False):
|
||||
"""run a command (expects a list)"""
|
||||
if debug:
|
||||
LOG.dbg('exec: {}'.format(' '.join(cmd)))
|
||||
@@ -43,13 +43,6 @@ def run(cmd, raw=True, debug=False, checkerr=False):
|
||||
ret = p.returncode
|
||||
out = out.splitlines(keepends=True)
|
||||
lines = ''.join([x.decode('utf-8', 'replace') for x in out])
|
||||
if checkerr and ret != 0:
|
||||
c = ' '.join(cmd)
|
||||
errl = lines.rstrip()
|
||||
m = '\"{}\" returned non zero ({}): {}'.format(c, ret, errl)
|
||||
LOG.err(m)
|
||||
if raw:
|
||||
return ret == 0, out
|
||||
return ret == 0, lines
|
||||
|
||||
|
||||
@@ -79,7 +72,7 @@ def fastdiff(left, right):
|
||||
return not filecmp.cmp(left, right, shallow=False)
|
||||
|
||||
|
||||
def diff(original, modified, raw=True,
|
||||
def diff(original, modified,
|
||||
diff_cmd='', debug=False):
|
||||
"""compare two files, returns '' if same"""
|
||||
if not diff_cmd:
|
||||
@@ -92,7 +85,7 @@ def diff(original, modified, raw=True,
|
||||
"{modified}": modified,
|
||||
}
|
||||
cmd = [replacements.get(x, x) for x in diff_cmd.split()]
|
||||
_, out = run(cmd, raw=raw, debug=debug)
|
||||
_, out = run(cmd, debug=debug)
|
||||
return out
|
||||
|
||||
|
||||
|
||||
@@ -94,6 +94,9 @@ profiles:
|
||||
_EOF
|
||||
#cat ${cfg}
|
||||
|
||||
# list profiles
|
||||
cd ${ddpath} | ${bin} profiles -c ${cfg} -V
|
||||
|
||||
# create the dotfile
|
||||
echo "test" > ${tmps}/dotfiles/abc
|
||||
echo "test" > ${tmps}/dotfiles/def
|
||||
|
||||
Reference in New Issue
Block a user