facilitate testing on localhost for CloudStorage
parent
5fd93237c5
commit
b81bf41015
|
@ -12,7 +12,7 @@ server.socket_queue_size: 10
|
||||||
server.thread_pool: 20
|
server.thread_pool: 20
|
||||||
server.thread_pool_max: 20
|
server.thread_pool_max: 20
|
||||||
|
|
||||||
# change host params in .autocat3 or /etc/autocat3.conf files
|
# change host and postgres params in .autocat3 or /etc/autocat3.conf files
|
||||||
pghost: 'localhost'
|
pghost: 'localhost'
|
||||||
pgport: 5432
|
pgport: 5432
|
||||||
pgdatabase: 'gutenberg'
|
pgdatabase: 'gutenberg'
|
||||||
|
@ -20,6 +20,7 @@ pguser: 'postgres'
|
||||||
|
|
||||||
host: 'www.gutenberg.org'
|
host: 'www.gutenberg.org'
|
||||||
host_mobile: 'm.gutenberg.org'
|
host_mobile: 'm.gutenberg.org'
|
||||||
|
host_https: 1
|
||||||
file_host: 'www.gutenberg.org'
|
file_host: 'www.gutenberg.org'
|
||||||
|
|
||||||
sqlalchemy.pool_size: 20
|
sqlalchemy.pool_size: 20
|
||||||
|
@ -72,8 +73,8 @@ tools.sessions.on: True
|
||||||
tools.sessions.table_name = "cherrypy.sessions"
|
tools.sessions.table_name = "cherrypy.sessions"
|
||||||
tools.sessions.timeout: 30
|
tools.sessions.timeout: 30
|
||||||
tools.sessions.path: '/'
|
tools.sessions.path: '/'
|
||||||
# change host in .autocat3 or /etc/autocat3.conf files
|
|
||||||
tools.sessions.domain: 'gutenberg.org'
|
tools.sessions.domain: 'gutenberg.org'
|
||||||
|
#tools.sessions.domain: 'localhost'
|
||||||
|
|
||||||
tools.expires.on: True
|
tools.expires.on: True
|
||||||
tools.expires.secs: 0
|
tools.expires.secs: 0
|
||||||
|
@ -81,4 +82,8 @@ tools.expires.force: True
|
||||||
|
|
||||||
[/index.html]
|
[/index.html]
|
||||||
tools.staticfile.on: True
|
tools.staticfile.on: True
|
||||||
tools.staticfile.filename: CherryPyApp.install_dir + '/templates/index.html'
|
tools.staticfile.filename: CherryPyApp.install_dir + '/test/index.html'
|
||||||
|
|
||||||
|
[/test.pdf]
|
||||||
|
tools.staticfile.on: True
|
||||||
|
tools.staticfile.filename: CherryPyApp.install_dir + '/test/test.pdf'
|
||||||
|
|
|
@ -54,10 +54,7 @@ plugins.Timer = Timer.TimerPlugin
|
||||||
install_dir = os.path.dirname (os.path.abspath (__file__))
|
install_dir = os.path.dirname (os.path.abspath (__file__))
|
||||||
|
|
||||||
CHERRYPY_CONFIG = os.path.join(install_dir, 'CherryPy.conf')
|
CHERRYPY_CONFIG = os.path.join(install_dir, 'CherryPy.conf')
|
||||||
LOCAL_CONFIG = (
|
LOCAL_CONFIG = [os.path.expanduser('~/.autocat3'), '/etc/autocat3.conf']
|
||||||
os.path.join(install_dir, 'CherryPy.conf'),
|
|
||||||
os.path.expanduser('~/.autocat3'), '/etc/autocat3.conf'
|
|
||||||
)
|
|
||||||
|
|
||||||
class MyRoutesDispatcher (cherrypy.dispatch.RoutesDispatcher):
|
class MyRoutesDispatcher (cherrypy.dispatch.RoutesDispatcher):
|
||||||
""" Dispatcher that tells us the matched route.
|
""" Dispatcher that tells us the matched route.
|
||||||
|
@ -92,13 +89,6 @@ def main ():
|
||||||
|
|
||||||
config_filename = None
|
config_filename = None
|
||||||
cherrypy.config.update (CHERRYPY_CONFIG)
|
cherrypy.config.update (CHERRYPY_CONFIG)
|
||||||
for config_filename in LOCAL_CONFIG:
|
|
||||||
try:
|
|
||||||
cherrypy.config.update (config_filename)
|
|
||||||
break
|
|
||||||
except IOError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Rotating Logs
|
# Rotating Logs
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -122,6 +112,8 @@ def main ():
|
||||||
h.setFormatter (cherrypy._cplogging.logfmt)
|
h.setFormatter (cherrypy._cplogging.logfmt)
|
||||||
cherrypy.log.access_log.addHandler (h)
|
cherrypy.log.access_log.addHandler (h)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not cherrypy.config['daemonize']:
|
if not cherrypy.config['daemonize']:
|
||||||
ch = logging.StreamHandler ()
|
ch = logging.StreamHandler ()
|
||||||
ch.setLevel (logging.DEBUG)
|
ch.setLevel (logging.DEBUG)
|
||||||
|
@ -132,8 +124,15 @@ def main ():
|
||||||
#
|
#
|
||||||
|
|
||||||
cherrypy.log ('*' * 80, context = 'ENGINE', severity = logging.INFO)
|
cherrypy.log ('*' * 80, context = 'ENGINE', severity = logging.INFO)
|
||||||
cherrypy.log ("Using config file '%s'." % config_filename,
|
cherrypy.log ("Using config file '%s'." % CHERRYPY_CONFIG,
|
||||||
context = 'ENGINE', severity = logging.INFO)
|
context = 'ENGINE', severity = logging.INFO)
|
||||||
|
for config_filename in LOCAL_CONFIG:
|
||||||
|
try:
|
||||||
|
cherrypy.config.update (config_filename)
|
||||||
|
cherrypy.log ('loaded %s' % config_filename, context = 'ENGINE', severity = logging.INFO)
|
||||||
|
break
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
|
||||||
# after cherrypy.config is parsed
|
# after cherrypy.config is parsed
|
||||||
Formatters.init ()
|
Formatters.init ()
|
||||||
|
@ -308,7 +307,7 @@ def main ():
|
||||||
|
|
||||||
cherrypy.log ("Mounting root", context = 'ENGINE', severity = logging.INFO)
|
cherrypy.log ("Mounting root", context = 'ENGINE', severity = logging.INFO)
|
||||||
|
|
||||||
app = cherrypy.tree.mount (root = None, config = config_filename)
|
app = cherrypy.tree.mount (root = None, config = CHERRYPY_CONFIG)
|
||||||
|
|
||||||
app.merge ({'/': {'request.dispatch': d}})
|
app.merge ({'/': {'request.dispatch': d}})
|
||||||
return app
|
return app
|
||||||
|
|
|
@ -65,9 +65,10 @@ class CloudOAuth2Session (requests_oauthlib.OAuth2Session): # pylint: disable=R0
|
||||||
prefix = self.name_prefix
|
prefix = self.name_prefix
|
||||||
|
|
||||||
host = config['file_host']
|
host = config['file_host']
|
||||||
|
host_https = config['host_https']
|
||||||
urlgen = routes.URLGenerator (cherrypy.routes_mapper, {
|
urlgen = routes.URLGenerator (cherrypy.routes_mapper, {
|
||||||
'HTTP_HOST': host,
|
'HTTP_HOST': host,
|
||||||
'HTTPS': 1
|
'HTTPS': host_https
|
||||||
})
|
})
|
||||||
|
|
||||||
client_id = config[prefix + '_client_id']
|
client_id = config[prefix + '_client_id']
|
||||||
|
@ -297,7 +298,11 @@ class EbookMetaData (object):
|
||||||
|
|
||||||
def get_source_url (self):
|
def get_source_url (self):
|
||||||
""" Return the url of the ebook file on gutenberg.org. """
|
""" Return the url of the ebook file on gutenberg.org. """
|
||||||
|
protocol = 'https://' if cherrypy.config['host_https'] else 'http://'
|
||||||
|
if self.id == 99999:
|
||||||
|
# test filename
|
||||||
|
return urllib.parse.urljoin (
|
||||||
|
protocol + str(cherrypy.config['file_host']) , 'test.pdf')
|
||||||
return urllib.parse.urljoin (
|
return urllib.parse.urljoin (
|
||||||
'https://' + cherrypy.config['file_host'],
|
protocol + cherrypy.config['file_host'],
|
||||||
'ebooks/%d.%s' % (self.id, self.filetype))
|
'ebooks/%d.%s' % (self.id, self.filetype))
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<link rel="stylesheet" type="text/css" href="https://www.gutenberg.org/css/pg-desktop-one.css" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="body">
|
|
||||||
<p><a href="/ebooks/downloadtest.pdf">Download Test</a></p>
|
|
||||||
<p>
|
|
||||||
<a href="/ebooks/send/dropbox/test.pdf" title="Send to Dropbox." rel="nofollow"><span class="icon icon_dropbox">Dropbox</span></a>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<a href="/ebooks/send/gdrive/test.pdf" title="Send to Google Drive." rel="nofollow"><span class="icon icon_gdrive">Google Drive</span></a>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<a href="/ebooks/send/msdrive/test.pdf" title="Send to OneDrive." rel="nofollow"><span class="icon icon_msdrive">OneDrive</span></a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://www.gutenberg.org/css/pg-desktop-one.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="body">
|
||||||
|
<p><a href="/test.pdf">Download Test</a></p>
|
||||||
|
<p>
|
||||||
|
<a href="/ebooks/send/dropbox/99999.pdf" title="Send to Dropbox." rel="nofollow"><span class="icon icon_dropbox">Dropbox</span></a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a href="/ebooks/send/gdrive/99999.pdf" title="Send to Google Drive." rel="nofollow"><span class="icon icon_gdrive">Google Drive</span></a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a href="/ebooks/send/msdrive/99999.pdf" title="Send to OneDrive." rel="nofollow"><span class="icon icon_msdrive">OneDrive</span></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Binary file not shown.
Loading…
Reference in New Issue