diff --git a/cps/gdriveutils.py b/cps/gdriveutils.py index f1af97bf..b26f24d0 100644 --- a/cps/gdriveutils.py +++ b/cps/gdriveutils.py @@ -103,7 +103,7 @@ def getEbooksFolderId(drive=None): gDriveId.path='/' session.merge(gDriveId) session.commit() - return + return def getFolderInFolder(parentId, folderName, drive=None): if not drive: @@ -112,7 +112,7 @@ def getFolderInFolder(parentId, folderName, drive=None): drive.auth.Refresh() folder= "title = '%s' and '%s' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false" % (folderName.replace("'", "\\'"), parentId) fileList = drive.ListFile({'q': folder}).GetList() - return fileList[0] + return fileList[0] def getFile(pathId, fileName, drive=None): if not drive: @@ -168,7 +168,7 @@ def getFileFromEbooksFolder(drive, path, fileName): folderId=getFolderId(path, drive) else: folderId=getEbooksFolderId(drive) - + return getFile(folderId, fileName, drive) def copyDriveFileRemote(drive, origin_file_id, copy_title): @@ -221,7 +221,7 @@ def copyToDrive(drive, uploadFile, createRoot, replaceFiles, if os.path.isdir(os.path.join(prevDir,uploadFile)): existingFolder=drive.ListFile({'q' : "title = '%s' and '%s' in parents and trashed = false" % (os.path.basename(uploadFile), parent['id'])}).GetList() if len(existingFolder) == 0 and (not isInitial or createRoot): - parent = drive.CreateFile({'title': os.path.basename(uploadFile), 'parents' : [{"kind": "drive#fileLink", 'id' : parent['id']}], + parent = drive.CreateFile({'title': os.path.basename(uploadFile), 'parents' : [{"kind": "drive#fileLink", 'id' : parent['id']}], "mimeType": "application/vnd.google-apps.folder" }) parent.Upload() else: @@ -259,7 +259,7 @@ def uploadFileToEbooksFolder(drive, destFile, f): else: existingFolder=drive.ListFile({'q' : "title = '%s' and '%s' in parents and trashed = false" % (x, parent['id'])}).GetList() if len(existingFolder) == 0: - parent = drive.CreateFile({'title': x, 'parents' : [{"kind": "drive#fileLink", 'id' : parent['id']}], + parent = drive.CreateFile({'title': x, 'parents' : [{"kind": "drive#fileLink", 'id' : parent['id']}], "mimeType": "application/vnd.google-apps.folder" }) parent.Upload() else: @@ -341,7 +341,7 @@ def stopChannel(drive, channel_id, resource_id): if not drive: drive=getDrive() if drive.auth.access_token_expired: - drive.auth.Refresh() + drive.auth.Refresh() # service=drive.auth.service body = { 'id': channel_id, @@ -363,5 +363,5 @@ def getChangeById (drive, change_id): change = drive.auth.service.changes().get(changeId=change_id).execute() return change except errors.HttpError, error: - web.app.logger.exception(error) + web.app.logger.exception(error) return None diff --git a/cps/helper.py b/cps/helper.py index c4cdf03f..5cf64372 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -366,6 +366,7 @@ class Updater(threading.Thread): def one_minus_two(self, one, two): return [x for x in one if x not in set(two)] + @classmethod def reduce_dirs(self, delete_files, new_list): new_delete = [] for file in delete_files: diff --git a/cps/static/js/get_meta.js b/cps/static/js/get_meta.js index 80543516..99fce061 100644 --- a/cps/static/js/get_meta.js +++ b/cps/static/js/get_meta.js @@ -141,7 +141,7 @@ $(document).ready(function () { function dbSearchBook (title) { var url = douban + dbSearch + "?q=" + title + "&fields=all&count=10"; $.ajax({ - url: url, + url, type: "GET", dataType: "jsonp", jsonp: "callback", @@ -149,7 +149,7 @@ $(document).ready(function () { dbResults = data.books; }, error () { - $("#meta-info").html('

'+ msg.search_error+"!

"); + $("#meta-info").html("

"+ msg.search_error+"!

"); }, complete () { dbDone = true; diff --git a/cps/web.py b/cps/web.py index 3b3597e9..592240c1 100755 --- a/cps/web.py +++ b/cps/web.py @@ -484,7 +484,7 @@ def fill_indexpage(page, database, db_filter, order): return entries, random, pagination -def modify_database_object(input_elements, db_book_object, db_object, db_session, type): +def modify_database_object(input_elements, db_book_object, db_object, db_session, db_type): input_elements = [x for x in input_elements if x != ''] # we have all input element (authors, series, tags) names now # 1. search for elements to remove @@ -516,7 +516,7 @@ def modify_database_object(input_elements, db_book_object, db_object, db_session db_session.delete(del_element) # if there are elements to add, we add them now! if len(add_elements) > 0: - if type == 'languages': + if db_type == 'languages': db_filter = db_object.lang_code else: db_filter = db_object.name @@ -525,12 +525,12 @@ def modify_database_object(input_elements, db_book_object, db_object, db_session new_element = db_session.query(db_object).filter(db_filter == add_element).first() # if no element is found add it if new_element is None: - if type == 'author': + if db_type == 'author': new_element = db_object(add_element, add_element, "") else: - if type == 'series': + if db_type == 'series': new_element = db_object(add_element, add_element) - else: # type should be tag, or languages + else: # db_type should be tag, or languages new_element = db_object(add_element) db_session.add(new_element) new_element = db.session.query(db_object).filter(db_filter == add_element).first()