Permalink
Browse files

initial

  • Loading branch information...
0 parents commit 98c1e2b4332a70ad1cfdf9e3e9870166a4a408ab @michiya committed Feb 21, 2012
@@ -0,0 +1,5 @@
+*.cspkg
+*.csx
+*.log
+*.pyc
+*.pyo
@@ -0,0 +1,42 @@
+heliconzoo-django-role
+======================
+This is a simple scaffold powered by [Helicon Zoo](http://www.helicontech.com/zoo/)
+for packaging Django applications to run on Windows Azure and SQL Azure.
+
+Prerequisites
+-------------
+
+You will need to install the following software on your local computer.
+You can use [Web Platform Installer](http://www.microsoft.com/web/downloads/platform.aspx)
+to install them easily.
+
+* Windows Azure SDK
+* Python 2.7
+* Helicon Zoo Module
+* SQL Server Express 2008 R2
+
+And the following Python packages are also required on your Python installation,
+the script `WebRole/bin/install-requirements.cmd` in this scaffold may be helpful
+when you install them.
+
+* Django
+* [pyodbc](http://code.google.com/p/pyodbc/)
+* [django-pyodbc](http://code.google.com/p/django-pyodbc/)
+
+Usage
+-----
+
+1. Create your Django applications into `WebRole/project` directory,
+and add any other Python packages you use to `WebRole/requirements.txt`.
+
+2. Turn IIS feature on and run `run.cmd` on your Windows Azure Command Prompt
+to run the application on your local emulator.
+
+3. Run `pack.cmd` on your Windows Azure Command Prompt to output `heliconzoo-django-role.cspkg`.
+That file, along with `ServiceConfiguration.Cloud.cscfg` is what you need to deploy
+via the Windows Azure portal (or with some other tool) to get the applications running in the cloud.
+
+License
+-------
+
+Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ServiceConfiguration serviceName="heliconzoo-django-role" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*">
+ <Role name="WebRole">
+ <Instances count="1" />
+ <ConfigurationSettings>
+ </ConfigurationSettings>
+ </Role>
+</ServiceConfiguration>
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ServiceConfiguration serviceName="heliconzoo-django-role" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*">
+ <Role name="WebRole">
+ <Instances count="1" />
+ <ConfigurationSettings>
+ </ConfigurationSettings>
+ </Role>
+</ServiceConfiguration>
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ServiceDefinition name="heliconzoo-django-role" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
+ <WebRole name="WebRole" enableNativeCodeExecution="true">
+ <Sites>
+ <Site name="Web" physicalDirectory="./WebRole">
+ <Bindings>
+ <Binding name="Endpoint1" endpointName="HttpEndpoint" />
+ </Bindings>
+ </Site>
+ </Sites>
+ <Startup>
+ <Task commandLine="startup.cmd" executionContext="elevated" taskType="simple" >
+ <Environment>
+ <Variable name="EMULATED">
+ <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
+ </Variable>
+ <Variable name="LOCAL_RESOURCE_TMP_DIR">
+ <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[@name='tmp']/@path" />
+ </Variable>
+ </Environment>
+ </Task>
+ </Startup>
+ <Endpoints>
+ <InputEndpoint name="HttpEndpoint" protocol="http" port="80" />
+ </Endpoints>
+ <ConfigurationSettings>
+ </ConfigurationSettings>
+ <LocalResources>
+ <LocalStorage name="tmp" cleanOnRoleRecycle="true" sizeInMB="1000" />
+ </LocalResources>
+ </WebRole>
+</ServiceDefinition>
@@ -0,0 +1,70 @@
+@echo off
+
+echo Starting installation of requirements...
+
+REM Helicon Zoo requires Python to be there
+set PYTHON_INSTALL_DIR=%SystemDrive%\Python27
+
+REM test installation prerequisites
+if not exist %PYTHON_INSTALL_DIR%\python.exe (
+echo ERROR: %PYTHON_INSTALL_DIR%\python.exe is missing.
+exit /b 1
+)
+if not exist %SystemDrive%\Zoo (
+echo ERROR: %SystemDrive%\Zoo is missing.
+exit /b 1
+)
+
+if "%LOCAL_RESOURCE_TMP_DIR%"=="" set LOCAL_RESOURCE_TMP_DIR=%TMP%\
+echo temporary download directory is set to [%LOCAL_RESOURCE_TMP_DIR%]
+
+cd /d "%~dp0"
+
+%PYTHON_INSTALL_DIR%\python -c "import sys; print sys.version" | find "64 bit"
+set PYTHON_X86=%ERRORLEVEL%
+
+echo installing subversion...
+if exist %LOCAL_RESOURCE_TMP_DIR%svn-win32\bin\svn.exe goto INSTALL_SETUPTOOLS
+powershell -c "(new-object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/project/win32svn/1.7.2/svn-win32-1.7.2.zip', '%LOCAL_RESOURCE_TMP_DIR%svn-win32-1.7.2.zip')"
+%SystemDrive%\Zoo\Tools\7za x -o%LOCAL_RESOURCE_TMP_DIR% -y %LOCAL_RESOURCE_TMP_DIR%svn-win32-1.7.2.zip
+ren %LOCAL_RESOURCE_TMP_DIR%svn-win32-1.7.2 svn-win32
+
+:INSTALL_SETUPTOOLS
+echo installing setuptools...
+if exist %PYTHON_INSTALL_DIR%\Scripts\easy_install.exe goto INSTALL_PIP
+powershell -c "(new-object System.Net.WebClient).DownloadFile('http://peak.telecommunity.com/dist/ez_setup.py', '%LOCAL_RESOURCE_TMP_DIR%easy_setup.py')"
+%PYTHON_INSTALL_DIR%\python %LOCAL_RESOURCE_TMP_DIR%easy_setup.py
+
+:INSTALL_PIP
+echo installing pip...
+if exist %PYTHON_INSTALL_DIR%\Scripts\pip.exe goto INSTALL_PYODBC
+%PYTHON_INSTALL_DIR%\Scripts\easy_install pip
+
+:INSTALL_PYODBC
+echo installing pyodbc...
+%PYTHON_INSTALL_DIR%\python -c "import pyodbc" 2>nul
+if "%ERRORLEVEL%"=="0" goto INSTALL_DJANGO_PYODBC
+if "%PYTHON_X86%"=="0" goto INSTALL_PYODBC_X64
+%SystemDrive%\Python27\Scripts\easy_install -Z pyodbc==3.0.2
+goto INSTALL_DJANGO_PYODBC
+
+:INSTALL_PYODBC_X64
+powershell -c "(new-object System.Net.WebClient).DownloadFile('http://pyodbc.googlecode.com/files/pyodbc-3.0.2.win-amd64-py2.7.exe', '%LOCAL_RESOURCE_TMP_DIR%pyodbc.exe')"
+%SystemDrive%\Zoo\Tools\7za x -o%LOCAL_RESOURCE_TMP_DIR%pyodbc -y %LOCAL_RESOURCE_TMP_DIR%pyodbc.exe
+xcopy /e /h /y %LOCAL_RESOURCE_TMP_DIR%pyodbc\PLATLIB\* %PYTHON_INSTALL_DIR%\Lib\site-packages
+
+:INSTALL_DJANGO_PYODBC
+echo installing django-pyodbc...
+%PYTHON_INSTALL_DIR%\python -c "import sql_server.pyodbc" 2>nul
+if "%ERRORLEVEL%"=="0" goto INSTALL_REQUIREMENTS
+cd /d %LOCAL_RESOURCE_TMP_DIR%
+%LOCAL_RESOURCE_TMP_DIR%svn-win32\bin\svn checkout http://django-pyodbc.googlecode.com/svn/trunk/ django-pyodbc
+cd .\django-pyodbc
+%PYTHON_INSTALL_DIR%\python setup.py install
+cd /d "%~dp0"
+
+:INSTALL_REQUIREMENTS
+echo installing required packages...
+%SystemDrive%\Python27\Scripts\pip install --timeout=600 --default-timeout=600 -r ..\requirements.txt
+
+echo Completed installation of requirements.
@@ -0,0 +1,35 @@
+@echo off
+
+echo Starting installation...
+
+if not "%1"=="" set PYTHON_ARCH=.%1
+
+REM Helicon Zoo requires Python to be there
+set PYTHON_INSTALL_DIR=%SystemDrive%\Python27
+
+if "%LOCAL_RESOURCE_TMP_DIR%"=="" set LOCAL_RESOURCE_TMP_DIR=%TMP%\
+
+cd /d "%~dp0"
+
+md "%~dp0appdata"
+reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%~dp0appdata" /f
+
+echo installing Python...
+powershell -c "(new-object System.Net.WebClient).DownloadFile('http://www.python.org/ftp/python/2.7.2/python-2.7.2%PYTHON_ARCH%.msi', '%LOCAL_RESOURCE_TMP_DIR%python27.msi')"
+msiexec /i %LOCAL_RESOURCE_TMP_DIR%python27.msi /qn TARGET_DIR=%PYTHON_INSTALL_DIR%
+
+echo installing WebPICmdLine...
+powershell -c "(new-object System.Net.WebClient).DownloadFile('http://www.iis.net/community/files/webpi/webpicmdline_anycpu.zip', '%LOCAL_RESOURCE_TMP_DIR%webpicmdline.zip')"
+%PYTHON_INSTALL_DIR%\python -m zipfile -e %LOCAL_RESOURCE_TMP_DIR%webpicmdline.zip %LOCAL_RESOURCE_TMP_DIR%webpicmdline
+
+echo installing Helicon Zoo...
+%LOCAL_RESOURCE_TMP_DIR%webpicmdline\webpicmdline /Products:HeliconZooModule /Feeds:http://www.helicontech.com/zoo/feed/ /AcceptEula
+
+call "%~dp0"install-requirements
+
+REM allow write access to Python runtime for bytecode optimization by Helicon Zoo
+icacls %PYTHON_INSTALL_DIR% /grant "Everyone":F /T
+
+reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d %%USERPROFILE%%\AppData\Local /f
+
+echo Completed installation.
@@ -0,0 +1,12 @@
+@echo off
+
+cd "%~dp0"
+
+icacls %RoleRoot%\approot /grant "Everyone":F /T
+
+REM This script will only execute on production Windows Azure.
+if "%EMULATED%"=="true" goto :EOF
+
+REM run the command like this if you want to you use Python x64 instead
+REM install.cmd amd64 >..\startup-tasks.log 2>..\startup-tasks-error.log
+install.cmd >..\startup-tasks.log 2>..\startup-tasks-error.log
@@ -0,0 +1 @@
+this file is just a placeholder so the empty directory is not ignored by version control
No changes.
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+from django.core.management import execute_manager
+import imp
+try:
+ imp.find_module('settings') # Assumed to be in the same directory.
+except ImportError:
+ import sys
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
+ sys.exit(1)
+
+import settings
+
+if __name__ == "__main__":
+ execute_manager(settings)
Oops, something went wrong.

0 comments on commit 98c1e2b

Please sign in to comment.