Reworked logging

Re-implemented logging using python's logging module instead of simple print() calls.
dev
Peery 3 years ago
parent 756b95abc8
commit 7a41c675ec

@ -1,6 +1,8 @@
import shutil
import sys
import os
import logging
import datetime
from hashlib import md5
from PyQt5.QtWidgets import QApplication
@ -14,13 +16,28 @@ from ArtNet.web.link_generator import LinkGenerator
class ArtNetManager:
LOG_FOLDER = "log"
def __init__(self, config_location: str = "."):
if not os.path.isdir(ArtNetManager.LOG_FOLDER):
os.mkdir(ArtNetManager.LOG_FOLDER)
file_name = "artnet-" + str(datetime.datetime.now().strftime("%Y-%m-%d")) + ".log"
logging.basicConfig(filename=os.path.join(ArtNetManager.LOG_FOLDER, file_name), encoding='utf-8',
level=logging.DEBUG)
logFormatter = logging.Formatter(fmt="%(asctime)s.%(msecs)03d [%(threadName)-12.12s] [%(levelname)-5.5s] "
"%(message)s",
datefmt="%Y-%m-%d %H:%M:%S")
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
for handler in logging.getLogger().handlers:
handler.setFormatter(logFormatter)
logging.info("Starting ArtNet client ...")
self.known_image_amount = None
self.config = ConfigReader(config_location, "somePassword")
if self.config.data["version"] != self.config.CONFIG_VERSION:
print("Loaded config version is unequal to expected version! {0} (current) != {1} (expected)"
logging.warning("Loaded config version is unequal to expected version! {0} (current) != {1} (expected)"
.format(self.config.data["version"], self.config.CONFIG_VERSION))
self.db_connection = None
@ -34,7 +51,7 @@ class ArtNetManager:
port=self.config.data["db"]["port"],
database=self.config.data["db"]["database"])
except ValueError as e: # db connection didn't work
print(e)
logging.error(e)
dialog = DBDialog()
prev_db_data = self.get_db_connection_details()
dialog.ui.user_line_edit.setText(prev_db_data["user"])
@ -51,8 +68,9 @@ class ArtNetManager:
database=db_data["database"])
self.window = Window(self)
if len(self.config.data["file_root"]) == 0 or not os.path.isdir(self.config.data["file_root"]): # no file_root given by config or invalid
print("Querying for new file root due to lack of valid one ...")
if len(self.config.data["file_root"]) == 0 or not os.path.isdir(
self.config.data["file_root"]): # no file_root given by config or invalid
logging.info("Querying for new file root due to lack of valid one ...")
self.window.on_artnet_root_change_clicked()
self.__file_reader = FileReader(self.config.data["file_root"])
@ -71,7 +89,9 @@ class ArtNetManager:
self.window.show()
sys.exit(self.__app.exec_())
status = self.__app.exec_()
logging.info(f"Shutting client down with status: {status}")
sys.exit(status)
def update_all_images_list(self):
"""
@ -93,7 +113,7 @@ class ArtNetManager:
self.window.ui.imageNumberSpinBox.setMaximum(len(self.all_images))
def scrape_tags(self, file_name: str, art_ID: int, url: str=None):
def scrape_tags(self, file_name: str, art_ID: int, url: str = None):
"""
Scrape the tags from the given url and return which one's are new
:param file_name:
@ -204,28 +224,26 @@ class ArtNetManager:
full_art_path = self.get_root() + os.path.sep + path
if delete_instead_of_move:
print(f"Deleting the actual file {full_art_path} is disabled for now")
#os.remove(full_art_path)
#return
logging.warning(f"Deleting the actual file {full_art_path} is disabled for now")
# os.remove(full_art_path)
# return
trash_dst = trash_bin_folder_path + os.path.sep + path
t_splits = trash_dst.split(os.path.sep)
t_path = ""
for i in range(len(t_splits)-1):
for i in range(len(t_splits) - 1):
t_path += os.path.sep + t_splits[i]
t_path = t_path[1:]
if not os.path.exists(t_path):
print(f"{t_path} did not exist and will be created!")
os.makedirs("."+os.path.sep+t_path)
print(f"Moving image {full_art_path} to {trash_dst}")
logging.info(f"{t_path} did not exist and will be created!")
os.makedirs("." + os.path.sep + t_path)
logging.info(f"Moving image {full_art_path} to {trash_dst}")
shutil.move(full_art_path, trash_dst)
self.update_all_images_list()
while self.curr_image_index >= len(self.all_images):
self.curr_image_index -= 1
@DeprecationWarning
def recalculate_hash_for_known_images(self):
"""
@ -335,7 +353,7 @@ class ArtNetManager:
image_db_result = self.db_connection.get_art_by_hash(
self.get_md5_of_image(self.all_images[self.curr_image_index])
)
#image_db_result = self.db_connection.get_art_by_path(self.all_images[self.curr_image_index])
# image_db_result = self.db_connection.get_art_by_path(self.all_images[self.curr_image_index])
s = self.all_images[self.curr_image_index].split(os.path.sep)
if image_db_result is not None:
image_title = image_db_result["title"] if isinstance(image_db_result["title"], str) and \
@ -353,18 +371,19 @@ class ArtNetManager:
image_link = "(Unknown)"
image_description = None
print(f"Displaying #{self.curr_image_index} \"{self.all_images[self.curr_image_index]}\"")
logging.info(f"Displaying #{self.curr_image_index} \"{self.all_images[self.curr_image_index]}\"")
self.window.display_image(image_title, image_author,
os.path.join(self.config.data["file_root"], self.all_images[self.curr_image_index]),
self.all_images[self.curr_image_index],
art_ID, image_link, file_name=s[-1], description=image_description)
self.window.set_tag_list([self.db_connection.get_tag_by_ID(x)[0][1].strip() for x in self.db_connection.get_art_tags_by_ID(art_ID)])
self.window.set_tag_list(
[self.db_connection.get_tag_by_ID(x)[0][1].strip() for x in self.db_connection.get_art_tags_by_ID(art_ID)])
self.window.data_changed = False
self.window.setting_up_data = False
def create_db_connection(self, host: str, port: int, database: str, user: str, password: str) -> DBAdapter:
print(f"Changing db connection to {host}:{port} {user}@{database} ...")
logging.info(f"Changing db connection to {host}:{port} {user}@{database} ...")
return DBAdapter(user=user, password=password, host=host, port=port, database=database)
def get_root(self) -> str:
@ -380,7 +399,7 @@ class ArtNetManager:
"""
if len(path) == 0:
exit(0)
print("Changing root to", path)
logging.info("Changing root to", path)
self.config.data["file_root"] = path
self.config.update_config()
self.__file_reader = FileReader(self.config.data["file_root"])
@ -400,5 +419,3 @@ class ArtNetManager:
self.config.update_config()
self.db_connection = self.create_db_connection(host, port, database, user, password)

@ -1,3 +1,4 @@
import logging
import psycopg2
from psycopg2.errorcodes import UNIQUE_VIOLATION
@ -17,9 +18,10 @@ class DBAdapter:
except psycopg2.OperationalError as e:
raise ValueError("Invalid DB credentials!")
print("DB connection established to {0}:{1}/{2}".format(host, port, database))
logging.debug("DB connection established to {0}:{1}/{2}".format(host, port, database))
if not self.check_tables():
logging.debug("Database schema check has failed! The expected tables have not been present.")
raise ValueError("Invalid DB schema!")
def check_tables(self) -> bool:
@ -39,11 +41,11 @@ class DBAdapter:
missing.remove(table)
if len(missing) > 0:
print("The following tables are missing from the currently connected database: {0}".format(missing))
logging.error("The following tables are missing from the currently connected database: {0}".format(missing))
return False
if len(unknown_tables) > 0:
print("The following tables are unknown and not expected inside the database: {0}".format(unknown_tables))
logging.error("The following tables are unknown and not expected inside the database: {0}".format(unknown_tables))
return True
@ -60,7 +62,7 @@ class DBAdapter:
:param desc: image description or None for empty
:return:
"""
print("Saving Image {0}:{1} authors: {2} path: {3} tags: {4} link: {5} hash:{6} desc:{7}"
logging.debug("Saving Image {0}:{1} authors: {2} path: {3} tags: {4} link: {5} hash:{6} desc:{7}"
.format(ID, title, authors, path, tags, link, md5_hash, desc))
d = {"title": title, "path": path, "id": ID, "link": link, "hash": md5_hash, "desc": desc}
if self.get_art_by_path(path) is None:
@ -92,8 +94,8 @@ class DBAdapter:
self.db_cursor.execute("INSERT INTO art_tag (art_id, tag_ID) VALUES (%(id)s, %(tag)s)", d)
except psycopg2.Error as e:
if e.pgcode == UNIQUE_VIOLATION:
print(e)
print("Skipping Unique Violation ...")
logging.debug(e)
logging.info("Skipping Unique Violation ...")
else:
raise e
@ -125,7 +127,7 @@ class DBAdapter:
"""
image_data = self.get_art_by_hash(hash)
art_ID = image_data["ID"]
print(f"Deleting image #{art_ID} {image_data['title']}")
logging.debug(f"Deleting image #{art_ID} {image_data['title']}")
tags = self.get_art_tags_by_ID(art_ID)
for tag_ID in tags:
pass
@ -174,7 +176,7 @@ class DBAdapter:
:param link:
:return:
"""
print("Saving Presence {0}:{1} Artist: {2} Link: {3}".format(name, domain, artist_ID, link))
logging.debug("Saving Presence {0}:{1} Artist: {2} Link: {3}".format(name, domain, artist_ID, link))
artist = self.get_artist(artist_ID)
if artist is None or len(artist) == 0:
raise Exception("Unknown Artist to create/update Presence with!")
@ -195,7 +197,7 @@ class DBAdapter:
Remove a presence from the database
:return:
"""
print("Removing Presence {0}:{1}".format(name, domain))
logging.debug("Removing Presence {0}:{1}".format(name, domain))
d = {"name": name, "domain": domain}
self.db_cursor.execute("DELETE FROM presence WHERE name = %(name)s and domain = %(domain)s", d)
self.db.commit()
@ -226,7 +228,7 @@ class DBAdapter:
:param name:
:return:
"""
print("Saving artist {0}:{1}".format(ID, name))
logging.debug("Saving artist {0}:{1}".format(ID, name))
d = {"id": ID, "name": name}
if ID is None: # no ID given, auto generate it
self.db_cursor.execute("INSERT INTO artist (name) VALUES (%(name)s)", d)
@ -242,7 +244,7 @@ class DBAdapter:
:param ID:
:return:
"""
print("Deleting artist {0}".format(ID))
logging.debug("Deleting artist {0}".format(ID))
d = {"id": ID}
self.db_cursor.execute("DELETE FROM Artist WHERE ID = %(id)s", d)
self.db.commit()
@ -255,7 +257,7 @@ class DBAdapter:
:param name:
:return:
"""
print("Saving category {0}!".format(name))
logging.debug("Saving category {0}!".format(name))
d = {"name": name}
self.db_cursor.execute("INSERT INTO tag_category (name) VALUES (%(name)s)", d)

@ -37,9 +37,3 @@ class FileReader:
dirs.append(os.path.join(curr_dir, d))
return l
if __name__ == "__main__":
fr = FileReader("/home/peery/Software_Projects/ArtNet/App/Fake_Other_Artists")
print(fr.list_artists())
print(fr.get_files("AkuDrache"))

@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1239, 824)
MainWindow.resize(1140, 849)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setEnabled(True)
self.centralwidget.setObjectName("centralwidget")
@ -173,13 +173,13 @@ class Ui_MainWindow(object):
self.tag_layout = QtWidgets.QVBoxLayout()
self.tag_layout.setSizeConstraint(QtWidgets.QLayout.SetMinimumSize)
self.tag_layout.setObjectName("tag_layout")
self.label = QtWidgets.QLabel(self.right_frame)
self.search_tags_label = QtWidgets.QLabel(self.right_frame)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.tag_layout.addWidget(self.label)
self.search_tags_label.setFont(font)
self.search_tags_label.setObjectName("search_tags_label")
self.tag_layout.addWidget(self.search_tags_label)
self.tag_list_layout = QtWidgets.QVBoxLayout()
self.tag_list_layout.setSizeConstraint(QtWidgets.QLayout.SetMinimumSize)
self.tag_list_layout.setObjectName("tag_list_layout")
@ -197,13 +197,13 @@ class Ui_MainWindow(object):
self.search_result_list.setMaximumSize(QtCore.QSize(400, 16777215))
self.search_result_list.setObjectName("search_result_list")
self.tag_list_layout.addWidget(self.search_result_list)
self.label_2 = QtWidgets.QLabel(self.right_frame)
self.selected_tags_label = QtWidgets.QLabel(self.right_frame)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.tag_list_layout.addWidget(self.label_2)
self.selected_tags_label.setFont(font)
self.selected_tags_label.setObjectName("selected_tags_label")
self.tag_list_layout.addWidget(self.selected_tags_label)
self.tag_list = QtWidgets.QListView(self.right_frame)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
@ -214,14 +214,14 @@ class Ui_MainWindow(object):
self.tag_list.setMaximumSize(QtCore.QSize(400, 16777215))
self.tag_list.setObjectName("tag_list")
self.tag_list_layout.addWidget(self.tag_list)
self.label_3 = QtWidgets.QLabel(self.right_frame)
self.implied_tags_list = QtWidgets.QLabel(self.right_frame)
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(True)
font.setWeight(75)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.tag_list_layout.addWidget(self.label_3)
self.implied_tags_list.setFont(font)
self.implied_tags_list.setObjectName("implied_tags_list")
self.tag_list_layout.addWidget(self.implied_tags_list)
self.implied_tag_list = QtWidgets.QListView(self.right_frame)
self.implied_tag_list.setMinimumSize(QtCore.QSize(100, 0))
self.implied_tag_list.setMaximumSize(QtCore.QSize(400, 16777215))
@ -263,13 +263,21 @@ class Ui_MainWindow(object):
self.tag_button_layout.addItem(spacerItem)
self.tag_layout.addLayout(self.tag_button_layout)
self.horizontalLayout_3.addLayout(self.tag_layout)
self.topic_docker_button = QtWidgets.QToolButton(self.right_frame)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.topic_docker_button.sizePolicy().hasHeightForWidth())
self.topic_docker_button.setSizePolicy(sizePolicy)
self.topic_docker_button.setObjectName("topic_docker_button")
self.horizontalLayout_3.addWidget(self.topic_docker_button)
self.horizontalLayout.addWidget(self.right_frame)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menuBar = QtWidgets.QMenuBar(MainWindow)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 1239, 30))
self.menuBar.setGeometry(QtCore.QRect(0, 0, 1140, 34))
self.menuBar.setObjectName("menuBar")
self.menuArtNet = QtWidgets.QMenu(self.menuBar)
self.menuArtNet.setObjectName("menuArtNet")
@ -324,14 +332,15 @@ class Ui_MainWindow(object):
self.source_link_label.setText(_translate("MainWindow", "Link:"))
self.description_label.setText(_translate("MainWindow", "Description:"))
self.next_image_button.setText(_translate("MainWindow", ">"))
self.label.setText(_translate("MainWindow", "Search Tags"))
self.label_2.setText(_translate("MainWindow", "Selected Tags:"))
self.label_3.setText(_translate("MainWindow", "Implied Tags:"))
self.search_tags_label.setText(_translate("MainWindow", "Search Tags"))
self.selected_tags_label.setText(_translate("MainWindow", "Selected Tags:"))
self.implied_tags_list.setText(_translate("MainWindow", "Implied Tags:"))
self.save_button.setText(_translate("MainWindow", "Save"))
self.import_button.setText(_translate("MainWindow", "Import Tags"))
self.prev_unknown_image_button.setText(_translate("MainWindow", "prev Unknown"))
self.next_unknown_image_button.setText(_translate("MainWindow", "next Unknown"))
self.delete_button.setText(_translate("MainWindow", "Delete"))
self.topic_docker_button.setText(_translate("MainWindow", ">"))
self.menuArtNet.setTitle(_translate("MainWindow", "ArtNet"))
self.menuTags.setTitle(_translate("MainWindow", "Tags"))
self.menuCategory.setTitle(_translate("MainWindow", "Category"))

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1239</width>
<height>824</height>
<width>1140</width>
<height>849</height>
</rect>
</property>
<property name="windowTitle">
@ -282,7 +282,7 @@
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="search_tags_label">
<property name="font">
<font>
<weight>75</weight>
@ -332,7 +332,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="selected_tags_label">
<property name="font">
<font>
<weight>75</weight>
@ -367,7 +367,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="implied_tags_list">
<property name="font">
<font>
<pointsize>9</pointsize>
@ -482,6 +482,19 @@
</item>
</layout>
</item>
<item>
<widget class="QToolButton" name="topic_docker_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -493,8 +506,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1239</width>
<height>30</height>
<width>1140</width>
<height>34</height>
</rect>
</property>
<widget class="QMenu" name="menuArtNet">

@ -1,4 +1,5 @@
import validators, os
import logging
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt, QSize, QUrl
@ -650,7 +651,7 @@ class Window(QtWidgets.QMainWindow):
elif a0.key() == Qt.Key_Right:
self.on_next_clicked()
elif a0.key() == Qt.Key_Return:
print("Pressed Enter!")
logging.debug("Pressed Enter!")
if self.__showing_video:
s = self.__player.state()
if self.__player.state() == QtMultimedia.QMediaPlayer.PlayingState:
@ -684,7 +685,7 @@ class Window(QtWidgets.QMainWindow):
self.set_tag_list(self.curr_tags) # update relevant lists
self.set_tag_search_result_list([item_data[0]])
print(item_data)
logging.debug(item_data)
def on_movie_player_state_changed(self, state: int):
self.__image_resize()
@ -702,12 +703,12 @@ class Window(QtWidgets.QMainWindow):
self.__pixmap.setPaused(True)
def on_save_clicked(self):
print("Clicked Save!")
logging.info("Clicked Save!")
self.set_image_title_link()
self.save_changes()
def on_import_tags_clicked(self):
print("Clicked Import!")
logging.info("Clicked Import!")
dialog = TagImportDialog(self)
if len(self.get_image_link_from_line()) == 0 or self.get_image_link_from_line() == '(Unknown)':
url = LinkGenerator.get_instance().construct_link(self.curr_file_name,
@ -765,7 +766,7 @@ class Window(QtWidgets.QMainWindow):
self.set_tag_list(self.curr_tags)
def on_next_clicked(self):
print("Clicked Next!")
logging.info("Clicked Next!")
if not self.check_save_changes():
return
@ -783,7 +784,7 @@ class Window(QtWidgets.QMainWindow):
self.curr_image_title = self.ui.image_title_line.text()
def on_previous_clicked(self):
print("Clicked previous!")
logging.info("Clicked previous!")
if not self.check_save_changes():
return
@ -798,14 +799,15 @@ class Window(QtWidgets.QMainWindow):
self.on_tag_search_change()
def toggle_presence_docker(self):
print("Clicked presence docker button!")
if not self.presence_docker_open:
logging.info("Opened presence docker!")
self.presence_docker = PresenceDocker(self)
self.ui.presence_docker_layout.addWidget(self.presence_docker)
self.presence_docker.set_selected_presences_list(self.get_current_presences())
self.ui.presence_docker_button.setText(">")
self.presence_docker_open = True
else:
logging.info("Closed presence docker!")
self.presence_docker.setParent(None)
self.ui.presence_docker_button.setText("<")
@ -814,7 +816,7 @@ class Window(QtWidgets.QMainWindow):
self.presence_docker_open = False
def on_artnet_root_change_clicked(self):
print("Clicked changing ArtNet root!")
logging.info("Clicked changing ArtNet root!")
dialog = QtWidgets.QFileDialog(self, 'Choose new ArtNet root:')
dialog.setFileMode(QtWidgets.QFileDialog.Directory)
dialog.setOptions(QtWidgets.QFileDialog.ShowDirsOnly)
@ -823,7 +825,7 @@ class Window(QtWidgets.QMainWindow):
self.__main.change_root(directory)
def on_db_connection_change_clicked(self):
print("Clicked db connection change!")
logging.info("Clicked db connection change!")
dialog = DBDialog(self)
prev_db_data = self.__main.get_db_connection_details()
dialog.ui.user_line_edit.setText(prev_db_data["user"])
@ -840,11 +842,11 @@ class Window(QtWidgets.QMainWindow):
database=db_data["database"])
def on_tag_creation_clicked(self):
print("Clicked Tag Creation!")
logging.info("Clicked Tag Creation!")
dialog = TagModifyDialog(self, create_tag=True)
tag_data: dict = dialog.exec_()
print("Got Tag data", tag_data)
logging.debug("Got Tag data", tag_data)
if tag_data is None or len(tag_data.keys()) == 0: # got canceled?
return
@ -858,11 +860,11 @@ class Window(QtWidgets.QMainWindow):
self.on_tag_search_change()
def on_tag_deletion_clicked(self):
print("Clicked Tag Deletion!")
logging.info("Clicked Tag Deletion!")
dialog = TagSelectDialog(self, delete_tag=True)
tag = dialog.exec_()
print("Got Tag", tag)
logging.debug("Got Tag", tag)
if tag is None or len(tag) == 0:
return
@ -889,7 +891,7 @@ class Window(QtWidgets.QMainWindow):
edit_dialog.set_all_categories()
tag_data = edit_dialog.exec_()
print("Got Tag data", tag_data)
logging.debug("Got Tag data", tag_data)
if tag_data is None or len(tag_data.keys()) == 0:
return None
if len(tag_data["category"]) == 0:
@ -909,7 +911,7 @@ class Window(QtWidgets.QMainWindow):
return tag_data
def on_tag_edit_clicked(self):
print("Clicked Tag Editing!")
logging.info("Clicked Tag Editing!")
select_dialog = TagSelectDialog(self, delete_tag=False)
tag = select_dialog.exec_()
@ -930,7 +932,7 @@ class Window(QtWidgets.QMainWindow):
edit_dialog.set_all_categories()
tag_data = edit_dialog.exec_()
print("Got Tag data", tag_data)
logging.debug("Got Tag data", tag_data)
if tag_data is None or len(tag_data.keys()) == 0:
return
@ -954,7 +956,7 @@ class Window(QtWidgets.QMainWindow):
self.set_tag_list(self.curr_tags)
def on_tag_item_changed(self, item: QStandardItem):
print("Item {0} has changed!".format(item.text()))
logging.debug("Item {0} has changed!".format(item.text()))
if item.checkState() == Qt.Unchecked:
if item.text() in self.curr_tags:
self.curr_tags.remove(item.text())
@ -995,7 +997,7 @@ class Window(QtWidgets.QMainWindow):
def on_prev_unknown_image_clicked(self):
unknown_image_index = self.__main.get_prev_unknown_image()
print("Previous unknown image clicked!")
logging.info("Previous unknown image clicked!")
result = QtWidgets.QMessageBox.question(self, "Switch Image?",
"Do you really want to skip to image #{1} \"{0}\"?"
@ -1007,7 +1009,7 @@ class Window(QtWidgets.QMainWindow):
def on_next_unknown_image_clicked(self):
unknown_image_index = self.__main.get_next_unknown_image()
print("Next unknown image clicked!")
logging.info("Next unknown image clicked!")
result = QtWidgets.QMessageBox.question(self, "Switch Image?",
"Do you really want to skip to image #{1} \"{0}\"?"
@ -1019,7 +1021,7 @@ class Window(QtWidgets.QMainWindow):
def on_image_id_spinbox_changed(self, v: int):
if self.__tmp_imageid_spinbox == v:
print("SpinBox change detected!")
logging.info("SpinBox change detected!")
result = QtWidgets.QMessageBox.question(self, "Switch Image?",
"Do you really want to skip to image #{1} \"{0}\"?"
.format(self.__main.all_images[v],
@ -1031,26 +1033,26 @@ class Window(QtWidgets.QMainWindow):
self.__tmp_imageid_spinbox: int = v
def on_delete_image_clicked(self):
print("Delete clicked!")
logging.info("Delete clicked!")
art_hash = self.__main.get_md5_of_image(self.curr_art_path)
if self.__main.db_connection.get_art_by_hash(art_hash) is not None:
print("Delete on known image")
logging.debug("Delete on known image")
confirm_result = QtWidgets.QMessageBox.question(self, "Delete data?", "Do you really wish to delete all "
"data from the DB about this image?")
if confirm_result == QtWidgets.QMessageBox.Yes:
print(f"deleting image data of \"{self.curr_image_title}\"")
logging.info(f"deleting image data of \"{self.curr_image_title}\"")
self.__main.db_connection.remove_image(art_hash)
else:
return
else:
print("Delete on unknown image")
logging.debug("Delete on unknown image")
confirm_result = QtWidgets.QMessageBox.question(self, "Delete image?", "Do you really wish to delete this "
"image?")
if confirm_result == QtWidgets.QMessageBox.Yes:
print("deleting image file")
logging.info(f"deleting image file {self.curr_art_path}")
self.__main.delete_image(self.curr_art_path)
else:
return
@ -1058,11 +1060,11 @@ class Window(QtWidgets.QMainWindow):
self.__main.refresh_shown_image()
def on_link_label_activated(self, link: str):
print("Source link activated!", link)
logging.debug("Source link activated!", link)
QDesktopServices.openUrl(QUrl(link))
def on_image_author_label_activated(self, link: str):
print("Image author link activated!", link)
logging.debug("Image author link activated!", link)
QDesktopServices.openUrl(QUrl(link))
def on_description_change(self):

Loading…
Cancel
Save