Skip to content

Commit

Permalink
Add hot-patch for tomerfiliba/plumbum#180
Browse files Browse the repository at this point in the history
  • Loading branch information
tillberg committed Jul 2, 2015
1 parent 5878b36 commit 1a7193a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions gut/gut.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import plumbum
from plumbum.commands.processes import ProcessExecutionError
import patch_plumbum; patch_plumbum.patch_darwin_stat()

GIT_REPO_URL = 'https://github.com/git/git.git'
GIT_VERSION = 'v2.4.5'
Expand Down
26 changes: 26 additions & 0 deletions gut/patch_plumbum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
def patch_darwin_stat():
import plumbum
from plumbum.commands import shquote
from plumbum.path.remote import StatRes
def _path_getuid(self, fn):
stat_cmd = "stat -c '%u,%U' " if self.uname != 'Darwin' else "stat -f '%u,%Su' "
return self._session.run(stat_cmd + shquote(fn))[1].strip().split(",")
def _path_getgid(self, fn):
stat_cmd = "stat -c '%g,%G' " if self.uname != 'Darwin' else "stat -f '%g,%Sg' "
return self._session.run(stat_cmd + shquote(fn))[1].strip().split(",")
def _path_stat(self, fn):
if self.uname != 'Darwin':
stat_cmd = "stat -c '%F,%f,%i,%d,%h,%u,%g,%s,%X,%Y,%Z' "
else:
stat_cmd = "stat -f '%HT,%Xp,%i,%d,%l,%u,%g,%z,%a,%m,%c' "
rc, out, _ = self._session.run(stat_cmd + shquote(fn), retcode = None)
if rc != 0:
return None
statres = out.strip().split(",")
text_mode = statres.pop(0).lower()
res = StatRes((int(statres[0], 16),) + tuple(int(sr) for sr in statres[1:]))
res.text_mode = text_mode
return res
plumbum.machines.remote.BaseRemoteMachine._path_getuid = _path_getuid
plumbum.machines.remote.BaseRemoteMachine._path_getgid = _path_getgid
plumbum.machines.remote.BaseRemoteMachine._path_stat = _path_stat

0 comments on commit 1a7193a

Please sign in to comment.