Drop python2 support.

Update for PyTQt.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/35/head
Slávek Banko 1 year ago
parent 5f01cbb7f8
commit 9be5499101
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -4,7 +4,7 @@
# Config dialog for alarm script # Config dialog for alarm script
# (c) 2005 Mark Kretschmann <markey@web.de> # (c) 2005 Mark Kretschmann <markey@web.de>
# #
# Depends on: Python 2.2, PyQt # Depends on: Python 3, PyTQt
############################################################################ ############################################################################
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -14,42 +14,42 @@
# #
############################################################################ ############################################################################
from ConfigParser import * from configparser import *
import Queue import queue
import os.path import os.path
import sys import sys
import threading import threading
from os import * from os import *
try: try:
from qt import * from PyTQt.qt import *
except: except:
popen( "kdialog --sorry 'PyQt (Qt bindings for Python) is required for this script.'" ) popen( "kdialog --sorry 'PyTQt (TQt bindings for Python) is required for this script.'" )
raise raise
class ConfigDialog( QDialog ): class ConfigDialog( TQDialog ):
def __init__( self ): def __init__( self ):
QDialog.__init__( self ) TQDialog.__init__( self )
self.setWFlags( Qt.WDestructiveClose ) self.setWFlags( TQt.WDestructiveClose )
self.setCaption( "Alarm Script - Amarok" ) self.setCaption( "Alarm Script - Amarok" )
self.lay = QHBoxLayout( self ) self.lay = TQHBoxLayout( self )
self.vbox = QVBox( self ) self.vbox = TQVBox( self )
self.lay.addWidget( self.vbox ) self.lay.addWidget( self.vbox )
self.htopbox = QHBox( self.vbox ) self.htopbox = TQHBox( self.vbox )
QLabel( "Alarm time: ", self.htopbox ) TQLabel( "Alarm time: ", self.htopbox )
self.timeEdit = QTimeEdit( self.htopbox ) self.timeEdit = TQTimeEdit( self.htopbox )
self.hbox = QHBox( self.vbox ) self.hbox = TQHBox( self.vbox )
self.ok = QPushButton( self.hbox ) self.ok = TQPushButton( self.hbox )
self.ok.setText( "Ok" ) self.ok.setText( "Ok" )
self.cancel = QPushButton( self.hbox ) self.cancel = TQPushButton( self.hbox )
self.cancel.setText( "Cancel" ) self.cancel.setText( "Cancel" )
self.cancel.setDefault( True ) self.cancel.setDefault( True )
@ -59,11 +59,11 @@ class ConfigDialog( QDialog ):
self.adjustSize() self.adjustSize()
def __del__( self ): def __del__( self ):
print "ConfigDialog dtor" print("ConfigDialog dtor")
def save( self ): def save( self ):
wakeTime = str( self.timeEdit.time().toString() ) wakeTime = str( self.timeEdit.time().toString() )
print wakeTime print(wakeTime)
self.file = file( "alarmrc", 'w' ) self.file = file( "alarmrc", 'w' )
@ -76,24 +76,24 @@ class ConfigDialog( QDialog ):
self.accept() self.accept()
class Alarm( QApplication ): class Alarm( TQApplication ):
def __init__( self, args ): def __init__( self, args ):
QApplication.__init__( self, args ) TQApplication.__init__( self, args )
self.queue = Queue.Queue() self.queue = queue.Queue()
self.startTimer( 100 ) self.startTimer( 100 )
self.t = threading.Thread( target = self.readStdin ) self.t = threading.Thread( target = self.readStdin )
self.t.start() self.t.start()
self.alarmTimer = QTimer() self.alarmTimer = TQTimer()
self.connect( self.alarmTimer, SIGNAL( "timeout()" ), self.wakeup ) self.connect( self.alarmTimer, SIGNAL( "timeout()" ), self.wakeup )
self.readSettings() self.readSettings()
def __del__( self ): def __del__( self ):
print "Alarm dtor" print("Alarm dtor")
def wakeup( self ): def wakeup( self ):
popen( "dcop amarok player play" ) popen( "dcop amarok player play" )
@ -106,10 +106,10 @@ class Alarm( QApplication ):
try: try:
timestr = config.get( "General", "alarmtime" ) timestr = config.get( "General", "alarmtime" )
print "Alarm Time: " + timestr print("Alarm Time: " + timestr)
time = QTime.fromString( timestr ) time = TQTime.fromString( timestr )
secondsleft = QTime.currentTime().secsTo( time ) secondsleft = TQTime.currentTime().secsTo( time )
if secondsleft > 0: if secondsleft > 0:
self.alarmTimer.start( secondsleft * 1000, True ) self.alarmTimer.start( secondsleft * 1000, True )
@ -137,14 +137,14 @@ class Alarm( QApplication ):
def timerEvent( self, event ): def timerEvent( self, event ):
if not self.queue.empty(): if not self.queue.empty():
string = QString( self.queue.get_nowait() ) eventStr = TQString( self.queue.get_nowait() )
print "[Alarm Script] Received notification: " + str( string ) print("[Alarm Script] Received notification: " + str( eventStr ))
if string.contains( "configure" ): if eventStr.contains( "configure" ):
self.configure() self.configure()
def configure( self ): def configure( self ):
print "Alarm Script: configuration" print("Alarm Script: configuration")
self.dia = ConfigDialog() self.dia = ConfigDialog()
self.dia.show() self.dia.show()

