-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add various shutil methods #16
Add various shutil methods #16
Conversation
f1cb8f3
to
ca2ec50
Compare
Awesome work thanks for doing this. I'm still working through some final stuff on the easy-api branch and once that is in I'll start the review on this so we can include it in the same release. |
@jborean93 all right, I will try to fix the build in the meantime. |
92c7d85
to
ba35490
Compare
Some parts still require tests and I am not sure how to handle Py2/3 compatibility for some of the error formattings. I'll add some more tests for the missing branches. |
Ah, this is actually a pytest bug when |
b527e7d
to
46a7a85
Compare
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.
Thanks again for working on this, things look pretty good and have added some comments inline.
smbclient/shutil.py
Outdated
else: | ||
raise ValueError("Target %s already exists" % norm_dst) | ||
|
||
with SMBRawIO(norm_src, mode='r', desired_access=FilePipePrinterAccessMask.GENERIC_READ, |
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.
it's simpler to just do with open_file(norm_src, mode='r', share_access='r', **kwargs)
and rely on that doing the conversion with the access mask and create options.
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.
After rebase, the test are failing, I'll have to find out why first.
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.
Some of the failures were my doing sorry, I renamed some kwargs to avoid the builtin names. One I know off the top of my head is that ioctl_request's
buffer
kwarg is now input_buffer
.
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.
Right, that was the issue!
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.
When changing to the suggested open_file
I get
> sid = self.raw.fd.tree_connect.session.session_id
E AttributeError: '_io.TextIOWrapper' object has no attribute 'fd'
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.
It sounds like you need to open it in binary mode. Typically you will want to set mode='<x>b
(the b is important) to make sure you are dealing with bytes. Internal functions should avoid using the text side unless they really need it.
Also, if you rebase the commit against easy-api I've removed Python 3.4 from the matrix as it is EOL and I've removed support for it. That should get CI green on Appveyor. |
1b5110f
to
84eb2cb
Compare
84eb2cb
to
109326f
Compare
I have cleaned up the code a bit, rmtree, copy and copytree_copy are in shutil, the server side implementation has been moved to _os. I still wasn't able to make the SMBRawIO replacement working. I will check out next week. |
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.
Nearly there, I'm still dubious about the source of the max chunk size part so I'm curious if you've got further evidence that state that's the max size for SMB2. (Edit: see #16 (comment))
@jborean93 , I hope I have addressed most issues. Two are still open I think:
|
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.
Looks great, thanks for sticking with this and making my job a whole lot easier :)
I'll have a look at both points once easy-api has been merged into the master branch before finalising the new release as well. |
@jborean93 thx, for all your comments and help. Lets get that one released and I would then work on copy2. |
@martinhoefling about those 2 remaining issues, here is the fix for the unicode chars in the exception dd1b5de. It wasn't an issue in pytest but rather how Python 2 handles native string compared to 3. In 2, a native string is actually a byte string and the default behaviour of converting a unicode string to byte is to encode it using the As for the SMBRawIO to open_file this was fixed in 39d82b7. Basically the SMBFileTransaction expects a SMBRawIO object and when you use open_file that can be encapsulated in a few different layers. In this case I am making sure I open the file in binary mode ( I'm hoping to expand on the tests a bit more before the end of the week and get a PR ready this weekend, early next week. From there I'll be using it for some further testing with downstream libraries and hopefully a full release soon after that. |
Thx! |
* Added higher level client API * Fixes after recent pull rebase * remove utils mention now we use conftest * Add default timeout to connection * try and reduce deadlocks in the msg queue processor * Fix deadlock issue and ensure tests are passing locally * Try and smooth out transport error handling * Fix up transport test after change * Dropped support for Python 3.4 * Added the ability to register and close a session in the pool * Fix up test and typos * More typos and minor nit changes * Set Impersonation as the default Impersonation level * Fix up listdir and read for pipes * Add various shutil methods (#16) * Add various shutil methods * reworked rmtree, review comments addressed * renamed copy2 -> copy and copytree -> copytree_copy, copying stats removed * service side copy moved to _os * fix pep8 indentation * review comments in shutil addressed * Fix up exceptions that can have unicode chars * Use open_file for copyfile * Move copyfile to top of file and add more tests * Use set size for SRV_REQUEST_RESUMT_KEY response output * Expand shutil and added more tests * Attempt to get Appveyor working again * Hopefully the last Appveyor fixes to go in * Should be last fix for appveyor * Last Appveyor fixes * Simplify stat and add ads tests * Remove ordereddict requirement
Added various methods like copy2, copytree etc. Also added a kwarg that allows to perform copying server side. Many methods are copied and adapted from their python2 shutil counterpart to mimic their behavior. Further, a set of integration tests that at least cover the happy paths was added. @jborean93 let me know what you think.