Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
baasgeo committed Jul 31, 2017
2 parents f84ea49 + 10e69de commit 99b04e5
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 83 deletions.
36 changes: 18 additions & 18 deletions SetupMapProxy.nsi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014 Baas geo-information
* Copyright (c) 2014-2017 Baas geo-information
*
* MapProxy Windows installer creation file.
*
Expand All @@ -21,10 +21,10 @@
; Define your application name
!define APPNAME "MapProxy"
!define COMPANY "Baas geo-information"
!define VERSION 1.8.0
!define VERSION 1.10.0
!define SEQ 0
!define APPNAMEANDVERSION "${APPNAME} ${VERSION}"
!define GITPAGE "http://github.com/bartbaas/mapproxywindows"
!define GITPAGE "http://baasgeo.github.io/mapproxywindows/"
!define SETTINGSREGPATH "Software\Baasgeo\${APPNAME}"
!define UNINSTALLREGPATH "Software\Microsoft\Windows\CurrentVersion\Uninstall"

Expand Down Expand Up @@ -92,18 +92,6 @@ VIAddVersionKey CompanyName "${COMPANY}"
VIAddVersionKey LegalCopyright "${COMPANY}"
VIAddVersionKey Comments "${GITPAGE}"

; Install options page headers
LangString TEXT_DATADIR_TITLE ${LANG_ENGLISH} "${APPNAME} Data Directory"
LangString TEXT_DATADIR_SUBTITLE ${LANG_ENGLISH} "${APPNAME} Data Directory path selection"
LangString TEXT_TYPE_TITLE ${LANG_ENGLISH} "Type of Installation"
LangString TEXT_TYPE_SUBTITLE ${LANG_ENGLISH} "Select the type of installation"
LangString TEXT_READY_TITLE ${LANG_ENGLISH} "Ready to Install"
LangString TEXT_READY_SUBTITLE ${LANG_ENGLISH} "${APPNAME} is ready to be installed"
LangString TEXT_CREDS_TITLE ${LANG_ENGLISH} "${APPNAME} Administrator"
LangString TEXT_CREDS_SUBTITLE ${LANG_ENGLISH} "Set administrator credentials"
LangString TEXT_PORT_TITLE ${LANG_ENGLISH} "${APPNAME} Web Server Port"
LangString TEXT_PORT_SUBTITLE ${LANG_ENGLISH} "Set the port that ${APPNAME} will respond on"

; Interface Settings
!define MUI_ICON "mapproxy.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico"
Expand All @@ -121,7 +109,7 @@ LangString TEXT_PORT_SUBTITLE ${LANG_ENGLISH} "Set the port that ${APPNAME} will
!define MUI_ABORTWARNING

; Optional text settings here
!define MUI_FINISHPAGE_LINK " Installer created and maintained by B. Baas $\n ${GITPAGE}"
!define MUI_FINISHPAGE_LINK " Installer created and maintained by Baas geo-information $\n ${GITPAGE}"
!define MUI_FINISHPAGE_LINK_LOCATION "${GITPAGE}"
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of ${APPNAMEANDVERSION}. \r\n\r\n\
It is recommended that you close all other applications before starting Setup.\
Expand Down Expand Up @@ -152,6 +140,18 @@ Page custom Ready ; Summary page
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL

; Install options page headers
LangString TEXT_DATADIR_TITLE ${LANG_ENGLISH} "${APPNAME} Data Directory"
LangString TEXT_DATADIR_SUBTITLE ${LANG_ENGLISH} "${APPNAME} Data Directory path selection"
LangString TEXT_TYPE_TITLE ${LANG_ENGLISH} "Type of Installation"
LangString TEXT_TYPE_SUBTITLE ${LANG_ENGLISH} "Select the type of installation"
LangString TEXT_READY_TITLE ${LANG_ENGLISH} "Ready to Install"
LangString TEXT_READY_SUBTITLE ${LANG_ENGLISH} "${APPNAME} is ready to be installed"
LangString TEXT_CREDS_TITLE ${LANG_ENGLISH} "${APPNAME} Administrator"
LangString TEXT_CREDS_SUBTITLE ${LANG_ENGLISH} "Set administrator credentials"
LangString TEXT_PORT_TITLE ${LANG_ENGLISH} "${APPNAME} Web Server Port"
LangString TEXT_PORT_SUBTITLE ${LANG_ENGLISH} "Set the port that ${APPNAME} will respond on"

; Check the user type, and quit if it's not an administrator.
; Taken from Examples/UserInfo that ships with NSIS.
Function CheckUserType
Expand Down Expand Up @@ -524,7 +524,7 @@ Section "Main" SectionMain
File /r PortablePython\App

; Install mapproxy
nsExec::ExecToLog '"$INSTDIR\App\Scripts\easy_install.exe" -f "eggs" mapproxy==${VERSION} Shapely==1.2.17 pyproj==1.9.3 cherrypy==3.7.0'
nsExec::ExecToLog '"$INSTDIR\App\Scripts\easy_install.exe" -f "eggs" mapproxy==${VERSION} Shapely==1.2.17 pyproj==1.9.3 Pillow==4.2.1 cherrypy==3.8.2'
nsExec::ExecToLog '"$INSTDIR\App\Scripts\mapproxy-util.exe" --version'
${If} $IsExisting == 1
Detailprint "Using existing data directory: $\r$\n$DataDir"
Expand Down Expand Up @@ -567,7 +567,7 @@ Section -FinishSection
SetShellVarContext all
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${APPNAME} Homepage.lnk" "http://mapproxy.org"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${APPNAME} Installer.lnk" "http://bartbaas.github.io/MapProxyWindows/"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${APPNAME} Installer.lnk" "https://baasgeo.github.io/mapproxywindows/"