@ -7,7 +7,7 @@
# #
# (c) 2005 Leo Franchi <lfranchi@gmail.com> # (c) 2005 Leo Franchi <lfranchi@gmail.com>
# #
# Depends on: Python 2.2, PyQt # Depends on: Python 3, PyTQt
############################################################################ ############################################################################
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -17,7 +17,7 @@
# #
############################################################################ ############################################################################
import ConfigParser import configparser
import os import os
import sys import sys
import threading import threading
@ -25,9 +25,9 @@ import signal
from time import sleep from time import sleep
try: try:
from qt import * from TQt.qt import *
except: except:
os.popen( "kdialog --sorry 'PyQt (Qt bindings for Python) is required for this script.'" ) os.popen( "kdialog --sorry 'PyTQt (TQt bindings for Python) is required for this script.'" )
raise raise
@ -35,34 +35,34 @@ except:
debug_prefix = "LiveCD Remastering" debug_prefix = "LiveCD Remastering"
class ConfigDialog ( QDialog ): class ConfigDialog ( TQDialog ):
""" Configuration widget """ """ Configuration widget """
def __init__( self ): def __init__( self ):
QDialog.__init__( self ) TQDialog.__init__( self )
self.setWFlags( Qt.WDestructiveClose ) self.setWFlags( TQt.WDestructiveClose )
self.setCaption("Amarok Live! Configuration") self.setCaption("Amarok Live! Configuration")
self.lay = QGridLayout( self, 3, 2) self.lay = TQGridLayout( self, 3, 2)
self.lay.addColSpacing( 0, 300 ) self.lay.addColSpacing( 0, 300 )
self.isopath = QLineEdit( self ) self.isopath = TQLineEdit( self )
self.isopath.setText( "Path to Amarok Live! iso" ) self.isopath.setText( "Path to Amarok Live! iso" )
self.tmppath = QLineEdit( self ) self.tmppath = TQLineEdit( self )
self.tmppath.setText( "Temporary directory used, 2.5gb free needed" ) self.tmppath.setText( "Temporary directory used, 2.5gb free needed" )
self.lay.addWidget( self.isopath, 0, 0 ) self.lay.addWidget( self.isopath, 0, 0 )
self.lay.addWidget( self.tmppath, 1, 0 ) self.lay.addWidget( self.tmppath, 1, 0 )
self.isobutton = QPushButton( self ) self.isobutton = TQPushButton( self )
self.isobutton.setText("Browse..." ) self.isobutton.setText("Browse..." )
self.tmpbutton = QPushButton( self ) self.tmpbutton = TQPushButton( self )
self.tmpbutton.setText("Browse..." ) self.tmpbutton.setText("Browse..." )
self.cancel = QPushButton( self ) self.cancel = TQPushButton( self )
self.cancel.setText( "Cancel" ) self.cancel.setText( "Cancel" )
self.ok = QPushButton( self ) self.ok = TQPushButton( self )
self.ok.setText( "Ok" ) self.ok.setText( "Ok" )
self.lay.addWidget( self.isobutton, 0, 1 ) self.lay.addWidget( self.isobutton, 0, 1 )
@ -82,11 +82,11 @@ class ConfigDialog ( QDialog ):
path = None path = None
try: try:
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
config.read( "remasterrc" ) config.read( "remasterrc" )
path = config.get( "General", "path" ) path = config.get( "General", "path" )
iso = config.get( "General", "iso") iso = config.get( "General", "iso")
if not path == "": self.tmppath.setText(path) if not path == "": self.tmppath.setText(path)
if not iso == "": self.isopath.setText(iso) if not iso == "": self.isopath.setText(iso)
except: except:
@ -97,7 +97,7 @@ class ConfigDialog ( QDialog ):
def save( self ): def save( self ):
""" Saves configuration to file """ """ Saves configuration to file """
self.file = file( "remasterrc", 'w' ) self.file = file( "remasterrc", 'w' )
self.config = ConfigParser.ConfigParser() self.config = configparser.ConfigParser()
self.config.add_section( "General" ) self.config.add_section( "General" )
self.config.set( "General", "path", self.tmppath.text() ) self.config.set( "General", "path", self.tmppath.text() )
self.config.set( "General", "iso", self.isopath.text() ) self.config.set( "General", "iso", self.isopath.text() )
@ -109,7 +109,7 @@ class ConfigDialog ( QDialog ):
def clear(): def clear():
self.file = file( "remasterrc", 'w' ) self.file = file( "remasterrc", 'w' )
self.config = ConfigParser.ConfigParser() self.config = configparser.ConfigParser()
self.config.add_section( "General" ) self.config.add_section( "General" )
self.config.set( "General", "path", "" ) self.config.set( "General", "path", "" )
self.config.set( "General", "iso", "" ) self.config.set( "General", "iso", "" )
@ -118,7 +118,7 @@ class ConfigDialog ( QDialog ):
def browseISO( self ): def browseISO( self ):
path = QFileDialog.getOpenFileName( "/home", path = TQFileDialog.getOpenFileName( "/home",
"CD Images (*.iso)", "CD Images (*.iso)",
self, self,
"iso choose dialogr", "iso choose dialogr",
@ -126,8 +126,8 @@ class ConfigDialog ( QDialog ):
self.isopath.setText( path ) self.isopath.setText( path )
def browsePath( self ): def browsePath( self ):
tmp = QFileDialog.getExistingDirectory( "/home", tmp = TQFileDialog.getExistingDirectory( "/home",
self, self,
"get tmp dir", "get tmp dir",
"Choose working directory", "Choose working directory",
@ -147,7 +147,7 @@ class ConfigDialog ( QDialog ):
path, iso = self.readConfig() path, iso = self.readConfig()
os.system("tdesu -t sh %s/amarok.live.remaster.part1.sh %s %s" % (scriptdir, path, iso)) os.system("tdesu -t sh %s/amarok.live.remaster.part1.sh %s %s" % (scriptdir, path, iso))
#os.wait() #os.wait()
print "got path: %s" % path print("got path: %s" % path)
@ -156,7 +156,7 @@ class ConfigDialog ( QDialog ):
path = "" path = ""
iso = "" iso = ""
try: try:
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
config.read("remasterrc") config.read("remasterrc")
path = config.get("General", "path") path = config.get("General", "path")
iso = config.get("General", "iso") iso = config.get("General", "iso")
@ -166,19 +166,18 @@ class ConfigDialog ( QDialog ):
class Notification( QCustomEvent ): class Notification( TQCustomEvent ):
__super_init = QCustomEvent.__init__ __super_init = TQCustomEvent.__init__
def __init__( self, str ): def __init__( self, str ):
self.__super_init(QCustomEvent.User + 1) self.__super_init(TQCustomEvent.User + 1)
self.string = str self.eventStr = str
class Remasterer( QApplication ): class Remasterer( TQApplication ):
""" The main application, also sets up the Qt event loop """ """ The main application, also sets up the TQt event loop """
def __init__( self, args ): def __init__( self, args ):
QApplication.__init__( self, args ) TQApplication.__init__( self, args )
debug( "Started." ) debug( "Started." )
# Start separate thread for reading data from stdin # Start separate thread for reading data from stdin
@ -187,13 +186,12 @@ class Remasterer( QApplication ):
self.readSettings() self.readSettings()
# ugly hack, thanks mp8 anyway # ugly hack, thanks mp8 anyway
os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Add playlist to livecd\"") os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Add playlist to livecd\"")
os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Add selected to livecd\"") os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Add selected to livecd\"")
os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Create Remastered CD\"") os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Create Remastered CD\"")
os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Clear Music on livecd\"") os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Clear Music on livecd\"")
os.system("dcop amarok script addCustomMenuItem \"Amarok live\" \"Add playlist to livecd\"") os.system("dcop amarok script addCustomMenuItem \"Amarok live\" \"Add playlist to livecd\"")
os.system("dcop amarok script addCustomMenuItem \"Amarok live\" \"Add selected to livecd\"") os.system("dcop amarok script addCustomMenuItem \"Amarok live\" \"Add selected to livecd\"")
os.system("dcop amarok script addCustomMenuItem \"Amarok live\" \"Create Remastered CD\"") os.system("dcop amarok script addCustomMenuItem \"Amarok live\" \"Create Remastered CD\"")
@ -234,22 +232,22 @@ class Remasterer( QApplication ):
def customEvent( self, notification ): def customEvent( self, notification ):
""" Handles notifications """ """ Handles notifications """
string = QString(notification.string) eventStr = TQString(notification.eventStr)
debug( "Received notification: " + str( string ) ) debug( "Received notification: " + str( eventStr ) )
if string.contains( "configure" ): if eventStr.contains( "configure" ):
self.configure() self.configure()
if string.contains( "stop"): if eventStr.contains( "stop" ):
self.stop() self.stop()
elif string.contains( "customMenuClicked" ): elif eventStr.contains( "customMenuClicked" ):
if "selected" in string: if eventStr.contains( "selected" ):
self.copyTrack( string ) self.copyTrack( eventStr )
elif "playlist" in string: elif eventStr.contains( "playlist" ):
self.copyPlaylist() self.copyPlaylist()
elif "Create" in string: elif eventStr.contains( "Create" ):
self.createCD() self.createCD()
elif "Clear" in string: elif eventStr.contains( "Clear" ):
self.clearCD() self.clearCD()
@ -264,7 +262,7 @@ class Remasterer( QApplication ):
#self.connect( self.dia, SIGNAL( "destroyed()" ), self.readSettings ) #self.connect( self.dia, SIGNAL( "destroyed()" ), self.readSettings )
def clearCD( self ): def clearCD( self ):
self.dia = ConfigDialog() self.dia = ConfigDialog()
path, iso = self.dia.readConfig() path, iso = self.dia.readConfig()
@ -274,7 +272,7 @@ class Remasterer( QApplication ):
stop() stop()
def stop( self ): def stop( self ):
fd = open("/tmp/amarok.stop", "w") fd = open("/tmp/amarok.stop", "w")
fd.write( "stopping") fd.write( "stopping")
fd.close() fd.close()
@ -297,22 +295,22 @@ class Remasterer( QApplication ):
os.system("dcop amarok playlist saveM3u '%s' false" % tmpfileloc) os.system("dcop amarok playlist saveM3u '%s' false" % tmpfileloc)
tmpfile = open(tmpfileloc) tmpfile = open(tmpfileloc)
import urllib import urllib.request, urllib.parse, urllib.error
files = "" files = ""
m3u = "" m3u = ""
for line in tmpfile.readlines(): for line in tmpfile.readlines():
if line[0] != "#": if line[0] != "#":
line = line.strip() line = line.strip()
# get filename # get filename
name = line.split("/")[-1] name = line.split("/")[-1]
#make url #make url
url = "file://" + urllib.quote(line) url = "file://" + urllib.parse.quote(line)
#make path on livecd #make path on livecd
livecdpath = "/music/" + name livecdpath = "/music/" + name
files += url + " " files += url + " "
@ -333,7 +331,7 @@ class Remasterer( QApplication ):
m3uOut.write(m3u) m3uOut.write(m3u)
m3uOut.close() m3uOut.close()
os.system("mv /tmp/amarok.live.%s.m3u %s/amarok.live/playlist/" % (suffix,path)) os.system("mv /tmp/amarok.live.%s.m3u %s/amarok.live/playlist/" % (suffix,path))
os.system("rm /tmp/amarok.live.%s.m3u" % suffix) os.system("rm /tmp/amarok.live.%s.m3u" % suffix)
@ -355,7 +353,7 @@ class Remasterer( QApplication ):
#trying out a new one #trying out a new one
#files = event.split(":")[-1][3:-2].replace("\"Amarok live!\" \"add to livecd\" ", "").split("\" \"") #files = event.split(":")[-1][3:-2].replace("\"Amarok live!\" \"add to livecd\" ", "").split("\" \"")
#and another #and another
files = event.replace("customMenuClicked: Amarok live Add selected to livecd", "").split() files = event.replace("customMenuClicked: Amarok live Add selected to livecd", "").split()
allfiles = "" allfiles = ""
@ -365,7 +363,7 @@ class Remasterer( QApplication ):
os.system("kfmclient copy %s file://%s/amarok.live/music/" % (allfiles, path)) os.system("kfmclient copy %s file://%s/amarok.live/music/" % (allfiles, path))
def createCD( self ): def createCD( self ):
self.dia = ConfigDialog() self.dia = ConfigDialog()
path,iso = self.dia.readConfig() path,iso = self.dia.readConfig()
if path == "": if path == "":
@ -394,7 +392,7 @@ def onSignal( signum, stackframe ):
fd.write( "stopping") fd.write( "stopping")
fd.close() fd.close()
print 'STOPPING' print('STOPPING')
os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Add playlist to livecd\"") os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Add playlist to livecd\"")
os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Add selected to livecd\"") os.system("dcop amarok script removeCustomMenuItem \"Amarok live\" \"Add selected to livecd\"")
@ -405,7 +403,7 @@ def onSignal( signum, stackframe ):
def debug( message ): def debug( message ):
""" Prints debug message to stdout """ """ Prints debug message to stdout """
print debug_prefix + " " + message print(debug_prefix + " " + message)
def main(): def main():
app = Remasterer( sys.argv ) app = Remasterer( sys.argv )
@ -420,7 +418,7 @@ if __name__ == "__main__":
mainapp = threading.Thread(target=main) mainapp = threading.Thread(target=main)
mainapp.start() mainapp.start()
signal.signal(15, onSignal) signal.signal(15, onSignal)
print signal.getsignal(15) print(signal.getsignal(15))
while 1: sleep(120) while 1: sleep(120)
#main( sys.argv ) #main( sys.argv )

