GoogleCodeArchives / xbtweet

Automatically exported from code.google.com/p/xbtweet
0 stars 0 forks source link

If bitly fails, the whole script crashes. #23

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When bitly failed to create URL for some reason (i have no clue) the entire
script crashed.

See debuglog:
03:10:21 T:3704 M:979308544  NOTICE: CheckIfPlayingAndTweet_Music()
03:10:21 T:3704 M:979308544  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbTweet\default.py", line 116, in
CheckIfPlayingAndTweet_Music
03:10:21 T:3704 M:979308544  NOTICE: short = bitlyAPI.shorten(imdburl)
03:10:21 T:3704 M:979308544  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbtweet\resources\lib\bitly.py",
line 64, in shorten
03:10:21 T:3704 M:979304448  NOTICE: self._CheckForError(json)
03:10:21 T:3704 M:979304448  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbtweet\resources\lib\bitly.py",
line 170, in _CheckForError
03:10:21 T:3704 M:979300352  NOTICE: raise BitlyError,
data['results'][key]['errorMessage']
03:10:21 T:3704 M:979300352  NOTICE: bitly
03:10:21 T:3704 M:979300352  NOTICE: .
03:10:21 T:3704 M:979300352  NOTICE: BitlyError
03:10:21 T:3704 M:979300352  NOTICE: :
03:10:21 T:3704 M:979300352  NOTICE: URL you tried to shorten was invalid.
03:10:21 T:3704 M:979300352   ERROR: Scriptresult: Error

After making an empty imdburl before assigning it, this is what I got in
the debuglog:
03:02:33 T:6032 M:1052471296  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbTweet\default.py", line 248, in ?
03:02:33 T:6032 M:1052475392  NOTICE: CheckIfPlayingAndTweet_Music()
03:02:33 T:6032 M:1052475392  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbTweet\default.py", line 114, in
CheckIfPlayingAndTweet_Music
03:02:33 T:6032 M:1052479488  NOTICE: short = bitlyAPI.shorten(imdburl)
03:02:33 T:6032 M:1052479488  NOTICE: UnboundLocalError
03:02:33 T:6032 M:1052479488  NOTICE: :
03:02:33 T:6032 M:1052479488  NOTICE: local variable 'imdburl' referenced
before assignment
03:02:33 T:6032 M:1052479488   ERROR: Scriptresult: Error

Original issue reported on code.google.com by Gunnar.Norin@gmail.com on 11 Jan 2010 at 2:15

GoogleCodeExporter commented 8 years ago
Argh, should really go to bed, the two debug log snippets are mixed up.. This 
is correct:

Bit.ly fails:
03:02:33 T:6032 M:1052471296  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbTweet\default.py", line 248, in ?
03:02:33 T:6032 M:1052475392  NOTICE: CheckIfPlayingAndTweet_Music()
03:02:33 T:6032 M:1052475392  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbTweet\default.py", line 114, in
CheckIfPlayingAndTweet_Music
03:02:33 T:6032 M:1052479488  NOTICE: short = bitlyAPI.shorten(imdburl)
03:02:33 T:6032 M:1052479488  NOTICE: UnboundLocalError
03:02:33 T:6032 M:1052479488  NOTICE: :
03:02:33 T:6032 M:1052479488  NOTICE: local variable 'imdburl' referenced
before assignment
03:02:33 T:6032 M:1052479488   ERROR: Scriptresult: Error

---------------------------------------------------------------------------

After making an empty imdburl before assigning it, this is what I got in
the debuglog:
03:10:21 T:3704 M:979308544  NOTICE: CheckIfPlayingAndTweet_Music()
03:10:21 T:3704 M:979308544  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbTweet\default.py", line 116, in
CheckIfPlayingAndTweet_Music
03:10:21 T:3704 M:979308544  NOTICE: short = bitlyAPI.shorten(imdburl)
03:10:21 T:3704 M:979308544  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbtweet\resources\lib\bitly.py",
line 64, in shorten
03:10:21 T:3704 M:979304448  NOTICE: self._CheckForError(json)
03:10:21 T:3704 M:979304448  NOTICE:   File
"F:\totalcmd\plugins\extra\XBMC\scripts\xbtweet\resources\lib\bitly.py",
line 170, in _CheckForError
03:10:21 T:3704 M:979300352  NOTICE: raise BitlyError,
data['results'][key]['errorMessage']
03:10:21 T:3704 M:979300352  NOTICE: bitly
03:10:21 T:3704 M:979300352  NOTICE: .
03:10:21 T:3704 M:979300352  NOTICE: BitlyError
03:10:21 T:3704 M:979300352  NOTICE: :
03:10:21 T:3704 M:979300352  NOTICE: URL you tried to shorten was invalid.
03:10:21 T:3704 M:979300352   ERROR: Scriptresult: Error

Original comment by Gunnar.Norin@gmail.com on 11 Jan 2010 at 2:17

GoogleCodeExporter commented 8 years ago
Fix for this:

use try, except for bitly generation

Original comment by Gunnar.Norin@gmail.com on 11 Jan 2010 at 2:26

Attachments:

GoogleCodeExporter commented 8 years ago
Patched.

Original comment by itay.weinberger on 11 Jan 2010 at 7:56

GoogleCodeExporter commented 8 years ago

Original comment by itay.weinberger on 11 Jan 2010 at 8:13