Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
handle case when the user does not provide good login pass and client…
Browse files Browse the repository at this point in the history
…_* parms
  • Loading branch information
FoxMaSk committed Sep 24, 2017
1 parent 82f640c commit 001a1c8
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions th_wallabag/my_wallabag.py
Expand Up @@ -119,8 +119,11 @@ def new_wall(self, token):
us = UserService.objects.get(
user=self.user, name='ServiceWallabag')
finally:
return Wall(host=us.host, client_secret=us.client_secret,
client_id=us.client_id, token=us.token)
wall = None if bool(us.token) is False else Wall(
host=us.host,
client_secret=us.client_secret,
client_id=us.client_id, token=us.token)
return wall

def _create_entry(self, title, data, tags):
"""
Expand All @@ -131,22 +134,23 @@ def _create_entry(self, title, data, tags):
:return: boolean
"""
if data.get('link') and len(data.get('link')) > 0:
wall = self.new_wall(self.token)

wall = self.new_wall(self.token)
if wall is None:
err = 'the provided informations for Wallabag are boken - ' \
# wall is none when login/pass/client_* things are wrong
err = 'The provided informations for Wallabag are boken - ' \
'check you login/pass client_id and host'
logger.critical(err)
update_result(self.trigger_id, msg=err, status=False)
return False

try:
wall.post_entries(url=data.get('link').encode(),
title=title,
tags=(tags.lower()))
logger.debug('wallabag {} created'.format(data.get('link')))
status = True
except Exception as e:
status = False
else:
try:
wall.post_entries(url=data.get('link').encode(),
title=title,
tags=(tags.lower()))
logger.debug('wallabag {} created'.format(data.get('link')))
status = True
except Exception as e:
logger.critical('issue with something else that a token'
' link ? : {}'.format(data.get('link')))
logger.critical(e)
Expand Down

0 comments on commit 001a1c8

Please sign in to comment.