Skip to content

Commit

Permalink
Merge pull request #214 from jazzband/llybin-master
Browse files Browse the repository at this point in the history
1. grouping messages in sentry: https://www.python.org/dev/peps/pep-0…
  • Loading branch information
marianoeramirez authored May 8, 2020
2 parents a0300da + 3913b84 commit 1e9e24f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
31 changes: 16 additions & 15 deletions cities_light/management/commands/cities_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def handle(self, *args, **options):
self._clear_identity_maps()

if not os.path.exists(DATA_DIR):
self.logger.info('Creating %s' % DATA_DIR)
self.logger.info('Creating %s', DATA_DIR)
os.mkdir(DATA_DIR)

install_file_path = os.path.join(DATA_DIR, 'install_datetime')
Expand Down Expand Up @@ -180,20 +180,21 @@ def handle(self, *args, **options):
force_import = True

if not os.path.exists(install_file_path):
self.logger.info('Forced import of %s because data do not seem'
' to have installed successfuly yet, note that this is'
' equivalent to --force-import-all.' %
destination_file_name)
self.logger.info(
'Forced import of %s because data do not seem'
' to have installed successfuly yet, note that this is'
' equivalent to --force-import-all.',
destination_file_name)
force_import = True

if downloaded or force_import:
self.logger.info('Importing %s' % destination_file_name)
self.logger.info('Importing %s', destination_file_name)

if url in TRANSLATION_SOURCES:
if options.get('hack_translations', False):
if os.path.exists(translation_hack_path):
self.logger.debug(
'Using translation parsed data: %s' %
'Using translation parsed data: %s',
translation_hack_path)
continue

Expand Down Expand Up @@ -577,12 +578,12 @@ def city_import(self, items):

def translation_parse(self, items):
if not hasattr(self, 'translation_data'):
self.country_ids = set(Country.objects.values_list('geoname_id',
flat=True))
self.region_ids = set(Region.objects.values_list('geoname_id',
flat=True))
self.city_ids = set(City.objects.values_list('geoname_id',
flat=True))
self.country_ids = set(Country.objects.values_list(
'geoname_id', flat=True))
self.region_ids = set(Region.objects.values_list(
'geoname_id', flat=True))
self.city_ids = set(City.objects.values_list(
'geoname_id', flat=True))

self.translation_data = collections.OrderedDict((
(Country, {}),
Expand Down Expand Up @@ -683,12 +684,12 @@ def translation_import(self):
def save(self, model, force_insert=False, force_update=False):
try:
with transaction.atomic():
self.logger.debug('Saving %s' % model.name)
self.logger.debug('Saving %s', model.name)
model.save(
force_insert=force_insert,
force_update=force_update
)
except IntegrityError as e:
# Regarding %r see the https://code.djangoproject.com/ticket/20572
# Also related to http://bugs.python.org/issue2517
self.logger.warning('Saving %s failed: %r' % (model, e))
self.logger.warning('Saving %s failed: %r', model, e)
3 changes: 2 additions & 1 deletion cities_light/management/commands/cities_light_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def create_parser(self, *args, **kwargs):
parser.formatter_class = RawTextHelpFormatter
return parser

def add_arguments(self, parser):
@staticmethod
def add_arguments(parser):
parser.add_argument(
'subcommand',
type=str,
Expand Down

0 comments on commit 1e9e24f

Please sign in to comment.