${ConfigWrite} "$INSTDIR\open_admin.py" "subkey=" "r'${SETTINGSREGPATH}\${VERSION}'" $R0
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${APPNAME} Web Admin Page.lnk" \
Expand Down
146 changes: 81 additions & 65 deletions mapproxy_srv.py
Original file line number Diff line number Diff line change
@@ -1,66 +1,82 @@
"""
The most basic (working) CherryPy 3.2 WSGI Windows service possible.
Requires Mark Hammond's pywin32 package.
Taken from here: http://tools.cherrypy.org/wiki/WindowsService and modified.
License and copyright unknown. No licence or warranty claimed on my behalf.
Inquire with source mentioned above regarding either.
To see a list of options for installing, removing, starting, and stopping your service.
python this_file.py
To install your new service type:
python this_file.py install
Then type:
python this_file.py start
If you get "Access Denied" you need to be admin to install, remove, start, stop.
( To run cmd as admin: Windows Key > "cmd" > CTRL+SHIFT+ENTER )
"""
import pywintypes, pythoncom, win32api, win32serviceutil, win32service
from logging.config import fileConfig
import os.path
import sys
from cherrypy import wsgiserver
from mapproxy.wsgiapp import make_wsgi_app
if sys.hexversion > 0x03000000:
import winreg
else:
import _winreg as winreg

# globals
version='1.0.0'
rootkey=winreg.HKEY_LOCAL_MACHINE
subkey=r'SOFTWARE\COMPANY\APP\NUM'
server_ip='0.0.0.0'

class MyService(win32serviceutil.ServiceFramework):
"""NT Service."""

_svc_name_ = 'MapProxy-' + version
_svc_display_name_ = 'MapProxy ' + version
_svc_description_ = 'This service runs the MapProxy tile server'

def SvcDoRun(self):
key=winreg.OpenKey(rootkey, subkey, 0, winreg.KEY_READ)
port_to_bind=int(winreg.QueryValueEx(key, 'Port')[0])
data_dir=str(winreg.QueryValueEx(key, 'DataDir')[0])
app_config=data_dir + r'\mapproxy.yaml'
log_conf=data_dir + r'\log.ini'

fileConfig(log_conf, {'here': data_dir})
application=make_wsgi_app(app_config)
d=wsgiserver.WSGIPathInfoDispatcher({'/mapproxy': application})
self.server=wsgiserver.CherryPyWSGIServer( (server_ip, port_to_bind), d, numthreads=10, server_name=None, max=-1, request_queue_size=2048, timeout=10, shutdown_timeout=5)
self.server.start()

def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
if self.server:
self.server.stop()

self.ReportServiceStatus(win32service.SERVICE_STOPPED)
# very important for use with py2exe
# otherwise the Service Controller never knows that it is stopped !

if __name__ == '__main__':
"""
The most basic (working) CherryPy 3.2 WSGI Windows service possible.
Requires Mark Hammond's pywin32 package.
Taken from here: http://tools.cherrypy.org/wiki/WindowsService and modified.
License and copyright unknown. No licence or warranty claimed on my behalf.
Inquire with source mentioned above regarding either.
To see a list of options for installing, removing, starting, and stopping your service.
python this_file.py
To install your new service type:
python this_file.py install
Then type:
python this_file.py start
If you get "Access Denied" you need to be admin to install, remove, start, stop.
( To run cmd as admin: Windows Key > "cmd" > CTRL+SHIFT+ENTER )
"""
import pywintypes, pythoncom, win32api, win32serviceutil, win32service
from logging.config import fileConfig
import os.path
import sys
import cherrypy
from cherrypy import wsgiserver
from mapproxy.wsgiapp import make_wsgi_app
if sys.hexversion > 0x03000000:
import winreg
else:
import _winreg as winreg

# globals
version='1.0.0'
rootkey=winreg.HKEY_LOCAL_MACHINE
subkey=r'SOFTWARE\COMPANY\APP\NUM'
server_ip='0.0.0.0'

class MyService(win32serviceutil.ServiceFramework):
"""NT Service."""

_svc_name_ = 'MapProxy-' + version
_svc_display_name_ = 'MapProxy ' + version
_svc_description_ = 'This service runs the MapProxy tile server'

def SvcDoRun(self):
key=winreg.OpenKey(rootkey, subkey, 0, winreg.KEY_READ)
port_to_bind=int(winreg.QueryValueEx(key, 'Port')[0])
data_dir=str(winreg.QueryValueEx(key, 'DataDir')[0])
app_config=data_dir + r'\mapproxy.yaml'
log_conf=data_dir + r'\log.ini'

cherrypy.config.update({
'global':{
'log.screen': False,
'tools.log_tracebacks.on': True,
'engine.autoreload.on': False,
'engine.SIGHUP': None,
'engine.SIGTERM': None
}
})

fileConfig(log_conf, {'here': data_dir})
application=make_wsgi_app(app_config)
d=wsgiserver.WSGIPathInfoDispatcher({'/mapproxy': application})
self.server=wsgiserver.CherryPyWSGIServer( (server_ip, port_to_bind), d, numthreads=10, server_name=None, max=-1, request_queue_size=2048, timeout=10, shutdown_timeout=5)
# Infinite loop serving requests
try:
self.server.start()
except Exception as e:
# Log an error event
servicemanager.LogErrorMsg("MapProxy failed to start:\n%s" % e)

def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
if self.server:
self.server.stop()

self.ReportServiceStatus(win32service.SERVICE_STOPPED)
# very important for use with py2exe
# otherwise the Service Controller never knows that it is stopped !

if __name__ == '__main__':
win32serviceutil.HandleCommandLine(MyService)

0 comments on commit 99b04e5

Please sign in to comment.