Skip to content

Commit f15287e

Browse files
committed
clemy.py 0.1.2: make script compatible with Python 3
1 parent 07f20bc commit f15287e

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

python/clemy.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,15 @@
2222
# Imports
2323
try:
2424
import weechat
25-
25+
IMPORT_OK = True
2626
except ImportError:
27-
import sys
28-
29-
print '\nError: Script must be run under Weechat.\n'
30-
31-
sys.exit(2)
27+
print('Error: Script must be run under Weechat.')
28+
IMPORT_OK = False
3229

3330
import dbus
3431

3532

36-
weechat.register('clemy', "Your mommy's boyfriend", '0.1.1', 'GPLv3', 'Control yo Clementine like boom-blaka!', '', '')
37-
38-
err_message = '\nSomething silly just happend. Make sure Clementine is running mah dude.'
33+
err_message = '\nSomething silly just happend. Make sure Clementine is running mah dude.'
3934

4035

4136
def help():
@@ -187,9 +182,11 @@ def weechat_np(data, buffer, args):
187182
return weechat.WEECHAT_RC_OK
188183

189184

190-
weechat.hook_command('clemynp', 'Get/output now playing info', '', '', '', 'weechat_np', '')
191-
weechat.hook_command('clemy', 'Control Clementine', "[play] | [pause] | [next] | [prev] | [stop] | [vol+] | [vol-] | [vol+by <n>] | [vol-by <n>] | [playtrack <n>] | [help]",
192-
"""
185+
if __name__ == "__main__" and IMPORT_OK:
186+
weechat.register('clemy', "Your mommy's boyfriend", '0.1.2', 'GPLv3', 'Control yo Clementine like boom-blaka!', '', '')
187+
weechat.hook_command('clemynp', 'Get/output now playing info', '', '', '', 'weechat_np', '')
188+
weechat.hook_command('clemy', 'Control Clementine', "[play] | [pause] | [next] | [prev] | [stop] | [vol+] | [vol-] | [vol+by <n>] | [vol-by <n>] | [playtrack <n>] | [help]",
189+
"""
193190
play: Play song.
194191
pause: Pause song.
195192
next: Play next song.

0 commit comments

Comments
 (0)