Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

# This file is the system monitor configuration GUI

from library.pythoncheck import check_python_version
check_python_version()

import glob
import os
import platform
Expand All @@ -28,14 +31,6 @@
import requests
import babel

MIN_PYTHON = (3, 9)
if sys.version_info < MIN_PYTHON:
print("[ERROR] Python %s.%s or later is required." % MIN_PYTHON)
try:
sys.exit(0)
except:
os._exit(0)

try:
import tkinter.ttk as ttk
from tkinter import *
Expand Down
39 changes: 39 additions & 0 deletions library/pythoncheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-License-Identifier: GPL-3.0-or-later
#
# turing-smart-screen-python - a Python system monitor and library for USB-C displays like Turing Smart Screen or XuanFang
# https://github.com/mathoudebine/turing-smart-screen-python/
#
# Copyright (C) 2021 Matthieu Houdebine (mathoudebine)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# This file is used to check if Python version used is compatible
import os
import sys

# Oldest / newest version supported
MIN_PYTHON = (3, 9)
MAX_PYTHON = (3, 13)


def check_python_version():
current_version = sys.version_info[:2]

if current_version < MIN_PYTHON or current_version > MAX_PYTHON:
print(f"[ERROR] Python {current_version[0]}.{current_version[1]} is not supported by this program. "
f"Python {MIN_PYTHON[0]}.{MIN_PYTHON[1]}-{MAX_PYTHON[0]}.{MAX_PYTHON[1]} required.")
try:
sys.exit(0)
except:
os._exit(0)
12 changes: 4 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# This file is the system monitor main program to display HW sensors on your screen using themes (see README)

from library.pythoncheck import check_python_version
check_python_version()

import glob
import os
import sys

MIN_PYTHON = (3, 9)
if sys.version_info < MIN_PYTHON:
print("[ERROR] Python %s.%s or later is required." % MIN_PYTHON)
try:
sys.exit(0)
except:
os._exit(0)

try:
import atexit
import locale
Expand Down
10 changes: 0 additions & 10 deletions res/fonts/font-preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@
# This file generate PNG previews for available fonts

import os
import sys

MIN_PYTHON = (3, 9)
if sys.version_info < MIN_PYTHON:
print("[ERROR] Python %s.%s or later is required." % MIN_PYTHON)
try:
sys.exit(0)
except:
os._exit(0)

from PIL import Image, ImageDraw, ImageFont
import math
from pathlib import Path
Expand Down
3 changes: 3 additions & 0 deletions simple-program.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

# This file is a simple Python test program using the library code to display custom content on screen (see README)

from library.pythoncheck import check_python_version
check_python_version()

import os
import signal
import sys
Expand Down
11 changes: 3 additions & 8 deletions theme-editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
# theme-editor.py: Allow to easily edit themes for System Monitor (main.py) in a preview window on the computer
# The preview window is refreshed as soon as the theme file is modified

from library.pythoncheck import check_python_version
check_python_version()

import locale
import logging
import os
Expand All @@ -28,14 +31,6 @@
import sys
import time

MIN_PYTHON = (3, 8)
if sys.version_info < MIN_PYTHON:
print("[ERROR] Python %s.%s or later is required." % MIN_PYTHON)
try:
sys.exit(0)
except:
os._exit(0)

try:
import tkinter
from PIL import ImageTk, Image
Expand Down
8 changes: 0 additions & 8 deletions tools/turing-theme-extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
PNG_SIGNATURE = b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'
PNG_IEND = b'\x49\x45\x4E\x44\xAE\x42\x60\x82'

MIN_PYTHON = (3, 8)
if sys.version_info < MIN_PYTHON:
print("[ERROR] Python %s.%s or later is required." % MIN_PYTHON)
try:
sys.exit(0)
except:
os._exit(0)

if len(sys.argv) != 2:
print("Usage :")
print(" turing-theme-extractor.py path/to/theme-file.data")
Expand Down