Commit 1b363ac7 authored by bodybybuddha's avatar bodybybuddha

Merged master into 617 - fixed import copy conflict

parents 9b1954f2 5a2ed58d
...@@ -123,9 +123,11 @@ def pdf_preview(tmp_file_path, tmp_dir): ...@@ -123,9 +123,11 @@ def pdf_preview(tmp_file_path, tmp_dir):
def get_versions(): def get_versions():
if not use_generic_pdf_cover: if not use_generic_pdf_cover:
IVersion=ImageVersion.MAGICK_VERSION IVersion = ImageVersion.MAGICK_VERSION
WVersion = ImageVersion.VERSION
else: else:
IVersion = _(u'not installed') IVersion = _(u'not installed')
WVersion = _(u'not installed')
if use_pdf_meta: if use_pdf_meta:
PVersion='v'+PyPdfVersion PVersion='v'+PyPdfVersion
else: else:
...@@ -134,4 +136,4 @@ def get_versions(): ...@@ -134,4 +136,4 @@ def get_versions():
XVersion = 'v'+'.'.join(map(str, lxmlversion)) XVersion = 'v'+'.'.join(map(str, lxmlversion))
else: else:
XVersion = _(u'not installed') XVersion = _(u'not installed')
return {'Image Magick': IVersion, 'PyPdf': PVersion, 'lxml':XVersion} return {'Image Magick': IVersion, 'PyPdf': PVersion, 'lxml':XVersion, 'Wand Version': WVersion}
...@@ -45,5 +45,5 @@ def versioncheck(): ...@@ -45,5 +45,5 @@ def versioncheck():
elif ub.config.config_ebookconverter == 2: elif ub.config.config_ebookconverter == 2:
return versionCalibre() return versionCalibre()
else: else:
return {'ebook_converter':''} return {'ebook_converter':_(u'not configured')}
...@@ -149,19 +149,19 @@ def getDrive(drive=None, gauth=None): ...@@ -149,19 +149,19 @@ def getDrive(drive=None, gauth=None):
drive.auth.Refresh() drive.auth.Refresh()
return drive return drive
def listRootFolders(drive=None): def listRootFolders():
drive = getDrive(drive) drive = getDrive(Gdrive.Instance().drive)
folder = "'root' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false" folder = "'root' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false"
fileList = drive.ListFile({'q': folder}).GetList() fileList = drive.ListFile({'q': folder}).GetList()
return fileList return fileList
def getEbooksFolder(drive=None): def getEbooksFolder(drive):
return getFolderInFolder('root',config.config_google_drive_folder,drive) return getFolderInFolder('root',config.config_google_drive_folder,drive)
def getFolderInFolder(parentId, folderName,drive=None): def getFolderInFolder(parentId, folderName, drive):
drive = getDrive(drive) # drive = getDrive(drive)
query="" query=""
if folderName: if folderName:
query = "title = '%s' and " % folderName.replace("'", "\\'") query = "title = '%s' and " % folderName.replace("'", "\\'")
...@@ -190,7 +190,6 @@ def getEbooksFolderId(drive=None): ...@@ -190,7 +190,6 @@ def getEbooksFolderId(drive=None):
def getFile(pathId, fileName, drive): def getFile(pathId, fileName, drive):
# drive = getDrive(Gdrive.Instance().drive)
metaDataFile = "'%s' in parents and trashed = false and title = '%s'" % (pathId, fileName.replace("'", "\\'")) metaDataFile = "'%s' in parents and trashed = false and title = '%s'" % (pathId, fileName.replace("'", "\\'"))
fileList = drive.ListFile({'q': metaDataFile}).GetList() fileList = drive.ListFile({'q': metaDataFile}).GetList()
...@@ -200,8 +199,8 @@ def getFile(pathId, fileName, drive): ...@@ -200,8 +199,8 @@ def getFile(pathId, fileName, drive):
return fileList[0] return fileList[0]
def getFolderId(path, drive=None): def getFolderId(path, drive):
drive = getDrive(drive) # drive = getDrive(drive)
currentFolderId = getEbooksFolderId(drive) currentFolderId = getEbooksFolderId(drive)
sqlCheckPath = path if path[-1] == '/' else path + '/' sqlCheckPath = path if path[-1] == '/' else path + '/'
storedPathName = session.query(GdriveId).filter(GdriveId.path == sqlCheckPath).first() storedPathName = session.query(GdriveId).filter(GdriveId.path == sqlCheckPath).first()
...@@ -249,7 +248,7 @@ def getFileFromEbooksFolder(path, fileName): ...@@ -249,7 +248,7 @@ def getFileFromEbooksFolder(path, fileName):
return None return None
def copyDriveFileRemote(drive, origin_file_id, copy_title): '''def copyDriveFileRemote(drive, origin_file_id, copy_title):
drive = getDrive(drive) drive = getDrive(drive)
copied_file = {'title': copy_title} copied_file = {'title': copy_title}
try: try:
...@@ -258,7 +257,7 @@ def copyDriveFileRemote(drive, origin_file_id, copy_title): ...@@ -258,7 +257,7 @@ def copyDriveFileRemote(drive, origin_file_id, copy_title):
return drive.CreateFile({'id': file_data['id']}) return drive.CreateFile({'id': file_data['id']})
except errors.HttpError as error: except errors.HttpError as error:
print ('An error occurred: %s' % error) print ('An error occurred: %s' % error)
return None return None'''
# Download metadata.db from gdrive # Download metadata.db from gdrive
...@@ -347,7 +346,6 @@ def uploadFileToEbooksFolder(destFile, f): ...@@ -347,7 +346,6 @@ def uploadFileToEbooksFolder(destFile, f):
def watchChange(drive, channel_id, channel_type, channel_address, def watchChange(drive, channel_id, channel_type, channel_address,
channel_token=None, expiration=None): channel_token=None, expiration=None):
# drive = getDrive(drive)
# Watch for all changes to a user's Drive. # Watch for all changes to a user's Drive.
# Args: # Args:
# service: Drive API service instance. # service: Drive API service instance.
...@@ -390,8 +388,6 @@ def watchFile(drive, file_id, channel_id, channel_type, channel_address, ...@@ -390,8 +388,6 @@ def watchFile(drive, file_id, channel_id, channel_type, channel_address,
Raises: Raises:
apiclient.errors.HttpError: if http request to create channel fails. apiclient.errors.HttpError: if http request to create channel fails.
""" """
# drive = getDrive(drive)
body = { body = {
'id': channel_id, 'id': channel_id,
'type': channel_type, 'type': channel_type,
...@@ -413,8 +409,6 @@ def stopChannel(drive, channel_id, resource_id): ...@@ -413,8 +409,6 @@ def stopChannel(drive, channel_id, resource_id):
Raises: Raises:
apiclient.errors.HttpError: if http request to create channel fails. apiclient.errors.HttpError: if http request to create channel fails.
""" """
# drive = getDrive(drive)
# service=drive.auth.service
body = { body = {
'id': channel_id, 'id': channel_id,
'resourceId': resource_id 'resourceId': resource_id
...@@ -423,7 +417,6 @@ def stopChannel(drive, channel_id, resource_id): ...@@ -423,7 +417,6 @@ def stopChannel(drive, channel_id, resource_id):
def getChangeById (drive, change_id): def getChangeById (drive, change_id):
# drive = getDrive(drive)
# Print a single Change resource information. # Print a single Change resource information.
# #
# Args: # Args:
...@@ -454,11 +447,13 @@ def updateDatabaseOnEdit(ID,newPath): ...@@ -454,11 +447,13 @@ def updateDatabaseOnEdit(ID,newPath):
storedPathName.path = newPath storedPathName.path = newPath
session.commit() session.commit()
# Deletes the hashes in database of deleted book # Deletes the hashes in database of deleted book
def deleteDatabaseEntry(ID): def deleteDatabaseEntry(ID):
session.query(GdriveId).filter(GdriveId.gdrive_id == ID).delete() session.query(GdriveId).filter(GdriveId.gdrive_id == ID).delete()
session.commit() session.commit()
# Gets cover file from gdrive # Gets cover file from gdrive
def get_cover_via_gdrive(cover_path): def get_cover_via_gdrive(cover_path):
df = getFileFromEbooksFolder(cover_path, 'cover.jpg') df = getFileFromEbooksFolder(cover_path, 'cover.jpg')
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class ReverseProxied(object):
"""Wrap the application in this middleware and configure the
front-end server to add these headers, to let you quietly bind
this to a URL other than / and to an HTTP scheme that is
different than what is used locally.
Code courtesy of: http://flask.pocoo.org/snippets/35/
In nginx:
location /myprefix {
proxy_pass http://127.0.0.1:8083;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /myprefix;
}
"""
def __init__(self, application):
self.app = application
def __call__(self, environ, start_response):
script_name = environ.get('HTTP_X_SCRIPT_NAME', '')
if script_name:
environ['SCRIPT_NAME'] = script_name
path_info = environ.get('PATH_INFO', '')
if path_info and path_info.startswith(script_name):
environ['PATH_INFO'] = path_info[len(script_name):]
scheme = environ.get('HTTP_X_SCHEME', '')
if scheme:
environ['wsgi.url_scheme'] = scheme
servr = environ.get('HTTP_X_FORWARDED_SERVER', '')
if servr:
environ['HTTP_HOST'] = servr
return self.app(environ, start_response)
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from socket import error as SocketError from socket import error as SocketError
import sys import sys
import os import os
import signal import signal
import web
try: try:
from gevent.pywsgi import WSGIServer from gevent.pywsgi import WSGIServer
...@@ -19,8 +19,6 @@ except ImportError: ...@@ -19,8 +19,6 @@ except ImportError:
from tornado import version as tornadoVersion from tornado import version as tornadoVersion
gevent_present = False gevent_present = False
import web
class server: class server:
...@@ -29,7 +27,7 @@ class server: ...@@ -29,7 +27,7 @@ class server:
def __init__(self): def __init__(self):
signal.signal(signal.SIGINT, self.killServer) signal.signal(signal.SIGINT, self.killServer)
signal.signal(signal.SIGTERM, self.killServer) signal.signal(signal.SIGTERM, self.killServer)
def start_gevent(self): def start_gevent(self):
try: try:
...@@ -68,7 +66,8 @@ class server: ...@@ -68,7 +66,8 @@ class server:
ssl_options=ssl) ssl_options=ssl)
http_server.listen(web.ub.config.config_port) http_server.listen(web.ub.config.config_port)
self.wsgiserver=IOLoop.instance() self.wsgiserver=IOLoop.instance()
self.wsgiserver.start() # wait for stop signal self.wsgiserver.start()
# wait for stop signal
self.wsgiserver.close(True) self.wsgiserver.close(True)
if self.restart == True: if self.restart == True:
......
...@@ -1173,7 +1173,7 @@ msgstr "Pfad zu Konvertertool" ...@@ -1173,7 +1173,7 @@ msgstr "Pfad zu Konvertertool"
#: cps/templates/config_edit.html:199 #: cps/templates/config_edit.html:199
msgid "Location of Unrar binary" msgid "Location of Unrar binary"
msgstr "Ofad zum UnRar Programm" msgstr "Pfad zum UnRar Programm"
#: cps/templates/config_edit.html:215 cps/templates/layout.html:82 #: cps/templates/config_edit.html:215 cps/templates/layout.html:82
#: cps/templates/login.html:4 #: cps/templates/login.html:4
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment