Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: BraceException: Add torrent files with data: {u'session': u'DownloadStation', u'destination': u'Downloads/torrents/tv-serier', u'api': u'SYNO.DownloadStation.Task', u'version': u'1', u'method': u'create'}

### INFO
**Python Version**: `2.7.13 (default, Apr 20 2017, 12:13:37) [GCC 6.3.0]`
**Operating System**: `Linux-3.10.102-x86_64-with`
**Locale**: `None`
**Branch**: [master](../tree/master)
**Database**: `44.12`
**Commit**: pymedusa/Medusa@0c0a73583452f988c518adeafa75ee1f17987bdf
**Link to Log**: https://gist.github.com/321b46e5d21323bdc69e71468199d19e
### ERROR
<pre>
2018-10-30 21:10:12 ERROR    SEARCHQUEUE-FORCED-354531 :: [0c0a735] BraceMessage string formatting failed. Using representation instead.
Traceback (most recent call last):
  File "/app/medusa/<a href="../blob/0c0a73583452f988c518adeafa75ee1f17987bdf/medusa/logger/adapters/style.py#L53">medusa/logger/adapters/style.py</a>", line 53, in __str__
    return self.msg.format(*args)
KeyError: u"u'session'"
Traceback (most recent call last):
  File "/app/medusa/<a href="../blob/0c0a73583452f988c518adeafa75ee1f17987bdf/medusa/logger/adapters/style.py#L60">medusa/logger/adapters/style.py</a>", line 60, in __str__
    raise BraceException(self.msg)
BraceException: Add torrent files with data: {u'session': u'DownloadStation', u'destination': u'Downloads/torrents/tv-serier', u'api': u'SYNO.DownloadStation.Task', u'version': u'1', u'method': u'create'}
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:

### INFO
**Python Version**: `2.7.13 (default, Apr 20 2017, 12:13:37) [GCC 6.3.0]`
**Operating System**: `Linux-3.10.102-x86_64-with`
**Locale**: `None`
**Branch**: [master](../tree/master)
**Database**: `44.12`
**Commit**: pymedusa/Medusa@0c0a73583452f988c518adeafa75ee1f17987bdf
**Link to Log**: https://gist.github.com/932f5e8535d32b57e609152c7043047f
### ERROR
<pre>
2018-10-31 16:33:32 ERROR    SEARCHQUEUE-FORCED-354531 :: [0c0a735] BraceMessage string formatting failed. Using representation instead.
Traceback (most recent call last):
  File "/app/medusa/<a href="../blob/0c0a73583452f988c518adeafa75ee1f17987bdf/medusa/logger/adapters/style.py#L53">medusa/logger/adapters/style.py</a>", line 53, in __str__
    return self.msg.format(*args)
KeyError: u"u'session'"
Traceback (most recent call last):
  File "/app/medusa/<a href="../blob/0c0a73583452f988c518adeafa75ee1f17987bdf/medusa/logger/adapters/style.py#L60">medusa/logger/adapters/style.py</a>", line 60, in __str__
    raise BraceException(self.msg)
BraceException: Add torrent files with data: {u'session': u'DownloadStation', u'destination': u'Downloads/torrents/tv-serier', u'api': u'SYNO.DownloadStation.Task', u'version': u'1', u'method': u'create'}
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


Resolving patch:
diff --git a/medusa/clients/torrent/downloadstation_client.py b/medusa/clients/torrent/downloadstation_client.py
--- a/medusa/clients/torrent/downloadstation_client.py
+++ b/medusa/clients/torrent/downloadstation_client.py
@@ -9,6 +9,7 @@
 
 from __future__ import unicode_literals
 
+import json
 import logging
 import os
 import re
@@ -120,7 +121,7 @@ def _add_torrent_uri(self, result):
 
         if torrent_path:
             data['destination'] = torrent_path
-        log.debug('Add torrent URI with data: {}'.format(data))
+        log.debug('Add torrent URI with data: {0}'.format(json.dumps(data)))
         self._request(method='post', data=data)
         return self._check_response()
 
@@ -143,7 +144,7 @@ def _add_torrent_file(self, result):
 
         files = {'file': ('{name}.torrent'.format(name=result.name), result.content)}
 
-        log.debug('Add torrent files with data: {}'.format(data))
+        log.debug('Add torrent files with data: {0}'.format(json.dumps(data)))
         self._request(method='post', data=data, files=files)
         return self._check_response()
 


Test patch: