Skip to content

Instantly share code, notes, and snippets.

@Signez Signez/nightmare.py
Created Apr 3, 2011

Embed
What would you like to do?
Et oui, en Python aussi on peut faire du code non maintenable.
# 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)
@cnotin

This comment has been minimized.

Copy link

cnotin commented Apr 3, 2011

Argh ! Ca pique

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.