@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301 USA
""" """
""" patch for meta-service (_services._dns-sd._udp) publishing """ """ patch for meta-service (_services._dns-sd._udp) publishing """
@ -87,6 +87,7 @@ import socket
import threading import threading
import select import select
import traceback import traceback
from functools import reduce
__all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"] __all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"]
@ -103,7 +104,7 @@ _LISTENER_TIME = 200
_BROWSER_TIME = 500 _BROWSER_TIME = 500
# Some DNS constants # Some DNS constants
_MDNS_ADDR = '224.0.0.251' _MDNS_ADDR = '224.0.0.251'
_MDNS_PORT = 5353; _MDNS_PORT = 5353;
_DNS_PORT = 53; _DNS_PORT = 53;
@ -212,7 +213,7 @@ class DNSEntry(object):
"""A DNS entry""" """A DNS entry"""
def __init__(self, name, type, clazz): def __init__(self, name, type, clazz):
self.key = string.lower(name) self.key = name.lower()
self.name = name self.name = name
self.type = type self.type = type
self.clazz = clazz & _CLASS_MASK self.clazz = clazz & _CLASS_MASK
@ -821,7 +822,7 @@ class DNSCache(object):
"""Returns a list of all entries""" """Returns a list of all entries"""
def add(x, y): return x+y def add(x, y): return x+y
try: try:
return reduce(add, self.cache.values()) return reduce(add, list(self.cache.values()))
except: except:
return [] return []
@ -870,7 +871,7 @@ class Engine(threading.Thread):
def getReaders(self): def getReaders(self):
result = [] result = []
self.condition.acquire() self.condition.acquire()
result = self.readers.keys() result = list(self.readers.keys())
self.condition.release() self.condition.release()
return result return result
@ -1008,7 +1009,7 @@ class ServiceBrowser(threading.Thread):
if self.nextTime <= now: if self.nextTime <= now:
out = DNSOutgoing(_FLAGS_QR_QUERY) out = DNSOutgoing(_FLAGS_QR_QUERY)
out.addQuestion(DNSQuestion(self.type, _TYPE_PTR, _CLASS_IN)) out.addQuestion(DNSQuestion(self.type, _TYPE_PTR, _CLASS_IN))
for record in self.services.values(): for record in list(self.services.values()):
if not record.isExpired(now): if not record.isExpired(now):
out.addAnswerAtTime(record, now) out.addAnswerAtTime(record, now)
self.zeroconf.send(out) self.zeroconf.send(out)
@ -1335,7 +1336,7 @@ class Zeroconf(object):
changed if needed to make it unique on the network.""" changed if needed to make it unique on the network."""
self.checkService(info) self.checkService(info)
self.services[info.name.lower()] = info self.services[info.name.lower()] = info
if self.servicetypes.has_key(info.type): if info.type in self.servicetypes:
self.servicetypes[info.type]+=1 self.servicetypes[info.type]+=1
else: else:
self.servicetypes[info.type]=1 self.servicetypes[info.type]=1
@ -1387,7 +1388,7 @@ class Zeroconf(object):
def unregisterAllServices(self): def unregisterAllServices(self):
"""Unregister all registered services.""" """Unregister all registered services."""
print 'Unregistering ',len(self.services),' services' print('Unregistering ',len(self.services),' services')
if len(self.services) > 0: if len(self.services) > 0:
now = currentTimeMillis() now = currentTimeMillis()
nextTime = now nextTime = now
@ -1398,7 +1399,7 @@ class Zeroconf(object):
now = currentTimeMillis() now = currentTimeMillis()
continue continue
out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA) out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
for info in self.services.values(): for info in list(self.services.values()):
out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR, _CLASS_IN, 0, info.name), 0) out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR, _CLASS_IN, 0, info.name), 0)
out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV, _CLASS_IN, 0, info.priority, info.weight, info.port, info.server), 0) out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV, _CLASS_IN, 0, info.priority, info.weight, info.port, info.server), 0)
out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN, 0, info.text), 0) out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN, 0, info.text), 0)
@ -1495,11 +1496,11 @@ class Zeroconf(object):
for question in msg.questions: for question in msg.questions:
if question.type == _TYPE_PTR: if question.type == _TYPE_PTR:
if question.name == "_services._dns-sd._udp.local.": if question.name == "_services._dns-sd._udp.local.":
for stype in self.servicetypes.keys(): for stype in list(self.servicetypes.keys()):
if out is None: if out is None:
out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA) out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
out.addAnswer(msg, DNSPointer("_services._dns-sd._udp.local.", _TYPE_PTR, _CLASS_IN, _DNS_TTL, stype)) out.addAnswer(msg, DNSPointer("_services._dns-sd._udp.local.", _TYPE_PTR, _CLASS_IN, _DNS_TTL, stype))
for service in self.services.values(): for service in list(self.services.values()):
if question.name == service.type: if question.name == service.type:
if out is None: if out is None:
out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA) out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
@ -1511,7 +1512,7 @@ class Zeroconf(object):
# Answer A record queries for any service addresses we know # Answer A record queries for any service addresses we know
if question.type == _TYPE_A or question.type == _TYPE_ANY: if question.type == _TYPE_A or question.type == _TYPE_ANY:
for service in self.services.values(): for service in list(self.services.values()):
if service.server == question.name.lower(): if service.server == question.name.lower():
out.addAnswer(msg, DNSAddress(question.name, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address)) out.addAnswer(msg, DNSAddress(question.name, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address))
@ -1544,10 +1545,10 @@ class Zeroconf(object):
def close(self): def close(self):
"""Ends the background threads, and prevent this instance from """Ends the background threads, and prevent this instance from
servicing further queries.""" servicing further queries."""
print 'in close' print('in close')
if globals()['_GLOBAL_DONE'] == 0: if globals()['_GLOBAL_DONE'] == 0:
globals()['_GLOBAL_DONE'] = 1 globals()['_GLOBAL_DONE'] = 1
print 'closing globals' print('closing globals')
self.notifyAll() self.notifyAll()
self.engine.notify() self.engine.notify()
self.unregisterAllServices() self.unregisterAllServices()
@ -1558,21 +1559,21 @@ class Zeroconf(object):
# query (for Zoe), and service unregistration. # query (for Zoe), and service unregistration.
if __name__ == '__main__': if __name__ == '__main__':
print "Multicast DNS Service Discovery for Python, version", __version__ print("Multicast DNS Service Discovery for Python, version", __version__)
r = Zeroconf() r = Zeroconf()
print "1. Testing registration of a service..." print("1. Testing registration of a service...")
desc = {'version':'0.10','a':'test value', 'b':'another value'} desc = {'version':'0.10','a':'test value', 'b':'another value'}
info = ServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local.", socket.inet_aton("127.0.0.1"), 1234, 0, 0, desc) info = ServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local.", socket.inet_aton("127.0.0.1"), 1234, 0, 0, desc)
print " Registering service..." print(" Registering service...")
r.registerService(info) r.registerService(info)
print " Registration done." print(" Registration done.")
print "2. Testing query of service information..." print("2. Testing query of service information...")
print " Getting ZOE service:", str(r.getServiceInfo("_http._tcp.local.", "ZOE._http._tcp.local.")) print(" Getting ZOE service:", str(r.getServiceInfo("_http._tcp.local.", "ZOE._http._tcp.local.")))
print " Query done." print(" Query done.")
print "3. Testing query of own service..." print("3. Testing query of own service...")
print " Getting self:", str(r.getServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local.")) print(" Getting self:", str(r.getServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local.")))
print " Query done." print(" Query done.")
print "4. Testing unregister of service information..." print("4. Testing unregister of service information...")
r.unregisterService(info) r.unregisterService(info)
print " Unregister done." print(" Unregister done.")
r.close() r.close()

