mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
[#132 state:fixed] Added a debug mode preference as well as extra debug loggings.
This commit is contained in:
@@ -30,12 +30,16 @@ JOB_COPY = 'job_copy'
|
||||
JOB_DELETE = 'job_delete'
|
||||
|
||||
HAD_FIRST_LAUNCH_PREFERENCE = 'HadFirstLaunch'
|
||||
DEBUG_MODE_PREFERENCE = 'DebugMode'
|
||||
|
||||
class NoScannableFileError(Exception):
|
||||
pass
|
||||
|
||||
class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
def __init__(self, data_module, appdata):
|
||||
if self.get_default(DEBUG_MODE_PREFERENCE, False):
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
logging.debug("Debug mode enabled")
|
||||
RegistrableApplication.__init__(self, appid=1)
|
||||
Broadcaster.__init__(self)
|
||||
self.is_first_run = not self.get_default(HAD_FIRST_LAUNCH_PREFERENCE, False)
|
||||
|
||||
@@ -29,9 +29,7 @@ JOBID2TITLE = {
|
||||
|
||||
class DupeGuru(app.DupeGuru):
|
||||
def __init__(self, data_module, appdata_subdir):
|
||||
LOGGING_LEVEL = logging.DEBUG if self.get_default('debug') else logging.WARNING
|
||||
logging.basicConfig(level=LOGGING_LEVEL, format='%(levelname)s %(message)s')
|
||||
logging.debug('started in debug mode')
|
||||
logging.basicConfig(level=logging.WARNING, format='%(levelname)s %(message)s')
|
||||
install_exception_hook()
|
||||
appsupport = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0]
|
||||
appdata = op.join(appsupport, appdata_subdir)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
from xml.etree import ElementTree as ET
|
||||
import logging
|
||||
|
||||
from hscommon import io
|
||||
from hscommon.path import Path
|
||||
@@ -24,7 +25,7 @@ class AlreadyThereError(Exception):
|
||||
class InvalidPathError(Exception):
|
||||
"""The path being added is invalid"""
|
||||
|
||||
class Directories(object):
|
||||
class Directories:
|
||||
#---Override
|
||||
def __init__(self, fileclasses=[fs.File]):
|
||||
self._dirs = []
|
||||
@@ -63,7 +64,9 @@ class Directories(object):
|
||||
try:
|
||||
filepaths = set()
|
||||
if state != STATE_EXCLUDED:
|
||||
for file in fs.get_files(from_path, fileclasses=self.fileclasses):
|
||||
found_files = fs.get_files(from_path, fileclasses=self.fileclasses)
|
||||
logging.debug("Collected {} files in folder {}".format(len(found_files), str(from_path)))
|
||||
for file in found_files:
|
||||
file.is_ref = state == STATE_REFERENCE
|
||||
filepaths.add(file.path)
|
||||
yield file
|
||||
|
||||
@@ -66,6 +66,7 @@ class Scanner:
|
||||
ScanType.Tag: lambda f: [engine.getwords(str(getattr(f, attrname))) for attrname in SCANNABLE_TAGS if attrname in self.scanned_tags],
|
||||
}[self.scan_type]
|
||||
for f in j.iter_with_progress(files, tr("Read metadata of %d/%d files")):
|
||||
logging.debug("Reading metadata of {}".format(str(f.path)))
|
||||
f.words = func(f)
|
||||
return engine.getmatches(files, j=j, **kw)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user