Created
April 3, 2011 14:31
-
-
Save Signez/900451 to your computer and use it in GitHub Desktop.
Et oui, en Python aussi on peut faire du code non maintenable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a nightmare. | |
class PlayerStack: | |
# ... | |
def liquidload(self): | |
lstck = self.getSortedWaitingStack() | |
if (not self.playingElement | |
or ((self.playingElement.startedAt + self.playingElement.length) - time.time()) < Stack.preload | |
or (len(lstck) > 0 and isinstance(lstck[0], Action) and lstck[0].directOnly == True)): | |
if len(lstck) == 0: | |
self.state = "stopped" | |
return | |
if (self.state == "playing" and lstck[0].status == "ready") or \ | |
(isinstance(lstck[0], Action) and (lstck[0].directOnly == True or self.state == "playing")): | |
if isinstance(lstck[0], Media): | |
thecommand = 'jukebox.push annotate:sydroid_uid="' + str(lstck[0].uid) + '":' + lstck[0].paths['path'] | |
send_command(thecommand) | |
sylog("Media #" + hex(int(lstck[0].uid))[2:] + " loaded : \n -> " + thecommand) | |
lstck[0].status = "loaded" | |
sylog("StackElement #" + hex(int(lstck[0].uid))[2:] + " changed status to " + lstck[0].status) | |
with ldb: | |
rsql = "UPDATE currentstack SET edited_at = UNIX_TIMESTAMP(), " \ | |
+ "status = '" + lstck[0].status + "' WHERE id = '" + str(lstck[0].uid) + "'" | |
db.execute(rsql) | |
conn.commit() | |
elif isinstance(lstck[0], Action): | |
if self.playingElement is None or lstck[0].directOnly == True: | |
lstck[0].doAction() | |
lstck[0].status = "done" | |
sylog("Action #" + hex(int(lstck[0].uid))[2:] + " done (" + lstck[0].command + ")") | |
self.setAsDone(lstck[0].uid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Argh ! Ca pique