oneplus fix

This commit is contained in:
Cédric Leporcq 2021-08-24 07:36:35 +02:00
parent a45c11b216
commit 1a716f9b94
4 changed files with 19 additions and 9 deletions

View File

@ -6,7 +6,6 @@ import sys
from datetime import datetime
import click
from send2trash import send2trash
from ordigi import config
from ordigi import constants
@ -112,14 +111,15 @@ def _sort(debug, dry_run, destination, clean, copy, exclude_regex, filter_by_ext
# Initialize Db
db = Db(destination)
if 'Directory' in conf and 'day_begins' in conf['Directory']:
config_directory = conf['Directory']
day_begins = config_directory['day_begins']
if 'Path' in conf and 'day_begins' in conf['Path']:
config_directory = conf['Path']
day_begins = int(config_directory['day_begins'])
else:
day_begins = 0
filesystem = FileSystem(cache, day_begins, dry_run, exclude_regex_list,
filter_by_ext, logger, max_deep, mode, path_format)
import ipdb; ipdb.set_trace()
summary, has_errors = filesystem.sort_files(paths, destination, db,
remove_duplicates, ignore_tags)

View File

@ -26,7 +26,9 @@ def coordinates_by_name(name, db):
# If the name is not cached then we go ahead with an API lookup
geocoder = get_geocoder()
if geocoder == 'Nominatim':
locator = Nominatim(user_agent='myGeocoder')
# timeout = DEFAULT_SENTINEL
timeout = 10
locator = Nominatim(user_agent='myGeocoder', timeout=timeout)
geolocation_info = locator.geocode(name)
if geolocation_info is not None:
return {
@ -135,14 +137,19 @@ def lookup_osm(lat, lon, logger=logging.getLogger()):
prefer_english_names = get_prefer_english_names()
try:
locator = Nominatim(user_agent='myGeocoder')
timeout = 10
locator = Nominatim(user_agent='myGeocoder', timeout=timeout)
coords = (lat, lon)
if(prefer_english_names):
lang='en'
else:
lang='local'
return locator.reverse(coords, language=lang).raw
except geopy.exc.GeocoderUnavailable as e:
locator_reverse = locator.reverse(coords, language=lang)
if locator_reverse is not None:
return locator_reverse.raw
else:
return None
except geopy.exc.GeocoderUnavailable or geopy.exc.GeocoderServiceError as e:
logger.error(e)
return None
# Fix *** TypeError: `address` must not be None

View File

@ -5,6 +5,7 @@ Media :class:`Media` class to get file metadata
import logging
import mimetypes
import os
import six
# load modules
from dateutil.parser import parse
@ -147,7 +148,8 @@ class Media():
value = re.sub(regex , r'\g<1>-\g<2>-\g<3>', value)
return parse(value)
except BaseException or dateutil.parser._parser.ParserError as e:
self.logger.error(e)
self.logger.error(e, value)
import ipdb; ipdb.set_trace()
return None
def get_coordinates(self, key, value):

View File

@ -153,6 +153,7 @@ class TestFilesystem:
for mode in 'copy', 'move':
filesystem = FileSystem(path_format=self.path_format, mode=mode)
# copy mode
import ipdb; ipdb.set_trace()
src_path = Path(self.src_paths, 'photo.png')
dest_path = Path(tmp_path,'photo_copy.png')
src_checksum = filesystem.checksum(src_path)