Changeset 41
- Timestamp:
- 08/13/10 19:46:21 (3 years ago)
- Location:
- trunk/radiomate
- Files:
-
- 5 modified
-
jukebox.py (modified) (4 diffs)
-
jukeslots/base.py (modified) (1 diff)
-
jukeslots/simplelive.py (modified) (1 diff)
-
jukeslots/simpleplaylist.py (modified) (1 diff)
-
mate.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/radiomate/jukebox.py
r27 r41 50 50 try: 51 51 # make a new connection every time, otherwise we have an outdated view of the database 52 cm = dao.DBConnectionManager(dbhost = config.DBHOST, \53 dbuser = config.DBUSER, dbpassword = config.DBPASSWORD, \52 cm = dao.DBConnectionManager(dbhost = config.DBHOST, 53 dbuser = config.DBUSER, dbpassword = config.DBPASSWORD, 54 54 database = config.DATABASE) 55 55 tsdao = dao.TimeSlotDAO(cm) … … 66 66 else: 67 67 self.nexttimeslot = next 68 self.logger.info("jukebox: queueing jukeslot %d %s at %s" % (self.nexttimeslot.id, \68 self.logger.info("jukebox: queueing jukeslot %d %s at %s" % (self.nexttimeslot.id, 69 69 self.nexttimeslot.title, self.nexttimeslot.getBeginningDatetime())) 70 70 return True … … 83 83 jukeslotclass = JUKESLOTTYPEDICT[self.currenttimeslot.slottype] 84 84 except KeyError: 85 self.logger.error("Slot type %s not found. '%s' will be canceled." \86 %(self.currenttimeslot.slottype, self.currenttimeslot.title))85 self.logger.error("Slot type %s not found. '%s' will be canceled." % \ 86 (self.currenttimeslot.slottype, self.currenttimeslot.title)) 87 87 jukeslotclass = JukeSlot 88 88 89 89 self.logger.debug("chosen %s -> %s" % (self.currenttimeslot.slottype, jukeslotclass)) 90 90 91 # spawn a new process 92 self.currentjukeslot = jukeslotclass(timeslot=self.currenttimeslot, mainpassword=self.getPassword()) 91 try: 92 # spawn a new process 93 self.currentjukeslot = jukeslotclass(timeslot=self.currenttimeslot, 94 mainpassword=self.getPassword()) 93 95 94 self.currentjukeslot.deathtime = time.time() + self.currentjukeslot.duration*6096 self.currentjukeslot.deathtime = time.time() + self.currentjukeslot.duration*60 95 97 96 self.currentjukeslot.run()98 self.currentjukeslot.run() 97 99 98 if self.pollcurrent(): 99 self.logger.info("jukebox: playing jukeslot %d %s for %d minutes until %s" % (self.currentjukeslot.id,\ 100 self.currentjukeslot.title, self.currentjukeslot.duration,\ 101 time.ctime(self.currentjukeslot.deathtime))) 102 return self.currentjukeslot.deathtime 103 else: 104 # TODO: if there is an error, update the timeslot info in the database 105 self.logger.error("jukebox: jukeslot %d %s failed to start." %(self.currentjukeslot.id,\ 106 self.currentjukeslot.title)) 107 return 0 100 if self.pollcurrent(): 101 self.logger.info("jukebox: playing jukeslot %d %s for %d minutes until %s" % (self.currentjukeslot.id, 102 self.currentjukeslot.title, self.currentjukeslot.duration, 103 time.ctime(self.currentjukeslot.deathtime))) 104 return self.currentjukeslot.deathtime 105 else: 106 raise JukeBoxException("Process is dead.") 107 except Exception, e: 108 self.logger.error("jukebox: jukeslot %d %s failed. %s" %(self.currentjukeslot.id, 109 self.currentjukeslot.title, str(e))) 110 # TODO: update the timeslot info in the database 111 self.currentjukeslot = None 112 108 113 109 114 def pollcurrent(self): … … 121 126 now = time.time() 122 127 if force or (now >= self.currentjukeslot.deathtime): 123 self.logger.info("Stopping the current jukeslot (deathtime = %s, now = %s)" % \128 self.logger.info("Stopping the current jukeslot (deathtime = %s, now = %s)" % \ 124 129 (time.ctime(self.currentjukeslot.deathtime), time.ctime(now))) 125 130 self.currentjukeslot.gracefulKill() -
trunk/radiomate/jukeslots/base.py
r27 r41 58 58 # initialize the connection to the database 59 59 try: 60 self.cm = dao.DBConnectionManager(dbhost = config.DBHOST, \61 dbuser = config.DBUSER, dbpassword = config.DBPASSWORD, \60 self.cm = dao.DBConnectionManager(dbhost = config.DBHOST, 61 dbuser = config.DBUSER, dbpassword = config.DBPASSWORD, 62 62 database = config.DATABASE) 63 63 self.pldao = dao.PlayListDAO(self.cm) -
trunk/radiomate/jukeslots/simplelive.py
r27 r41 62 62 description="%s", 63 63 radio) 64 """ % (config.LIVESTREAMPORT, self.slotparams['livepassword'], config.LIVESTREAMMOUNT, \65 self.getFallBackPlayListName(), self.title, config.INTERNALJUKEPORT, \64 """ % (config.LIVESTREAMPORT, self.slotparams['livepassword'], config.LIVESTREAMMOUNT, 65 self.getFallBackPlayListName(), self.title, config.INTERNALJUKEPORT, 66 66 self.mainpassword, self.title) 67 67 return liq -
trunk/radiomate/jukeslots/simpleplaylist.py
r27 r41 57 57 radio) 58 58 59 """ % (self.getPlayListName(self.playlist.id), self.getFallBackPlayListName(), \59 """ % (self.getPlayListName(self.playlist.id), self.getFallBackPlayListName(), 60 60 config.INTERNALJUKEPORT, self.mainpassword) 61 61 self.logger.info("Starting playlist jukeslot") -
trunk/radiomate/mate.py
r36 r41 186 186 def __init__(self, classdict = {}): 187 187 "take as parameter a row dictionary obtained through a MySQLdb.cursors.DictCursor object, or a json string" 188 self.__dict__.update({'rolename' : '', \189 'canManageRoles' : False, \190 'canManageUsers' : False, \191 'canManageAllPlaylists' : False, \192 'canRegisterFiles' : False, \193 'canManageRegisteredFiles' : False, \194 'canManageTimetable' : False, \195 'fixedSlotTimes' : False, \196 'changeTimeBeforeTransmission' : 1440, \197 'canCreateTestSlot' : False, \188 self.__dict__.update({'rolename' : '', 189 'canManageRoles' : False, 190 'canManageUsers' : False, 191 'canManageAllPlaylists' : False, 192 'canRegisterFiles' : False, 193 'canManageRegisteredFiles' : False, 194 'canManageTimetable' : False, 195 'fixedSlotTimes' : False, 196 'changeTimeBeforeTransmission' : 1440, 197 'canCreateTestSlot' : False, 198 198 'fixedSlotTimesList' : "15,30,45,60,75,90,105,120"}) 199 199 RadioMateParentClass.__init__(self) … … 209 209 def __init__(self, classdict = {}): 210 210 "take as parameter a row dictionary obtained through a MySQLdb.cursors.DictCursor object, or a json string" 211 self.__dict__.update({'name' : '', \212 'password' : '', \213 'displayname' : '', \211 self.__dict__.update({'name' : '', 212 'password' : '', 213 'displayname' : '', 214 214 'rolename' : ''}) 215 215 RadioMateParentClass.__init__(self) … … 237 237 "take as parameter a row dictionary obtained through a MySQLdb.cursors.DictCursor object, or a json string" 238 238 self.__dict__.update({ 239 'id': 0L, \240 'user' : '', \241 'path' : '', \242 'type' : 'audio', \243 'title' : '', \244 'author' : '', \245 'album' : '', \246 'genre' : '', \247 'year' : 0, \248 'comment' : '', \249 'license' : '', \250 'tags' : '', \239 'id': 0L, 240 'user' : '', 241 'path' : '', 242 'type' : 'audio', 243 'title' : '', 244 'author' : '', 245 'album' : '', 246 'genre' : '', 247 'year' : 0, 248 'comment' : '', 249 'license' : '', 250 'tags' : '', 251 251 'position' : -1}) 252 252 RadioMateParentClass.__init__(self) … … 260 260 "take as parameter a row dictionary obtained through a MySQLdb.cursors.DictCursor object, or a json string" 261 261 self.__dict__.update({ 262 'id': 0L, \263 'creator' : '', \264 'mediafilelist' : [], \265 'owners' : [], \266 'viewers' : [], \267 'private' : False, \268 'title' : '', \269 'description' : '', \270 'comment' : '', \262 'id': 0L, 263 'creator' : '', 264 'mediafilelist' : [], 265 'owners' : [], 266 'viewers' : [], 267 'private' : False, 268 'title' : '', 269 'description' : '', 270 'comment' : '', 271 271 'tags' : ''}) 272 272 RadioMateParentClass.__init__(self) … … 344 344 "take as parameter a row dictionary obtained through a MySQLdb.cursors.DictCursor object, or a json string" 345 345 self.__dict__.update({ 346 'id': 0L, \347 'creator' : '', \348 'slottype' : '', \349 'slotparams' : {}, \346 'id': 0L, 347 'creator' : '', 348 'slottype' : '', 349 'slotparams' : {}, 350 350 'beginningtime': { 351 'year' : 0, \352 'month' : 0, \353 'day' : 0, \354 'hour' : 0, \355 'minute' : 0 \356 }, \357 'duration': 0, \358 'title' : '', \359 'description' : '', \360 'comment' : '', \361 'fallbackplaylist' : 0L, \351 'year' : 0, 352 'month' : 0, 353 'day' : 0, 354 'hour' : 0, 355 'minute' : 0 356 }, 357 'duration': 0, 358 'title' : '', 359 'description' : '', 360 'comment' : '', 361 'fallbackplaylist' : 0L, 362 362 'tags' : ''}) 363 363 RadioMateParentClass.__init__(self) … … 390 390 def getBeginningTimestamp(self): 391 391 "convert to unix timestamp" 392 timetuple = (self.beginningtime['year'], \393 self.beginningtime['month'], \394 self.beginningtime['day'], \395 self.beginningtime['hour'], \396 self.beginningtime['minute'], \392 timetuple = (self.beginningtime['year'], 393 self.beginningtime['month'], 394 self.beginningtime['day'], 395 self.beginningtime['hour'], 396 self.beginningtime['minute'], 397 397 0, -1, -1, -1) 398 398 return time.mktime(timetuple) … … 400 400 def getEndingTimestamp(self): 401 401 "convert to unix timestamp" 402 timetuple = (self.beginningtime['year'], \403 self.beginningtime['month'], \404 self.beginningtime['day'], \405 self.beginningtime['hour'], \406 self.beginningtime['minute'], \402 timetuple = (self.beginningtime['year'], 403 self.beginningtime['month'], 404 self.beginningtime['day'], 405 self.beginningtime['hour'], 406 self.beginningtime['minute'], 407 407 0, -1, -1, -1) 408 408 t = time.mktime(timetuple) … … 413 413 "return a string with the beginning date and time" 414 414 return "%04d-%02d-%02d %02d:%02d" % \ 415 (self.beginningtime['year'], \416 self.beginningtime['month'], \417 self.beginningtime['day'], \418 self.beginningtime['hour'], \415 (self.beginningtime['year'], 416 self.beginningtime['month'], 417 self.beginningtime['day'], 418 self.beginningtime['hour'], 419 419 self.beginningtime['minute']) 420 420 … … 434 434 tm = time.strptime(str(thetime), "%Y-%m-%d %H:%M:%S") 435 435 436 self.beginningtime = {'year': tm.tm_year, 'month': tm.tm_mon, \436 self.beginningtime = {'year': tm.tm_year, 'month': tm.tm_mon, 437 437 'day': tm.tm_mday, 'hour': tm.tm_hour, 'minute': tm.tm_min} 438 438