summaryrefslogtreecommitdiffstats
path: root/amarok/src/scripts/amarok_live/amarok_live.py
diff options
context:
space:
mode:
Diffstat (limited to 'amarok/src/scripts/amarok_live/amarok_live.py')
-rwxr-xr-xamarok/src/scripts/amarok_live/amarok_live.py110
1 files changed, 54 insertions, 56 deletions
diff --git a/amarok/src/scripts/amarok_live/amarok_live.py b/amarok/src/scripts/amarok_live/amarok_live.py
index f482b490..cf731369 100755
--- a/amarok/src/scripts/amarok_live/amarok_live.py
+++ b/amarok/src/scripts/amarok_live/amarok_live.py
@@ -7,7 +7,7 @@
#
# (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
@@ -17,7 +17,7 @@
#
############################################################################
-import ConfigParser
+import configparser
import os
import sys
import threading
@@ -25,9 +25,9 @@ import signal
from time import sleep
try:
- from qt import *
+ from TQt.qt import *
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
@@ -35,34 +35,34 @@ except:
debug_prefix = "LiveCD Remastering"
-class ConfigDialog ( QDialog ):
+class ConfigDialog ( TQDialog ):
""" Configuration widget """
def __init__( self ):
- QDialog.__init__( self )
- self.setWFlags( Qt.WDestructiveClose )
+ TQDialog.__init__( self )
+ self.setWFlags( TQt.WDestructiveClose )
self.setCaption("Amarok Live! Configuration")
- self.lay = QGridLayout( self, 3, 2)
+ self.lay = TQGridLayout( self, 3, 2)
self.lay.addColSpacing( 0, 300 )
- self.isopath = QLineEdit( self )
+ self.isopath = TQLineEdit( self )
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.lay.addWidget( self.isopath, 0, 0 )
self.lay.addWidget( self.tmppath, 1, 0 )
- self.isobutton = QPushButton( self )
+ self.isobutton = TQPushButton( self )
self.isobutton.setText("Browse..." )
- self.tmpbutton = QPushButton( self )
+ self.tmpbutton = TQPushButton( self )
self.tmpbutton.setText("Browse..." )
- self.cancel = QPushButton( self )
+ self.cancel = TQPushButton( self )
self.cancel.setText( "Cancel" )
- self.ok = QPushButton( self )
+ self.ok = TQPushButton( self )
self.ok.setText( "Ok" )
self.lay.addWidget( self.isobutton, 0, 1 )
@@ -82,11 +82,11 @@ class ConfigDialog ( QDialog ):
path = None
try:
- config = ConfigParser.ConfigParser()
+ config = configparser.ConfigParser()
config.read( "remasterrc" )
path = config.get( "General", "path" )
iso = config.get( "General", "iso")
-
+
if not path == "": self.tmppath.setText(path)
if not iso == "": self.isopath.setText(iso)
except:
@@ -97,7 +97,7 @@ class ConfigDialog ( QDialog ):
def save( self ):
""" Saves configuration to file """
self.file = file( "remasterrc", 'w' )
- self.config = ConfigParser.ConfigParser()
+ self.config = configparser.ConfigParser()
self.config.add_section( "General" )
self.config.set( "General", "path", self.tmppath.text() )
self.config.set( "General", "iso", self.isopath.text() )
@@ -109,7 +109,7 @@ class ConfigDialog ( QDialog ):
def clear():
self.file = file( "remasterrc", 'w' )
- self.config = ConfigParser.ConfigParser()
+ self.config = configparser.ConfigParser()
self.config.add_section( "General" )
self.config.set( "General", "path", "" )
self.config.set( "General", "iso", "" )
@@ -118,7 +118,7 @@ class ConfigDialog ( QDialog ):
def browseISO( self ):
- path = QFileDialog.getOpenFileName( "/home",
+ path = TQFileDialog.getOpenFileName( "/home",
"CD Images (*.iso)",
self,
"iso choose dialogr",
@@ -126,8 +126,8 @@ class ConfigDialog ( QDialog ):
self.isopath.setText( path )
def browsePath( self ):
-
- tmp = QFileDialog.getExistingDirectory( "/home",
+
+ tmp = TQFileDialog.getExistingDirectory( "/home",
self,
"get tmp dir",
"Choose working directory",
@@ -147,7 +147,7 @@ class ConfigDialog ( QDialog ):
path, iso = self.readConfig()
os.system("tdesu -t sh %s/amarok.live.remaster.part1.sh %s %s" % (scriptdir, path, iso))
#os.wait()
- print "got path: %s" % path
+ print("got path: %s" % path)
@@ -156,7 +156,7 @@ class ConfigDialog ( QDialog ):
path = ""
iso = ""
try:
- config = ConfigParser.ConfigParser()
+ config = configparser.ConfigParser()
config.read("remasterrc")
path = config.get("General", "path")
iso = config.get("General", "iso")
@@ -166,19 +166,18 @@ class ConfigDialog ( QDialog ):
-class Notification( QCustomEvent ):
- __super_init = QCustomEvent.__init__
+class Notification( TQCustomEvent ):
+ __super_init = TQCustomEvent.__init__
def __init__( self, str ):
-
- self.__super_init(QCustomEvent.User + 1)
- self.string = str
+ self.__super_init(TQCustomEvent.User + 1)
+ self.eventStr = str
-class Remasterer( QApplication ):
- """ The main application, also sets up the Qt event loop """
+class Remasterer( TQApplication ):
+ """ The main application, also sets up the TQt event loop """
def __init__( self, args ):
- QApplication.__init__( self, args )
+ TQApplication.__init__( self, args )
debug( "Started." )
# Start separate thread for reading data from stdin
@@ -187,13 +186,12 @@ class Remasterer( QApplication ):
self.readSettings()
-
# 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 selected to livecd\"")
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 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\" \"Create Remastered CD\"")
@@ -234,22 +232,22 @@ class Remasterer( QApplication ):
def customEvent( self, notification ):
""" Handles notifications """
- string = QString(notification.string)
- debug( "Received notification: " + str( string ) )
+ eventStr = TQString(notification.eventStr)
+ debug( "Received notification: " + str( eventStr ) )
- if string.contains( "configure" ):
+ if eventStr.contains( "configure" ):
self.configure()
- if string.contains( "stop"):
+ if eventStr.contains( "stop" ):
self.stop()
- elif string.contains( "customMenuClicked" ):
- if "selected" in string:
- self.copyTrack( string )
- elif "playlist" in string:
+ elif eventStr.contains( "customMenuClicked" ):
+ if eventStr.contains( "selected" ):
+ self.copyTrack( eventStr )
+ elif eventStr.contains( "playlist" ):
self.copyPlaylist()
- elif "Create" in string:
+ elif eventStr.contains( "Create" ):
self.createCD()
- elif "Clear" in string:
+ elif eventStr.contains( "Clear" ):
self.clearCD()
@@ -264,7 +262,7 @@ class Remasterer( QApplication ):
#self.connect( self.dia, SIGNAL( "destroyed()" ), self.readSettings )
def clearCD( self ):
-
+
self.dia = ConfigDialog()
path, iso = self.dia.readConfig()
@@ -274,7 +272,7 @@ class Remasterer( QApplication ):
stop()
def stop( self ):
-
+
fd = open("/tmp/amarok.stop", "w")
fd.write( "stopping")
fd.close()
@@ -297,22 +295,22 @@ class Remasterer( QApplication ):
os.system("dcop amarok playlist saveM3u '%s' false" % tmpfileloc)
tmpfile = open(tmpfileloc)
- import urllib
+ import urllib.request, urllib.parse, urllib.error
files = ""
m3u = ""
for line in tmpfile.readlines():
if line[0] != "#":
-
+
line = line.strip()
# get filename
name = line.split("/")[-1]
- #make url
- url = "file://" + urllib.quote(line)
+ #make url
+ url = "file://" + urllib.parse.quote(line)
- #make path on livecd
+ #make path on livecd
livecdpath = "/music/" + name
files += url + " "
@@ -333,7 +331,7 @@ class Remasterer( QApplication ):
m3uOut.write(m3u)
m3uOut.close()
-
+
os.system("mv /tmp/amarok.live.%s.m3u %s/amarok.live/playlist/" % (suffix,path))
os.system("rm /tmp/amarok.live.%s.m3u" % suffix)
@@ -355,7 +353,7 @@ class Remasterer( QApplication ):
#trying out a new one
#files = event.split(":")[-1][3:-2].replace("\"Amarok live!\" \"add to livecd\" ", "").split("\" \"")
#and another
-
+
files = event.replace("customMenuClicked: Amarok live Add selected to livecd", "").split()
allfiles = ""
@@ -365,7 +363,7 @@ class Remasterer( QApplication ):
os.system("kfmclient copy %s file://%s/amarok.live/music/" % (allfiles, path))
def createCD( self ):
-
+
self.dia = ConfigDialog()
path,iso = self.dia.readConfig()
if path == "":
@@ -394,7 +392,7 @@ def onSignal( signum, stackframe ):
fd.write( "stopping")
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 selected to livecd\"")
@@ -405,7 +403,7 @@ def onSignal( signum, stackframe ):
def debug( message ):
""" Prints debug message to stdout """
- print debug_prefix + " " + message
+ print(debug_prefix + " " + message)
def main():
app = Remasterer( sys.argv )
@@ -420,7 +418,7 @@ if __name__ == "__main__":
mainapp = threading.Thread(target=main)
mainapp.start()
signal.signal(15, onSignal)
- print signal.getsignal(15)
+ print(signal.getsignal(15))
while 1: sleep(120)
#main( sys.argv )