@ -16,7 +16,7 @@ class Track(object):
__Q_SLOTS__ = FIELDS __Q_SLOTS__ = FIELDS
def __init__(self, **kwargs): def __init__(self, **kwargs):
for key,value in kwargs.iteritems(): for key,value in kwargs.items():
setattr(self, key, value) setattr(self, key, value)

@ -9,8 +9,8 @@
License: GPL License: GPL
""" """
import SimpleHTTPServer import http.server
import BaseHTTPServer import http.server
from Playlist import Playlist from Playlist import Playlist
# the port number to listen to # the port number to listen to
@ -19,7 +19,7 @@ PORT = 4773
PLIST = None PLIST = None
class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): class RequestHandler(http.server.SimpleHTTPRequestHandler):
"""We need our own 'RequestHandler, to handle the requests, that arrive at """We need our own 'RequestHandler, to handle the requests, that arrive at
our server.""" our server."""
@ -35,7 +35,7 @@ def main():
"""main is the starting-point for our script.""" """main is the starting-point for our script."""
global PLIST global PLIST
PLIST = Playlist() PLIST = Playlist()
srv = BaseHTTPServer.HTTPServer(('',PORT),RequestHandler) srv = http.server.HTTPServer(('',PORT),RequestHandler)
srv.serve_forever() srv.serve_forever()

