-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional function to fs module #39
Changes from 9 commits
0f571c7
9a91b3d
beee0c0
db495a8
961f5bf
9b9d311
44e2d28
9ea0f26
622abbc
444fa62
b4c6ff2
f653ba5
763ddb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,3 +89,48 @@ def create_script(self, content, path): | |
raise errors.CommandExecutionFailure( | ||
executor, cmd, rc, err, | ||
) | ||
|
||
def mkdir(self, path): | ||
""" | ||
Create directory on host | ||
|
||
:param path: directory path | ||
:type path: str | ||
:return: True, if action succeed, otherwise False | ||
:rtype: bool | ||
""" | ||
return self.host.run_command( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note that host.run_command will be removed, read #24 . |
||
['mkdir', path] | ||
)[0] == 0 | ||
|
||
def chown(self, path, username, groupname): | ||
""" | ||
Change owner of file or directory | ||
|
||
:param path: file or directory path | ||
:type path: str | ||
:param username: change user owner to username | ||
:type username: str | ||
:param groupname: change group owner to groupname | ||
:type groupname: str | ||
:return: True, if action succeed, otherwise False | ||
:rtype: bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
""" | ||
return self.host.run_command( | ||
['chown', '%s:%s' % (username, groupname), path] | ||
)[0] == 0 | ||
|
||
def chmod(self, path, mode): | ||
""" | ||
Change permission of directory or file | ||
|
||
:param path: file or directory path | ||
:type path: str | ||
:param mode: permission mode(600 for example or u+x) | ||
:type mode: str | ||
:return: True, if action succeed, otherwise False | ||
:rtype: bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks that you raise exception instead of bools. please update doc as well. |
||
""" | ||
return self.host.run_command( | ||
['chmod', mode, path] | ||
)[0] == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would raise exception, with all relevant info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see ':rtype: bool' but it doesn't return bool.