Skip to content

Commit

Permalink
4.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaM-TL committed Feb 17, 2024
1 parent a8cb4a3 commit 15a7e7d
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -2,6 +2,8 @@

## 2024

4.4.5 checking new version of FotoKilof

4.4.4 logging in proper way

4.4.3 entrypoint to easier run by execution fotokilof
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -132,7 +132,7 @@ python3 -m pip install fotokilof

#### Windows
Download and install requirements:
- [Python3](https://www.python.org/) - add path into `%PATH%` environment variable,
- [Python3.9+](https://www.python.org/) - add path into `%PATH%` environment variable,
- [ImageMagick](https://imagemagick.org/script/download.php#windows) - add path into `%PATH%` environment variable, enable install libraries!

```bash
Expand Down
20 changes: 15 additions & 5 deletions fotokilof/__main__.py
Expand Up @@ -59,6 +59,7 @@
DISABLED, NORMAL, HORIZONTAL

# my modules
import check_new_version
import convert
import convert_wand
import common
Expand Down Expand Up @@ -908,6 +909,7 @@ def ini_read_wraper():
logging.INFO
)
img_custom_on.set(ini_entries['img_custom_on'])
check_version.set(ini_entries['check_version'])
# resize
ini_entries = ini_read.resize(FILE_INI)
img_resize_on.set(ini_entries['img_resize_on'])
Expand Down Expand Up @@ -1052,20 +1054,21 @@ def ini_save_wraper():
# main
config = {'section': 'Main',
'path': file_in_path.get(),
'custom_on': img_custom_on.get(),
'work_dir': work_dir.get(),
'file_dir': file_dir_selector.get(),
'exif': img_exif_on.get(),
'preview_new': co_preview_selector_new.get(),
'custom_on': img_custom_on.get(),
'preview_orig': co_preview_selector_orig.get(),
'log': log_level.get()}
'preview_new': co_preview_selector_new.get(),
'log_level': log_level.get(),
'check_version': check_version.get()}
# resize
resize = {'section': 'Resize',
'on': img_resize_on.get(),
'resize': img_resize.get(),
'size_percent': e2_resize.get(),
'size_pixel_x': e1_resize_x.get(),
'size_pixel_y': e1_resize_y.get()}
'size_pixel_y': e1_resize_y.get(),
'size_percent': e2_resize.get()}
# text
text = {'section': 'Text',
'on': img_text_on.get(),
Expand Down Expand Up @@ -1621,6 +1624,7 @@ def text_tool_hide_show():
FILE_INI = os.path.join(os.path.expanduser("~"), ".fotokilof.ini")
PWD = os.getcwd()
log_level = StringVar() # E(rror), W(arning), M(essage)
check_version = IntVar() # allow to check new version
work_dir = StringVar() # default: "FotoKilof"
work_sub_dir = StringVar() # subdir for resized pictures
work_sub_dir.set("") # default none
Expand Down Expand Up @@ -2817,6 +2821,12 @@ def text_tool_hide_show():
b_file_select_screenshot.configure(state=DISABLED)
root.deiconify()


if check_version.get():
if check_new_version.check_version(version.__version__)[0]:
Messagebox.show_warning(_('New version of FotoKilof is available.\nCurrent: ' + version.__version__ +', New: ' + check_new_version.check_version(version.__version__)[1] + '\nRun command:\npython3 -m pip install --upgrade fotokilof'),
title=_('New version of FotoKilof is available'))

root.mainloop()

# EOF
68 changes: 68 additions & 0 deletions fotokilof/check_new_version.py
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-

"""
Copyright (c) 2024 Tomasz Łuczak, TeaM-TL
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
From https://stackoverflow.com/questions/28774852/pypi-api-how-to-get-stable-package-version
"""

import json
import requests

try:
from packaging.version import parse
except ImportError:
from pip._vendor.packaging.version import parse


URL_PATTERN = 'https://pypi.python.org/pypi/{package}/json'

def get_version(url_pattern=URL_PATTERN):
"""Return version of package on pypi.python.org using json."""

package = 'FotoKilof'
version = parse('0')
try:
req = requests.get(url_pattern.format(package=package), timeout=2.50)
request_success = 1
except:
request_success = 0

if request_success and req.status_code == requests.codes.ok:
j = json.loads(req.text.encode(req.encoding))
releases = j.get('releases', [])
for release in releases:
ver = parse(release)
if not ver.is_prerelease:
version = max(version, ver)
return (request_success, str(version))

def check_version(current_version):
"""
Check version of FotoKilof in PyPi
return 1 - get new
return 0 - there are no new
"""
result = 0
if get_version()[0] and get_version()[1] > current_version:
result = 1

return (result, get_version()[1])
6 changes: 6 additions & 0 deletions fotokilof/ini_read.py
Expand Up @@ -107,6 +107,12 @@ def main(file_ini, preview_size_list):
("E", "W", "M"),
"E")

try:
check_version = config.getint('Main', 'check_version')
except:
check_version = 1
dict_return['check_version'] = entries.parse_list(check_version, (0, 1), 0)

return dict_return


Expand Down
5 changes: 3 additions & 2 deletions fotokilof/ini_save.py
Expand Up @@ -40,9 +40,9 @@
"""

import configparser
import logging

import common
import logging


def save(ini_data):
Expand Down Expand Up @@ -73,7 +73,8 @@ def save(ini_data):
config.set(main['section'], 'custom', str(main['custom_on']))
config.set(main['section'], 'preview_orig', main['preview_orig'])
config.set(main['section'], 'preview_new', main['preview_new'])
config.set(main['section'], 'log', main['log'])
config.set(main['section'], 'log_level', main['log_level'])
config.set(main['section'], 'check_version', main['check_version'])
# resize
config.add_section(resize['section'])
config.set(resize['section'], 'on', str(resize['on']))
Expand Down
2 changes: 1 addition & 1 deletion fotokilof/version.py
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
"""

__version__ = "4.4.4"
__version__ = "4.4.5"
__author__ = "Tomasz Łuczak"
__email__ = "tlu@team-tl.pl"
__appname__ = "FotoKilof"
Expand Down

0 comments on commit 15a7e7d

Please sign in to comment.