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