|
a |
|
b/rdpl2stream/radiotray.py |
|
|
1 |
#!/usr/bin/env python
|
|
|
2 |
# -*- coding: utf-8 -*-
|
|
|
3 |
|
|
|
4 |
import dbus
|
|
|
5 |
import sys, os, string
|
|
|
6 |
from RadioTray import RadioTray
|
|
|
7 |
from dbus import DBusException
|
|
|
8 |
from dbus.mainloop.glib import threads_init
|
|
|
9 |
|
|
|
10 |
threads_init()
|
|
|
11 |
current_path = os.path.realpath(__file__)
|
|
|
12 |
basedir = os.path.dirname(os.path.realpath(__file__))
|
|
|
13 |
if not os.path.exists(os.path.join(basedir, "radiotray.py")):
|
|
|
14 |
if os.path.exists(os.path.join(os.getcwd(), "radiotray.py")):
|
|
|
15 |
basedir = os.getcwd()
|
|
|
16 |
sys.path.insert(0, basedir)
|
|
|
17 |
os.chdir(basedir)
|
|
|
18 |
|
|
|
19 |
def main(argv):
|
|
|
20 |
if(len(argv) == 1):
|
|
|
21 |
print "Trying to load URL: " + argv[0]
|
|
|
22 |
|
|
|
23 |
try:
|
|
|
24 |
bus = dbus.SessionBus()
|
|
|
25 |
radiotray = bus.get_object('net.sourceforge.radiotray', '/net/sourceforge/radiotray')
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
if argv[0] == '--config':
|
|
|
29 |
print "Radio Tray already running."
|
|
|
30 |
else:
|
|
|
31 |
print "Setting current radio through DBus..."
|
|
|
32 |
|
|
|
33 |
playUrl = radiotray.get_dbus_method('playUrl', 'net.sourceforge.radiotray')
|
|
|
34 |
playUrl(argv[0])
|
|
|
35 |
|
|
|
36 |
except DBusException:
|
|
|
37 |
RadioTray(argv[0])
|
|
|
38 |
else:
|
|
|
39 |
RadioTray()
|
|
|
40 |
|
|
|
41 |
if __name__ == "__main__":
|
|
|
42 |
main(sys.argv[1:])
|