@ -10,7 +10,7 @@ def main():
stdin = os.popen("kdialog --getsaveurl %s"%(user.home)) stdin = os.popen("kdialog --getsaveurl %s"%(user.home))
dest = stdin.readline().strip()[5:] dest = stdin.readline().strip()[5:]
plist = Playlist() plist = Playlist()
print dest print(dest)
try: try:
f = open(dest, "w") f = open(dest, "w")
f.write(plist.toHtml()) f.write(plist.toHtml())

@ -4,7 +4,7 @@
# Python-Qt template script for Amarok # Python-Qt template script for Amarok
# (c) 2005 Mark Kretschmann <markey@web.de> # (c) 2005 Mark Kretschmann <markey@web.de>
# #
# Depends on: Python 2.2, PyQt # Depends on: Python 3, PyTQt
############################################################################ ############################################################################
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -14,7 +14,7 @@
# #
############################################################################ ############################################################################
import ConfigParser import configparser
import os import os
import sys import sys
import threading import threading
@ -22,9 +22,9 @@ import signal
from time import sleep from time import sleep
try: try:
from qt import * from PyTQt.qt import *
except: except:
os.popen( "kdialog --sorry 'PyQt (Qt bindings for Python) is required for this script.'" ) os.popen( "kdialog --sorry 'PyTQt (TQt bindings for Python) is required for this script.'" )
raise raise
@ -36,13 +36,13 @@ class ConfigDialog( QDialog ):
""" Configuration widget """ """ Configuration widget """
def __init__( self ): def __init__( self ):
QDialog.__init__( self ) TQDialog.__init__( self )
self.setWFlags( Qt.WDestructiveClose ) self.setWFlags( TQt.WDestructiveClose )
self.setCaption( "Test Script - Amarok" ) self.setCaption( "Test Script - Amarok" )
foo = None foo = None
try: try:
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
config.read( "testrc" ) config.read( "testrc" )
foo = config.get( "General", "foo" ) foo = config.get( "General", "foo" )
except: except:
@ -55,7 +55,7 @@ class ConfigDialog( QDialog ):
self.file = file( "testrc", 'w' ) self.file = file( "testrc", 'w' )
self.config = ConfigParser.ConfigParser() self.config = configparser.ConfigParser()
self.config.add_section( "General" ) self.config.add_section( "General" )
self.config.set( "General", "foo", foovar ) self.config.set( "General", "foo", foovar )
self.config.write( self.file ) self.config.write( self.file )
@ -64,17 +64,17 @@ class ConfigDialog( QDialog ):
self.accept() self.accept()
class Notification( QCustomEvent ): class Notification( TQCustomEvent ):
__super_init = QCustomEvent.__init__ __super_init = TQCustomEvent.__init__
def __init__( self, str ): def __init__( self, str ):
self.__super_init(QCustomEvent.User + 1) self.__super_init(TQCustomEvent.User + 1)
self.string = str self.eventStr = str
class Test( QApplication ): class Test( TQApplication ):
""" The main application, also sets up the Qt event loop """ """ The main application, also sets up the TQt event loop """
def __init__( self, args ): def __init__( self, args ):
QApplication.__init__( self, args ) TQApplication.__init__( self, args )
debug( "Started." ) debug( "Started." )
# Start separate thread for reading data from stdin # Start separate thread for reading data from stdin
@ -117,25 +117,25 @@ class Test( QApplication ):
def customEvent( self, notification ): def customEvent( self, notification ):
""" Handles notifications """ """ Handles notifications """
string = QString(notification.string) eventStr = TQString(notification.eventStr)
debug( "Received notification: " + str( string ) ) debug( "Received notification: " + str( eventStr ) )
if string.contains( "configure" ): if eventStr.contains( "configure" ):
self.configure() self.configure()
if string.contains( "engineStateChange: play" ): if eventStr.contains( "engineStateChange: play" ):
self.engineStatePlay() self.engineStatePlay()
if string.contains( "engineStateChange: idle" ): if eventStr.contains( "engineStateChange: idle" ):
self.engineStateIdle() self.engineStateIdle()
if string.contains( "engineStateChange: pause" ): if eventStr.contains( "engineStateChange: pause" ):
self.engineStatePause() self.engineStatePause()
if string.contains( "engineStateChange: empty" ): if eventStr.contains( "engineStateChange: empty" ):
self.engineStatePause() self.engineStatePause()
if string.contains( "trackChange" ): if eventStr.contains( "trackChange" ):
self.trackChange() self.trackChange()
# Notification callbacks. Implement these functions to react to specific notification # Notification callbacks. Implement these functions to react to specific notification
@ -174,7 +174,7 @@ class Test( QApplication ):
def debug( message ): def debug( message ):
""" Prints debug message to stdout """ """ Prints debug message to stdout """
print debug_prefix + " " + message print(debug_prefix + " " + message)
def main( ): def main( ):
app = Test( sys.argv ) app = Test( sys.argv )

