Last active
August 29, 2015 14:15
-
-
Save mdiener21/76f62092afc993f9eca5 to your computer and use it in GitHub Desktop.
Django deploy script on windows server IIS 8 when you are logged on
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
import os | |
import shutil | |
import distutils | |
import subprocess | |
base_source_path = r"E:\WEBGIS\source\trunk\mysite" # svn source location | |
base_deploy_path = r"C:\inetpub\mysite" | |
source_dir3 = r"C:\Python27\Lib\site-packages\django_admin_bootstrapped\static\admin" | |
destination_dir3 = r"C:\inetpub\mysite\static\admin" | |
source_dir4 = r"C:\Python27\Lib\site-packages\django_admin_bootstrapped\static\bootstrap" | |
destination_dir4 = r"C:\inetpub\mysite\bootstrap" | |
folder_list = ['django_proj', 'app1', 'app2', 'app3'] | |
file_list = ['manage.py', 'wfastcgi.py'] | |
def copy_dir(source, destination): | |
if os.path.exists(destination): | |
shutil.rmtree(destination) | |
shutil.copytree(source, destination) | |
def copy_file(src, dest): | |
if os.path.isfile(dest): | |
os.remove(dest) | |
shutil.copyfile(src, dest) | |
for folder in folder_list: | |
in_path = os.path.join(base_source_path, folder) | |
out_path = os.path.join(base_deploy_path, folder) | |
copy_dir(in_path, out_path) | |
print in_path | |
print out_path | |
for file in file_list: | |
in_path = os.path.join(base_source_path, file) | |
out_path = os.path.join(base_deploy_path, file) | |
copy_file(in_path, out_path) | |
print "now copying files: " + str(file) | |
print """ !!!!!!!! | |
NOW go to IIS and REMOVE the Django Handler | |
by click folder STATIC delete Django handler | |
!!!!!!!! | |
""" | |
def py_xcopy(src, dst): | |
""" | |
copy over an existing folder and files | |
""" | |
for root, dirs, files in os.walk(src): | |
dst_dir = root.replace(src, dst) | |
if not os.path.exists(dst_dir): | |
os.mkdir(dst_dir) | |
for file_ in files: | |
src_file = os.path.join(root, file_) | |
dst_file = os.path.join(dst_dir, file_) | |
if os.path.exists(dst_file): | |
os.remove(dst_file) | |
shutil.copy(src_file, dst_dir) | |
py_xcopy(source_dir3, destination_dir3) | |
py_xcopy(source_dir4, destination_dir4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this script when logged on on Windows IIS server to deploy django project from a subversion repo on the server to the live IIS location in inetpub. Also copies over the django-admin-bootstrapped static files needed for the admin. (NOTE using django standard manage.py collectstatic could also be used instead of copying django-admin-bootstrapped static files over 😄