Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import argparse
import json
import sys
import distutils.util
import os
import pysftp #
# First, install run 'pip install pysftp''
# Define sFTP credentials:
sftp = pysftp.Connection('', username='xx', password='xx')
# set remote directory. (Must exist)
sftpDir = 'wp-content/uploads/hypeanimations/'
public_html_url = '' + '/' + 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)
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.