Skip to content

Commit

Permalink
bump version to 6.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
leovan committed Nov 12, 2023
1 parent c0ac928 commit c45781c
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 45 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [6.2.4](https://github.com/leovan/SciHubEVA/compare/v6.2.3...v6.2.4) (2023-11-12)

### Bug Fixes

- Close PDFParser and manual gc to avoid memory leak.

## [6.2.3](https://github.com/leovan/SciHubEVA/compare/v6.2.2...v6.2.3) (2023-09-10)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion building/Windows/SciHubEVA-x86_64.iss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define MyAppName "Sci-Hub EVA"
#define MyAppVersion "6.2.2"
#define MyAppVersion "6.2.4"
#define MyAppPublisher "Leo Van"
#define MyAppURL "https://github.com/leovan/SciHubEVA"
#define MyAppExeName "SciHubEVA.exe"
Expand Down
8 changes: 4 additions & 4 deletions building/Windows/SciHubEVA.win.version
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VSVersionInfo(
ffi=FixedFileInfo(
filevers=(6, 2, 2, 0),
prodvers=(6, 2, 2, 0),
filevers=(6, 2, 4, 0),
prodvers=(6, 2, 4, 0),
mask=0x3f,
flags=0x0,
OS=0x4,
Expand All @@ -16,12 +16,12 @@ VSVersionInfo(
u'040904B0',
[StringStruct(u'CompanyName', u'leovan.tech'),
StringStruct(u'FileDescription', u'Sci-Hub EVA'),
StringStruct(u'FileVersion', u'6.2.2.0'),
StringStruct(u'FileVersion', u'6.2.4.0'),
StringStruct(u'InternalName', u'SciHubEVA'),
StringStruct(u'LegalCopyright', u'\xa9 2018-2023 Leo Van.'),
StringStruct(u'OriginalFilename', u'SciHubEVA.exe'),
StringStruct(u'ProductName', u'Sci-Hub EVA'),
StringStruct(u'ProductVersion', u'6.2.2.0')])
StringStruct(u'ProductVersion', u'6.2.4.0')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
Expand Down
2 changes: 1 addition & 1 deletion building/macOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>MacOS/Sci-Hub EVA</string>
<key>CFBundleShortVersionString</key>
<string>6.2.2</string>
<string>6.2.4</string>
<key>LSBackgroundOnly</key>
<string>0</string>
<key>CFBundleName</key>
Expand Down
69 changes: 44 additions & 25 deletions building/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))

from docopt import docopt
from pathlib import Path

from scihub_eva.utils.sys_utils import *

Expand Down Expand Up @@ -87,6 +88,7 @@
'QtUiTools',
'QtVirtualKeyboard',
'QtWebChannel',
'QtWebChannelQuick',
'QtWebEngine',
'QtWebEngineCore',
'QtWebEngineQuick',
Expand Down Expand Up @@ -129,9 +131,6 @@
'Qt/plugins/texttospeech',
'Qt/plugins/tls',
'Qt/plugins/virtualkeyboard',
'Qt/qml/QtLocation',
'Qt/qml/QtPositioning',
'Qt/qml/QtTextToSpeech',
'Qt/translations',
]

Expand Down Expand Up @@ -163,7 +162,7 @@ def change_cwd():
def remove_files(files, path_func):
for file in files:
file_path = path_func(file)
if os.path.exists(file_path):
if os.path.isfile(file_path) or os.path.islink(file_path):
os.remove(file_path)


Expand All @@ -188,72 +187,92 @@ def remove_pattern_dirs(dirs_pattern, path_func, recursive=False):
shutil.rmtree(dir_path, ignore_errors=True)


def remove_dead_links(dir_path):
for root, dirs, files in os.walk(dir_path):
for file in files:
file_path = os.path.join(root, file)
if os.path.islink(file_path):
target = Path(file_path).resolve()
if not os.path.exists(target):
os.remove(file_path)


def post_process_win(dist_folder):
windows_app_path = os.path.join(dist_folder, 'SciHubEVA')

path_func = lambda lib: os.path.join(windows_app_path, 'PySide6', '{}.dll'.format(lib.replace('Qt', 'Qt6')))
path_func = lambda lib: os.path.join(windows_app_path, '_internal', 'PySide6', '{}.dll'.format(lib.replace('Qt', 'Qt6')))
remove_files(USELESS_QT_LIBS, path_func)
path_func = lambda lib: os.path.join(windows_app_path, 'PySide6', 'qml', lib)
path_func = lambda lib: os.path.join(windows_app_path, '_internal', 'PySide6', 'qml', lib)
remove_dirs(USELESS_QT_LIBS, path_func)

path_func = lambda dir_prefix: os.path.join(windows_app_path, 'PySide6', dir_prefix.replace('Qt/', ''))
path_func = lambda dir_prefix: os.path.join(windows_app_path, '_internal', 'PySide6', dir_prefix.replace('Qt/', ''))
remove_dirs(USELESS_QT_DIRS, path_func)

path_func = lambda package: os.path.join(windows_app_path, package)
path_func = lambda package: os.path.join(windows_app_path, '_internal', package)
remove_dirs(USELESS_PACKAGES, path_func)

path_func = lambda library: os.path.join(windows_app_path, 'lib{}*.dll'.format(library))
path_func = lambda library: os.path.join(windows_app_path, '_internal', 'lib{}*.dll'.format(library))
remove_pattern_files(USELESS_LIBS, path_func)

path_func = lambda dir_suffix: os.path.join(windows_app_path, '*{}'.format(dir_suffix))
path_func = lambda dir_suffix: os.path.join(windows_app_path, '_internal', '*{}'.format(dir_suffix))
remove_pattern_dirs(DIST_INFO_DIRS_SUFFIX, path_func)


def post_process_macos(dist_folder):
macos_app_path = os.path.join(dist_folder, 'Sci-Hub EVA.app')

path_func = lambda lib: os.path.join(macos_app_path, 'Contents', 'MacOS', lib)
remove_files(USELESS_QT_LIBS, path_func)
path_func = lambda lib: os.path.join(macos_app_path, 'Contents', 'MacOS', 'PySide6', 'Qt', 'qml', lib)
path_func = lambda lib: os.path.join(macos_app_path, 'Contents', 'Frameworks', 'PySide6', 'Qt', 'lib', '{}.framework'.format(lib))
remove_dirs(USELESS_QT_LIBS, path_func)
path_func = lambda lib: os.path.join(macos_app_path, 'Contents', 'Frameworks', 'PySide6', 'Qt', 'qml', lib)
remove_dirs(USELESS_QT_LIBS, path_func)
path_func = lambda lib: os.path.join(macos_app_path, 'Contents', 'Resources', 'PySide6', 'Qt', 'qml', lib)
remove_dirs(USELESS_QT_LIBS, path_func)

path_func = lambda dir_prefix: os.path.join(macos_app_path, 'Contents', 'MacOS', 'PySide6', dir_prefix)
path_func = lambda dir_prefix: os.path.join(macos_app_path, 'Contents', 'Frameworks', 'PySide6', dir_prefix)
remove_dirs(USELESS_QT_DIRS, path_func)
path_func = lambda dir_prefix: os.path.join(macos_app_path, 'Contents', 'Resources', 'PySide6', dir_prefix)
remove_dirs(USELESS_QT_DIRS, path_func)

path_func = lambda package: os.path.join(macos_app_path, 'Contents', 'Frameworks', package)
remove_dirs(USELESS_PACKAGES, path_func)
path_func = lambda package: os.path.join(macos_app_path, 'Contents', 'Resources', package)
remove_dirs(USELESS_PACKAGES, path_func)
path_func = lambda package: os.path.join(macos_app_path, 'Contents', 'MacOS', package)
remove_files(USELESS_PACKAGES, path_func)

path_func = lambda library: os.path.join(macos_app_path, 'Contents', 'MacOS', 'lib{}*.dylib'.format(library))
path_func = lambda library: os.path.join(macos_app_path, 'Contents', 'Frameworks', 'lib{}*.dylib'.format(library))
remove_pattern_files(USELESS_LIBS, path_func)
path_func = lambda library: os.path.join(macos_app_path, 'Contents', 'Resources', 'lib{}*.dylib'.format(library))
remove_pattern_files(USELESS_LIBS, path_func)

path_func = lambda dir_suffix: os.path.join(macos_app_path, 'Contents', 'Resources', '*{}'.format(dir_suffix))
path_func = lambda dir_suffix: os.path.join(macos_app_path, 'Contents', 'Frameworks', '*{}'.format(dir_suffix))
remove_pattern_dirs(DIST_INFO_DIRS_SUFFIX, path_func)
path_func = lambda dir_suffix: os.path.join(macos_app_path, 'Contents', 'MacOS', '*{}'.format(dir_suffix))
path_func = lambda dir_suffix: os.path.join(macos_app_path, 'Contents', 'Resources', '*{}'.format(dir_suffix))
remove_pattern_files(DIST_INFO_DIRS_SUFFIX, path_func)

remove_dead_links(os.path.join(macos_app_path, 'Contents'))


def post_process_linux(dist_folder):
linux_app_path = os.path.join(dist_folder, 'SciHubEVA')

path_func = lambda lib: os.path.join(linux_app_path, 'lib{}.so.6'.format(lib.replace('Qt', 'Qt6')))
path_func = lambda lib: os.path.join(linux_app_path, '_internal', 'lib{}.so.6'.format(lib.replace('Qt', 'Qt6')))
remove_files(USELESS_QT_LIBS, path_func)
path_func = lambda lib: os.path.join(linux_app_path, 'PySide6', 'Qt', 'qml', lib)
path_func = lambda lib: os.path.join(linux_app_path, '_internal', 'PySide6', 'Qt', 'qml', lib)
remove_dirs(USELESS_QT_LIBS, path_func)

path_func = lambda dir_prefix: os.path.join(linux_app_path, 'PySide6', dir_prefix)
path_func = lambda dir_prefix: os.path.join(linux_app_path, '_internal', 'PySide6', dir_prefix)
remove_dirs(USELESS_QT_DIRS, path_func)

path_func = lambda package: os.path.join(linux_app_path, package)
path_func = lambda package: os.path.join(linux_app_path, '_internal', package)
remove_dirs(USELESS_PACKAGES, path_func)

path_func = lambda library: os.path.join(linux_app_path, 'lib{}*.so*'.format(library))
path_func = lambda library: os.path.join(linux_app_path, '_internal', 'lib{}*.so*'.format(library))
remove_pattern_files(USELESS_LIBS, path_func)

path_func = lambda dir_suffix: os.path.join(linux_app_path, '*{}'.format(dir_suffix))
path_func = lambda dir_suffix: os.path.join(linux_app_path, '_internal', '*{}'.format(dir_suffix))
remove_pattern_dirs(DIST_INFO_DIRS_SUFFIX, path_func)

remove_dead_links(os.path.join(linux_app_path, '_internal'))


if __name__ == '__main__':
args = docopt(__doc__)
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
docopt==0.6.2
flask==2.3.3
flask==3.0.0
opencc-python-reimplemented==0.1.7
pyinstaller==5.13.2
pyinstaller==6.2.0
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
darkdetect==0.8.0
lxml==4.9.3
pathvalidate==3.1.0
pathvalidate==3.2.0
pdfminer.six==20221105
PySide6==6.5.2
PySide6==6.6.0
PySocks==1.7.1
requests==2.31.0
urllib3==2.0.4
urllib3==2.0.7
2 changes: 1 addition & 1 deletion scihub_eva/globals/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
ORGANIZATION_NAME = 'LeoVan'
ORGANIZATION_DOMAIN = 'leovan.tech'
APPLICATION_NAME = 'SciHubEVA'
APPLICATION_VERSION = 'v6.2.2'
APPLICATION_VERSION = 'v6.2.4'
13 changes: 7 additions & 6 deletions scihub_eva/ui/scihub_eva.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import os
import gc

from collections import deque

Expand Down Expand Up @@ -110,12 +111,6 @@ def rampage(self, raw_query):
self._scihub_url = scihub_url
self._sess = get_session(self._scihub_url)

self._scihub_api = SciHubAPI(
self._logger,
self.rampage_callback,
self._scihub_url,
self._sess)

if os.path.exists(raw_query):
if is_text_file(raw_query):
self._query_list = deque()
Expand Down Expand Up @@ -149,6 +144,9 @@ def rampage_query_list(self):
self.rampage_query(self._query_list.popleft())

def rampage_query(self, query):
del self._scihub_api
gc.collect()

self._scihub_api = SciHubAPI(
self._logger,
self.rampage_callback,
Expand Down Expand Up @@ -177,6 +175,9 @@ def rampage_callback(self, res, err):
self.after_rampage.emit()

def show_captcha(self, pdf_captcha_response):
del self._scihub_api
gc.collect()

self._scihub_api = SciHubAPI(
self._logger,
self.rampage_callback,
Expand Down
7 changes: 6 additions & 1 deletion scihub_eva/utils/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def guess_query_type(query):
def get_pdf_metadata(pdf) -> dict:
temp_pdf_file = tempfile.TemporaryFile()
temp_pdf_file.write(pdf)
temp_pdf_file.flush()

metadata = {
'author': 'UNKNOWN_AUTHOR',
Expand Down Expand Up @@ -87,7 +88,11 @@ def get_pdf_metadata(pdf) -> dict:
except Exception as e:
pass

temp_pdf_file.close()
if pdf_parser:
pdf_parser.close()

if temp_pdf_file:
temp_pdf_file.close()

return metadata

Expand Down
6 changes: 5 additions & 1 deletion scihub_eva/utils/network_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ def set_cookies(sess: Session, resp: Response):

def ddos_guard_bypass(url, sess: Session):
url = re.sub('/+$', '', url)
check_resp = sess.get(url)

try:
check_resp = sess.get(url)
except Exception as e:
return

if (check_resp.status_code == 403
or check_resp.headers.get('server', '').lower() == 'ddos-guard'):
Expand Down

0 comments on commit c45781c

Please sign in to comment.