Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/python
import argparse
import json
import sys
import distutils.util
import os
import pysftp # http://pysftp.readthedocs.io/en/release_0.2.8/cookbook.html#pysftp-connection
# First, install run 'pip install pysftp''
# Define sFTP credentials:
sftp = pysftp.Connection('domain.com', username='xx', password='xx')
# set remote directory. (Must exist)
sftpDir = 'wp-content/uploads/hypeanimations/'
public_html_url = 'http://tumulttest.nfshost.com' + '/' + sftpDir + '/'
HypedocumentName = 'index.html'
# Show where in the FTP directory you are.
print sftp.pwd
# todo check if you can get into sftpDIR, then run sftp.mkdir(sftpDir, mode=644) if you cannot.
sftp.put_r('toupload', sftpDir, preserve_mtime=True)
print 'Upload done.'
print os.getcwd()
# Single File.
# sftp.put('file.png', preserve_mtime=True)
sftp.close()
print 'Connection closed. Your URL is ' + public_html_url + HypedocumentName
#webbrowser.open_new_tab(public_html_url + HypedocumentName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.