@ -30,7 +30,7 @@ class Track(object):
max_field_value_lengths = [(0,"")] * len(FIELDS) max_field_value_lengths = [(0,"")] * len(FIELDS)
def __init__(self, **kwargs): def __init__(self, **kwargs):
for key,value in kwargs.iteritems(): for key,value in kwargs.items():
setattr(self, key, value) setattr(self, key, value)
@ -53,14 +53,14 @@ class Track(object):
index = 0 index = 0
# for f in self.__Q_SLOTS__ : # for f in self.__Q_SLOTS__ :
# print string.strip(f) # print f.strip()
for i in [getattr(self,f) for f in self.__Q_SLOTS__ ]: for i in [getattr(self,f) for f in self.__Q_SLOTS__ ]:
if len(string.strip(i)) > Track.max_field_value_lengths[index][0]: if len(i.strip()) > Track.max_field_value_lengths[index][0]:
Track.max_field_value_lengths[index] = (len(string.strip(i)),i) Track.max_field_value_lengths[index] = (len(i.strip()),i)
index += 1 index += 1
tr_style = '' tr_style = ''
tr_id = '' tr_id = ''
if style: if style:

@ -11,8 +11,8 @@
License: GPL License: GPL
""" """
import SimpleHTTPServer import http.server
import BaseHTTPServer import http.server
from Playlist import Playlist from Playlist import Playlist
import Globals import Globals
@ -63,8 +63,7 @@ class AmarokStatus:
if self.playState != -1: if self.playState != -1:
res = self.playState == self.EnginePlay res = self.playState == self.EnginePlay
else: else:
res = string.find(self.dcop_isplaying.result(), "true") >= 0 if "true" in self.dcop_isplaying.result():
if res:
self.playState = self.EnginePlay self.playState = self.EnginePlay
else: else:
self.playState = self.EnginePause self.playState = self.EnginePause
@ -85,7 +84,7 @@ class AmarokStatus:
def controlsEnabled(self): def controlsEnabled(self):
return self.allowControl return self.allowControl
class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): class RequestHandler(http.server.SimpleHTTPRequestHandler):
"""We need our own 'RequestHandler, to handle the requests, that arrive at """We need our own 'RequestHandler, to handle the requests, that arrive at
our server.""" our server."""
@ -144,10 +143,10 @@ class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
# abort a request that has already been completed # abort a request that has already been completed
# probably a refresh from the users browser # probably a refresh from the users browser
if qmap.has_key("reqid") and req_id == int(qmap["reqid"]): if "reqid" in qmap and req_id == int(qmap["reqid"]):
return 0 return 0
if qmap.has_key("action"): if "action" in qmap:
a = qmap["action"] a = qmap["action"]
if a == "stop": if a == "stop":
self._amarokStop() self._amarokStop()
@ -193,9 +192,9 @@ class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
# get the sessions last reqid # get the sessions last reqid
last_req_id = 0 last_req_id = 0
session_id = None session_id = None
if qmap.has_key("sesid"): if "sesid" in qmap:
session_id = qmap["sesid"] session_id = qmap["sesid"]
if REQ_IDS.has_key(session_id): if session_id in REQ_IDS:
last_req_id = REQ_IDS[session_id] last_req_id = REQ_IDS[session_id]
else: else:
REQ_IDS[session_id] = last_req_id REQ_IDS[session_id] = last_req_id
@ -229,15 +228,15 @@ class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
# Surely there must be a better way that this:) # Surely there must be a better way that this:)
# #
self.send_response(200) self.send_response(200)
if string.find(self.path, ".png") >= 0: if ".png" in self.path:
self.send_header("content-type","image/png") self.send_header("content-type","image/png")
self.end_headers() self.end_headers()
self._sendFile(self.path) self._sendFile(self.path)
elif string.find(self.path, ".js") >= 0: elif ".js" in self.path:
self.send_header("content-type","text/plain") self.send_header("content-type","text/plain")
self.end_headers() self.end_headers()
self._sendFile(self.path) self._sendFile(self.path)
elif string.find(self.path, ".css") >= 0: elif ".css" in self.path:
self.send_header("content-type","text/css") self.send_header("content-type","text/css")
self.end_headers() self.end_headers()
self._sendFile(self.path) self._sendFile(self.path)
@ -257,7 +256,7 @@ def main():
"""main is the starting-point for our script.""" """main is the starting-point for our script."""
global PLIST global PLIST
PLIST = Playlist() PLIST = Playlist()
srv = BaseHTTPServer.HTTPServer(('',Globals.PORT),RequestHandler) srv = http.server.HTTPServer(('',Globals.PORT),RequestHandler)
srv.serve_forever() srv.serve_forever()

