Skip to content

Commit

Permalink
Merge pull request #49 from swayf/chmod
Browse files Browse the repository at this point in the history
chmod is introduced
  • Loading branch information
tomerfiliba committed Nov 30, 2012
2 parents 3b5717a + f9d0a25 commit 72b7702
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plumbum/local_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ def chown(self, owner=None, group=None, recursive = None):
for subpath in self.walk():
os.chown(str(subpath), uid, gid)

@_setdoc(Path)
def chmod(self, mode):
if not hasattr(os, "chmod"):
raise OSError("os.chmod() not supported")
os.chmod(str(self), mode)


class Workdir(LocalPath):
"""Working directory manipulator"""
Expand Down
6 changes: 6 additions & 0 deletions plumbum/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,10 @@ def chown(self, owner=None, group=None, recursive=None):
will default to ``True`` if ``self`` is a directory, ``False`` otherwise.
"""
raise NotImplementedError()
def chmod(self, mode):
"""Change the mode of path to the numeric mode.
:param mode: file mode as for os.chmod
"""
raise NotImplementedError()

5 changes: 5 additions & 0 deletions plumbum/remote_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,8 @@ def chown(self, owner=None, group=None, recursive=None):
args.append(shquote(self))
self.remote._session.run(" ".join(args))

@_setdoc(Path)
def chmod(self, mode):
args = ["chmod", '%o' % mode, shquote(self)]
self.remote._session.run(" ".join(args))

0 comments on commit 72b7702

Please sign in to comment.