Skip to content

Commit ace2767

Browse files
author
Yakov Gnusin
committed
Few fixes and PowerShell deployment script.
1 parent 658fccf commit ace2767

File tree

7 files changed

+58
-4
lines changed

7 files changed

+58
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
venv/
44
bin/
55
obj/
6+
deployment/
67
*.pyc

terminalTwitter/deploy.ps1

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[string]$gitRepo
4+
)
5+
6+
$deploymentDir = "deployment"
7+
$terminalDir = "terminalTwitter"
8+
$sdkDirName = "fr8"
9+
$sdkDir = "../$sdkDirName"
10+
11+
If (Test-Path $deploymentDir){
12+
Write-Host "Removing old $deploymentDir folder"
13+
Remove-Item $deploymentDir -Force -Recurse
14+
}
15+
16+
Write-Host "Creating blank $deploymentDir folder"
17+
New-Item -ItemType Directory -Force -Path $deploymentDir | Out-Null
18+
19+
Write-Host "Extracting current Azure repo"
20+
cd $deploymentDir
21+
git init
22+
git remote add azure $gitRepo
23+
git fetch azure
24+
git checkout master
25+
cd ..
26+
27+
Write-Host "Remove previous deployment"
28+
Remove-Item "$deploymentDir\*" -Recurse
29+
30+
Write-Host "Creating terminal package"
31+
Copy-Item "web.2.7.config" -Destination "$deploymentDir\web.config" -Force
32+
Copy-Item "runtime.txt" -Destination $deploymentDir -Force
33+
Copy-Item "requirements.txt" -Destination $deploymentDir -Force
34+
Copy-Item "ptvs_virtualenv_proxy.py" -Destination $deploymentDir -Force
35+
Copy-Item "runserver.py" -Destination $deploymentDir -Force
36+
Copy-Item $terminalDir -Destination $deploymentDir -Force -Recurse
37+
Remove-Item "$deploymentDir\$terminalDir\*.pyc" -Recurse
38+
39+
Write-Host "Creating SDK package for the terminal"
40+
Copy-Item $sdkDir -Destination $deploymentDir -Force -Recurse
41+
Remove-Item "$deploymentDir\$sdkDirName\*.pyc" -Recurse
42+
Remove-Item "$deploymentDir\$sdkDirName\*.pyproj" -Recurse
43+
44+
Write-Host "Publishing to Azure Git repo"
45+
cd $deploymentDir
46+
git add .
47+
git commit -m "Deployment commit"
48+
git push azure master
49+
50+
cd ..

terminalTwitter/terminalTwitter.pyproj

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<Folder Include="terminalTwitter\" />
4545
</ItemGroup>
4646
<ItemGroup>
47+
<Content Include="deploy.ps1" />
4748
<Content Include="requirements.txt" />
4849
<Content Include="runtime.txt" />
4950
</ItemGroup>

terminalTwitter/terminalTwitter/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# Flask app instance.
1212
app = Flask(__name__)
1313

14+
1415
# Terminal request handler.
1516
handler = fr8.terminal.TerminalHandler(
1617
terminal.terminal,

terminalTwitter/terminalTwitter/terminal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import fr8.data
23

34
twitter_consumer_key = 'j0CGin9tvfWEe5UrxsCcjC6fT'
@@ -7,8 +8,7 @@
78
web_service = fr8.data.WebServiceDTO(name='Twitter', icon_path='/Content/icons/web_services/twitter-icon-64x64.png')
89

910
terminal_id = 'B9CC8E6D-69B0-4E41-BCBC-251F25E10E75'
10-
terminal_port = 38080
11-
terminal_endpoint = 'http://127.0.0.1:' + str(terminal_port)
11+
terminal_endpoint = os.environ.get('TERMINAL_URL', 'http://127.0.0.1:38080')
1212

1313
terminal = fr8.data.TerminalDTO(
1414
id = terminal_id,

terminalTwitter/web.2.7.config

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
</trace>
1515
</system.diagnostics>
1616
<appSettings>
17-
<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="terminalTwitter.app" />
17+
<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="terminalTwitter.main.app" />
1818
<add key="WSGI_ALT_VIRTUALENV_ACTIVATE_THIS" value="D:\home\site\wwwroot\env\Scripts\activate_this.py" />
1919
<add key="WSGI_HANDLER" value="ptvs_virtualenv_proxy.get_virtualenv_handler()" />
2020
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
21+
<add key="TERMINAL_URL" value="http://fr8-terminal-twitter.azurewebsites.net" />
2122
<!--
2223
Uncomment the following key/value to enable remote debugging.
2324
The following setting is meant to protect the debugging endpoint against

terminalTwitter/web.debug.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
88
<appSettings>
99
<!-- The following setting is meant to protect the debugging endpoint against inadvertent access, and should be treated as a password. -->
10-
<add key="WSGI_PTVSD_SECRET" value="eu3kownfzt3" xdt:Transform="Insert" />
10+
<add key="WSGI_PTVSD_SECRET" value="bkko31rrod2" xdt:Transform="Insert" />
1111
</appSettings>
1212
<system.web>
1313
<!-- Required for websockets. -->

0 commit comments

Comments
 (0)