@ -4,11 +4,11 @@
# (c) 2005 Jonas Drewsen <kde@xspect.dk> # (c) 2005 Jonas Drewsen <kde@xspect.dk>
# (c) 2006 Peter C. Ndikuwera <pndiku@gmail.com> # (c) 2006 Peter C. Ndikuwera <pndiku@gmail.com>
# #
# Depends on: Python 2.2, PyQt # Depends on: Python 3, PyTQt
# #
############################################################################ ############################################################################
# Based on # Based on
# Python-Qt template script for Amarok # PyTQt template script for Amarok
# (c) 2005 Mark Kretschmann <markey@web.de> # (c) 2005 Mark Kretschmann <markey@web.de>
# #
############################################################################ ############################################################################
@ -20,7 +20,7 @@
# #
############################################################################ ############################################################################
import ConfigParser import configparser
import os import os
import sys import sys
import socket import socket
@ -31,7 +31,7 @@ from time import sleep
import Globals import Globals
from Playlist import Playlist from Playlist import Playlist
import RequestHandler import RequestHandler
import BaseHTTPServer import http.server
from WebPublisher import * from WebPublisher import *
import time import time
@ -40,9 +40,9 @@ import time
import string import string
try: try:
from qt import * from PyTQt.qt import *
except: except:
os.popen( "kdialog --sorry 'PyQt (Qt bindings for Python) is required for this script.'" ) os.popen( "kdialog --sorry 'PyTQt (TQt bindings for Python) is required for this script.'" )
raise raise
@ -50,47 +50,47 @@ except:
debug_prefix = "[WebControl Script]" debug_prefix = "[WebControl Script]"
class ConfigDialog( QDialog ): class ConfigDialog( TQDialog ):
""" Configuration widget """ """ Configuration widget """
def __init__( self ): def __init__( self ):
QDialog.__init__( self ) TQDialog.__init__( self )
self.setWFlags( Qt.WDestructiveClose ) self.setWFlags( TQt.WDestructiveClose )
self.setCaption( "WebControl - Amarok" ) self.setCaption( "WebControl - Amarok" )
self.config = ConfigParser.ConfigParser() self.config = configparser.ConfigParser()
allowControl = RequestHandler.AmarokStatus.allowControl allowControl = RequestHandler.AmarokStatus.allowControl
publish = RequestHandler.AmarokStatus.publish publish = RequestHandler.AmarokStatus.publish
try: try:
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
config.read( "webcontrolrc" ) config.read( "webcontrolrc" )
allowControl = string.find(config.get( "General", "allowcontrol" ), "True") >= 0 allowControl = "True" in config.get( "General", "allowcontrol" )
publish = string.find(config.get( "General", "publish" ), "True") >= 0 publish = "True" in config.get( "General", "publish" )
except: except:
pass pass
self.lay = QHBoxLayout( self ) self.lay = TQHBoxLayout( self )
self.vbox = QVBox( self ) self.vbox = TQVBox( self )
self.lay.addWidget( self.vbox ) self.lay.addWidget( self.vbox )
self.hbox1 = QHBox( self.vbox ) self.hbox1 = TQHBox( self.vbox )
self.allowControl = QCheckBox( QString("Allow control"), self.hbox1 ) self.allowControl = TQCheckBox( TQString("Allow control"), self.hbox1 )
self.allowControl.setChecked(allowControl) self.allowControl.setChecked(allowControl)
self.hbox1 = QHBox( self.vbox ) self.hbox1 = TQHBox( self.vbox )
self.publish = QCheckBox( QString("Publish"), self.hbox1 ) self.publish = TQCheckBox( TQString("Publish"), self.hbox1 )
self.publish.setChecked(publish) self.publish.setChecked(publish)
self.hbox = QHBox( self.vbox ) self.hbox = TQHBox( self.vbox )
self.ok = QPushButton( self.hbox ) self.ok = TQPushButton( self.hbox )
self.ok.setText( "Ok" ) self.ok.setText( "Ok" )
self.cancel = QPushButton( self.hbox ) self.cancel = TQPushButton( self.hbox )
self.cancel.setText( "Cancel" ) self.cancel.setText( "Cancel" )
self.cancel.setDefault( True ) self.cancel.setDefault( True )
@ -104,7 +104,7 @@ class ConfigDialog( QDialog ):
self.file = file( "webcontrolrc", 'w' ) self.file = file( "webcontrolrc", 'w' )
self.config = ConfigParser.ConfigParser() self.config = configparser.ConfigParser()
self.config.add_section( "General" ) self.config.add_section( "General" )
self.config.set( "General", "allowcontrol", self.allowControl.isChecked() ) self.config.set( "General", "allowcontrol", self.allowControl.isChecked() )
self.config.set( "General", "publish", self.publish.isChecked() ) self.config.set( "General", "publish", self.publish.isChecked() )
@ -114,17 +114,17 @@ class ConfigDialog( QDialog ):
self.accept() self.accept()
class Notification( QCustomEvent ): class Notification( TQCustomEvent ):
__super_init = QCustomEvent.__init__ __super_init = TQCustomEvent.__init__
def __init__( self, str ): def __init__( self, str ):
self.__super_init(QCustomEvent.User + 1) self.__super_init(TQCustomEvent.User + 1)
self.string = str self.eventStr = str
class WebControl( QApplication ): class WebControl( TQApplication ):
""" The main application, also sets up the Qt event loop """ """ The main application, also sets up the TQt event loop """
def __init__( self, args ): def __init__( self, args ):
QApplication.__init__( self, args ) TQApplication.__init__( self, args )
debug( "Started." ) debug( "Started." )
self.readSettings() self.readSettings()
@ -138,15 +138,15 @@ class WebControl( QApplication ):
while p_incr < 10: while p_incr < 10:
try: try:
p_i=p_incr+Globals.PORT p_i=p_incr+Globals.PORT
self.srv = BaseHTTPServer.HTTPServer(('',p_i),RequestHandler.RequestHandler) self.srv = http.server.HTTPServer(('',p_i),RequestHandler.RequestHandler)
publisher.port = p_i publisher.port = p_i
break break
except socket.error: except socket.error:
p_incr+=1 p_incr+=1
self.zeroconfPublishing() self.zeroconfPublishing()
self.snsrv = QSocketNotifier(self.srv.fileno(), QSocketNotifier.Read) self.snsrv = TQSocketNotifier(self.srv.fileno(), TQSocketNotifier.Read)
self.snsrv.connect( self.snsrv, SIGNAL('activated(int)'), self.readSocket ) self.snsrv.connect( self.snsrv, SIGNAL('activated(int)'), self.readSocket )
def readSocket( self ): def readSocket( self ):
@ -155,15 +155,15 @@ class WebControl( QApplication ):
def readSettings( self ): def readSettings( self ):
""" Reads settings from configuration file """ """ Reads settings from configuration file """
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
config.read( "webcontrolrc" ) config.read( "webcontrolrc" )
try: try:
RequestHandler.AmarokStatus.allowControl = string.find(config.get( "General", "allowcontrol" ), "True") >= 0 RequestHandler.AmarokStatus.allowControl = "True" in config.get( "General", "allowcontrol" )
RequestHandler.AmarokStatus.publish = string.find(config.get( "General", "publish" ), "True") >= 0 RequestHandler.AmarokStatus.publish = "True" in config.get( "General", "publish" )
except: except:
debug( "No config file found, using defaults." ) debug( "No config file found, using defaults." )
def postConfigure( self ): def postConfigure( self ):
self.readSettings() self.readSettings()
@ -195,32 +195,32 @@ class WebControl( QApplication ):
def customEvent( self, notification ): def customEvent( self, notification ):
""" Handles the notifications """ """ Handles the notifications """
string = QString(notification.string) eventStr = TQString(notification.eventStr)
debug( "Received notification: " + str( string ) ) debug( "Received notification: " + str( eventStr ) )
if string.contains( "configure" ): if eventStr.contains( "configure" ):
self.configure() self.configure()
elif string.contains( "exit" ): elif eventStr.contains( "exit" ):
cleanup(None,None) cleanup(None,None)
elif string.contains( "engineStateChange: play" ): elif eventStr.contains( "engineStateChange: play" ):
self.engineStatePlay() self.engineStatePlay()
elif string.contains( "engineStateChange: idle" ): elif eventStr.contains( "engineStateChange: idle" ):
self.engineStateIdle() self.engineStateIdle()
elif string.contains( "engineStateChange: pause" ): elif eventStr.contains( "engineStateChange: pause" ):
self.engineStatePause() self.engineStatePause()
elif string.contains( "engineStateChange: empty" ): elif eventStr.contains( "engineStateChange: empty" ):
self.engineStatePause() self.engineStatePause()
elif string.contains( "trackChange" ): elif eventStr.contains( "trackChange" ):
self.trackChange() self.trackChange()
else: else:
debug( "Unknown notification: " + str(string) + " -> ignoring") debug( "Unknown notification: " + str(eventStr) + " -> ignoring")
# Notification callbacks. Implement these functions to react to specific notification # Notification callbacks. Implement these functions to react to specific notification
# events from Amarok: # events from Amarok:
@ -260,7 +260,6 @@ class WebControl( QApplication ):
RequestHandler.AmarokStatus.dcop_trackcurrenttime.result() RequestHandler.AmarokStatus.dcop_trackcurrenttime.result()
RequestHandler.AmarokStatus.dcop_tracktotaltime = Globals.PlayerDcop("trackTotalTime") RequestHandler.AmarokStatus.dcop_tracktotaltime = Globals.PlayerDcop("trackTotalTime")
RequestHandler.AmarokStatus.dcop_tracktotaltime.result() RequestHandler.AmarokStatus.dcop_tracktotaltime.result()
@ -269,21 +268,21 @@ class WebControl( QApplication ):
def debug( message ): def debug( message ):
""" Prints debug message to stdout """ """ Prints debug message to stdout """
print debug_prefix + " " + message print(debug_prefix + " " + message)
def cleanup(sig,frame): def cleanup(sig,frame):
publisher.shutdown() publisher.shutdown()
os._exit(0) os._exit(0)
def guithread(): def guithread():
app = WebControl( sys.argv ) app = WebControl( sys.argv )
app.exec_loop() app.exec_loop()
if __name__ == "__main__": if __name__ == "__main__":
Globals.EXEC_PATH = os.path.abspath(sys.path[0]) Globals.EXEC_PATH = os.path.abspath(sys.path[0])
gui = threading.Thread(target=guithread) gui = threading.Thread(target=guithread)
gui.start() gui.start()
signal.signal(signal.SIGTERM,cleanup) signal.signal(signal.SIGTERM,cleanup)
# just wait quietly for the end # just wait quietly for the end
while 1: sleep(120) while 1: sleep(120)

@ -20,15 +20,15 @@ import string
temp=sys.path[:] temp=sys.path[:]
sys.path.insert(0,os.path.abspath(os.path.dirname(sys.argv[0])+'/../common')) sys.path.insert(0,os.path.abspath(os.path.dirname(sys.argv[0])+'/../common'))
if not os.getenv("TDEDIR") is None: sys.path.insert(0,os.getenv("TDEDIR")+"/share/apps/amarok/scripts/common") if not os.getenv("TDEDIR") is None: sys.path.insert(0,os.getenv("TDEDIR")+"/share/apps/amarok/scripts/common")
if not os.getenv("TDEDIRS") is None: sys.path=[p+"/share/apps/amarok/scripts/common" for p in string.split(os.getenv("TDEDIRS"),os.pathsep)]+sys.path if not os.getenv("TDEDIRS") is None: sys.path=[p+"/share/apps/amarok/scripts/common" for p in os.pathsep.split(os.getenv("TDEDIRS"))]+sys.path
from Publisher import * from Publisher import *
sys.path=temp sys.path=temp
class WebPublisher(Publisher): class WebPublisher(Publisher):
port = None port = None
def services(self): def services(self):
return [{ "name" : "Amarok WebControl for "+getpass.getuser(), "port": self.port, "type": "_http._tcp", "properties": {}}] return [{ "name" : "Amarok WebControl for "+getpass.getuser(), "port": self.port, "type": "_http._tcp", "properties": {}}]
publisher = WebPublisher() publisher = WebPublisher()

Loading…
Cancel
Save