Created
January 5, 2018 00:47
-
-
Save themorgantown/0450186f556368d12f2016b0d0993f34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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