Skip to content

copy_file is not creating folders that part of the path on remote host nor raising exception #64

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

Closed
bexp opened this issue Sep 6, 2016 · 3 comments
Labels

Comments

@bexp
Copy link

bexp commented Sep 6, 2016

Hi, according to a doc copy_file should be able to create missing folder

Remote directories in remote_file that do not exist will be created as long as permissions allow.

I don't see this is happening. I used same credentials for python script as default ssh client
to verify I can create folder manually on remote.

this is output from the pssh:

Error occured copying file 1 to remote destination mysuperhost:/mnt/cache/purge_requests/1 - >[Errno 2] No such file

local file also exists, and copy_file succeeded with hosts which have remote folder already created.
would be nice to add some exception for that case.

This is the code I'm using right now:

    output = ssh_client.copy_file(src, dst)
    ssh_client.pool.join()
    for cmd in output:
        try:
            cmd_out = cmd.get()
            print 'upload result ', cmd.exception
        except (ConnectionErrorException, AuthenticationException,\
                UnknownHostException, SSHException ) as e:
            print("Unexpected error:{} in host {}".format(e,  e.args[1]))
            print "*** removing errorneous hostname from list ", e.args[1]
            ssh_client.hosts.remove(e.args[1])
        except Exception as e:
            print 'upload exception ', str(e)
            ssh_client.hosts.remove(e.args[1])
@pkittenis pkittenis added the bug label Sep 8, 2016
pkittenis pushed a commit that referenced this issue Sep 8, 2016
@pkittenis
Copy link
Member

pkittenis commented Sep 8, 2016

Indeed, this is a bug with multiple directories in target remote_file. Weirdly enough, there is a test for exactly this - not a good one obviously :)

The branch referenced above contains a fix, feel free to install if this is a blocker for you, though not releasing before fixing tests.

It should also be raising exception on permission errors, yes, that will be in next point release at it's an API change.

@bexp
Copy link
Author

bexp commented Sep 8, 2016

thanks for quick fix in branch. I will wait for release .

@pkittenis
Copy link
Member

0.92.2 contains this fix. Exception on permissions errors will be in a new release as it's API change, can watch #65 for that.

Thanks again for raising 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants