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

Commit

Permalink
minor patches && release v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
weilue luo committed Apr 6, 2020
1 parent 3a21999 commit 64c420e
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 11 deletions.
4 changes: 4 additions & 0 deletions gui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ def queue_downloader(target, queue, stdout_queue, lang):
target(item)
except (EOFError, BrokenPipeError, OSError) as e:
sys.stderr.write(str(e))
except MemoryError as e:
# TODO: display a dialogue
import sys
sys.stdout.write(f'OUT OF MEMORY: {e}')


def concurrent_download(target, items):
Expand Down
4 changes: 4 additions & 0 deletions gui/dist/change_log.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Pikax GUI Change Log

v0.2.0 6 April 2020
- Refined time est output
- Refactored pikax handler

v0.1.10 26 Jan 2020
- Added options for pages/artworks limit

Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion gui/main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exe = EXE(pyz,
a.zipfiles,
a.datas,
[],
name='Pikax 0.1.10',
name='Pikax 0.2.0',
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand Down
16 changes: 15 additions & 1 deletion gui/pikaxhandler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys

import pikax

import texts
from pikax import Pikax, ArtworkError, DefaultPikaxResult
from pikax import params
Expand Down Expand Up @@ -90,6 +90,7 @@ def download_by_artist_id(self, artist_id, limit, content, folder, likes, pages_
sys.stdout.write(str(e))


# log stuff
def log(*objects, sep=' ', end='\n', file=sys.stdout, flush=True, start='', inform=False, save=False, error=False,
warn=False, normal=False):
import sys
Expand All @@ -98,3 +99,16 @@ def log(*objects, sep=' ', end='\n', file=sys.stdout, flush=True, start='', info


pikax.util.log = log

pikax.texts.GUI_ARTWORK_DOWNLOAD_HEADING = {
'English': 'Artwork Downloading' + os.linesep + os.linesep,
'Chinese': '作品下载中' + os.linesep + os.linesep
}
pikax.texts.GUI_ID_PROCESSING_HEADING = {
'English': 'Artwork ID Processing' + os.linesep,
'Chinese': '作品ID处理中' + os.linesep
}


# request stuff
pikax.settings.TIMEOUT = 3
2 changes: 1 addition & 1 deletion gui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
MAIN_WINDOW_WIDTH = 1000
DOWNLOAD_WINDOW_WIDTH = 600
DOWNLOAD_WINDOW_HEIGHT = 400
VERSION = '0.1.10'
VERSION = '0.2.0'

# Paths
CANVAS_BACKGROUND_PATH = 'assets/images/background.jpg'
Expand Down
8 changes: 0 additions & 8 deletions gui/texts.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ def set_lang(lang):
raise KeyError(f'Given language: {lang} is not in supported languages: {LANGS}')
LANG = lang
pikax.texts.lang = GUI_LANG_TO_PIKAX_LANG[LANG]
pikax.texts.GUI_ARTWORK_DOWNLOAD_HEADING = {
'English': 'Artwork Downloading' + str(os.linesep * 2),
'Chinese': '作品下载中' + str(os.linesep * 2)
}
pikax.texts.GUI_ID_PROCESSING_HEADING = {
'English': 'Artwork ID Processing' + os.linesep,
'Chinese': '作品ID处理中' + os.linesep
}


def get(key):
Expand Down
4 changes: 4 additions & 0 deletions pikax/texts.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ def __setattr__(self, key, value):
'English': 'Request timeout: retries: {retries}',
'Chinese': '请求超时:重试:{retries}'
}
REQUEST_CONNECTION_ERROR = {
'English': 'Request Connection Error: retries: {retries}',
'Chinese': '请求链接出错:重试:{retries}'
}
REQUEST_EXCEPTION = {
'English': 'Request exception encountered, retries: {retries}',
'Chinese': '请求时出错,重试:{retries}'
Expand Down
4 changes: 4 additions & 0 deletions pikax/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ def req(url, req_type='get', session=None, params=None, data=None, headers=setti
if log_req:
log(texts.REQUEST_TIME_OUT.format(retries=curr_retries), save=True)
log(texts.REQUEST_REASON.format(e=e), save=True, inform=True)
except requests.exceptions.ConnectionError as e:
if log_req:
log(texts.REQUEST_CONNECTION_ERROR.format(retries=curr_retries), save=True)
log(texts.REQUEST_REASON.format(e=e), save=True, inform=True)
except requests.exceptions.RequestException as e:
if log_req:
log(texts.REQUEST_EXCEPTION.format(retries=curr_retries), save=True, inform=True)
Expand Down

0 comments on commit 64c420e

Please sign in to comment.