Changeset 3c1479 in indico
- Timestamp:
- 10/13/10 17:22:32 (3 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
- Children:
- 456f15
- Parents:
- 775b91
- git-author:
- Juan Alonso <juan.alonso.hernandez@…> (08/07/09 09:40:04)
- git-committer:
- Pedro Ferreira <jose.pedro.ferreira@…> (10/13/10 17:22:32)
- Files:
-
- 12 added
- 9 edited
-
bin/legacy/chdatetime.py (modified) (1 diff)
-
bin/utils/indicoShell.py (modified) (2 diffs)
-
bin/utils/registerFoundationSync.py (added)
-
indico/MaKaC/booking.py (modified) (1 diff)
-
indico/MaKaC/common/dvdCreation.py (modified) (4 diffs)
-
indico/MaKaC/common/pendingQueues.py (modified) (16 diffs)
-
indico/MaKaC/common/timerExec.py (modified) (3 diffs)
-
indico/MaKaC/consoleScripts/taskDaemon.py (modified) (7 diffs)
-
indico/MaKaC/modules/base.py (modified) (1 diff)
-
indico/MaKaC/modules/tasks.py (added)
-
indico/MaKaC/tasks/__init__.py (added)
-
indico/MaKaC/tasks/base.py (added)
-
indico/MaKaC/tasks/controllers.py (added)
-
indico/MaKaC/tasks/dvdCreation.py (added)
-
indico/MaKaC/tasks/indico.py (added)
-
setup.py (modified) (1 diff)
-
tests/MaKaC_tests/tasks/__init__.py (added)
-
tests/MaKaC_tests/tasks/inject.py (added)
-
tests/MaKaC_tests/tasks/massive_injector.sh (added)
-
tests/MaKaC_tests/tasks/run.py (added)
-
tests/MaKaC_tests/tasks/testOverlord.py (added)
Legend:
- Unmodified
- Added
- Removed
-
bin/legacy/chdatetime.py
rbdd862 r3c1479 38 38 chconf(conf) 39 39 get_transaction().commit() 40 40 41 # Tasks 42 # tl = Supervisor. 41 43 htl = timerExec.HelperTaskList.getTaskListInstance() 42 44 for task in htl.getTasks(): -
bin/utils/indicoShell.py
rb79d09 r3c1479 8 8 from MaKaC.conference import Conference, Category, ConferenceHolder, CategoryManager, DeletedObjectHolder 9 9 from MaKaC.user import AvatarHolder, GroupHolder 10 from MaKaC.common.timerExec import HelperTaskList 10 from MaKaC.common.timerExec import HelperTaskList # DEPRECATED 11 11 from MaKaC.common.info import HelperMaKaCInfo 12 12 from MaKaC.plugins.base import PluginsHolder … … 47 47 add(namespace, AvatarHolder) 48 48 add(namespace, GroupHolder) 49 add(namespace, HelperTaskList) 49 add(namespace, HelperTaskList) # DEPRECATED 50 50 add(namespace, HelperMaKaCInfo) 51 51 add(namespace, PluginsHolder) -
indico/MaKaC/booking.py
rbdd862 r3c1479 41 41 from MaKaC.common.Locators import Locator 42 42 from MaKaC.accessControl import AccessController 43 from MaKaC.common.timerExec import HelperTaskList, Alarm44 43 from MaKaC.errors import MaKaCError, TimingError, ParentTimingError 45 44 from MaKaC import registration -
indico/MaKaC/common/dvdCreation.py
rbdd862 r3c1479 18 18 ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., 19 19 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 21 '''TODO TASKDAEMON: remove this file once the migration to the new taskDaemon is complete''' 20 22 21 23 import traceback, string … … 460 462 return publicFileURL 461 463 464 462 465 class RHWrapper(Persistent): 463 464 466 def __init__(self, rh): 465 467 self._user = rh._getUser() … … 483 485 return "" 484 486 487 485 488 class DVDCreation: 486 487 489 def __init__(self, rh, conf, wf): 488 490 self._rh=rh … … 504 506 dvdTask.addObj(dvdCreator) 505 507 506 # Add the t rack to the track list508 # Add the task to the task list 507 509 htl = HelperTaskList.getTaskListInstance() 508 510 htl.addTask(dvdTask) 509 511 510 -
indico/MaKaC/common/pendingQueues.py
rbdd862 r3c1479 24 24 from MaKaC.webinterface import mail, urlHandlers 25 25 from MaKaC.common.info import HelperMaKaCInfo 26 from MaKaC.common.timerExec import HelperTaskList, task, obj 26 from MaKaC.common.timerExec import task, obj 27 from MaKaC.tasks.controllers import Supervisor 28 from MaKaC.tasks.base import OneShotTask 27 29 from persistent import Persistent 28 30 from MaKaC.user import AvatarHolder … … 33 35 #---GENERAL---- 34 36 35 class PendingHolder: 36 37 class PendingHolder(object): 37 38 """ This is an index that holds all the requests to add pending people to become 38 39 Indico users. … … 75 76 """We must implement this method in order to sent an email with the reminder for the specific pending users""" 76 77 pass 78 77 79 78 80 def _getTasksIdx(self): … … 85 87 if not self._hasTask(email): 86 88 # Create the object which send the email 87 pedingReminder =self._reminder(email)88 pedingReminder.setId("ReminderPending%s-%s" %(self._id,email))89 pedingReminder = self._reminder(email) 90 pedingReminder.setId("ReminderPending%s-%s" % (self._id,email)) 89 91 # Create the task 90 92 t=task() … … 95 97 t.setEndDate(nw+timedelta(15)) # keep trying during 15 days 96 98 self._tasksIdx.indexTask(email, t) 97 # Add the track to the track list98 htl = HelperTaskList.getTaskListInstance()99 htl.addTask(t)99 100 Supervisor.addTask(t) 101 100 102 101 103 def _removeTask(self, email): 102 104 if self._hasTask(email): 103 105 t=self._getTasksIdx().matchTask(email)[0] 104 htl = HelperTaskList.getTaskListInstance() 105 htl.removeTask(t) 106 Supervisor.removeTask(t) 106 107 self._tasksIdx.unindexTask(email, t) 107 108 … … 109 110 return self._getTasksIdx().matchTask(email) != [] 110 111 111 class _PendingNotification: 112 113 class _PendingNotification(object): 112 114 113 115 def __init__( self, psList ): … … 148 150 return d 149 151 150 class PendingReminder(obj): 151 152 def __init__(self, email ):153 obj.__init__(self)154 self._email =email152 153 class PendingReminder(OneShotTask): 154 def __init__(self, email, **kwargs): 155 super(PendingReminder, self).__init__(**kwargs) 156 self._email = email 155 157 156 158 def run(self): … … 174 176 return True 175 177 return False 176 177 def endTask(self):178 """Mandatory to implement for the specific queues.179 It removes the task from the task list and from the index of the pending queue"""180 pass178 179 def tearDown(self): 180 '''Inheriting classes must implement this method''' 181 raise Exception('Unimplemented tearDown') 182 181 183 182 184 def getEmail(self): … … 278 280 mail.GenericMailer.send( notif ) 279 281 280 def endTask(self):282 def tearDown(self): 281 283 psh=PendingSubmittersHolder() 282 284 psl=psh.getPendingByEmail(self._email) … … 368 370 return participations 369 371 372 370 373 class PendingManagerReminder(PendingReminder): 371 374 … … 379 382 mail.GenericMailer.send( notif ) 380 383 381 def endTask(self):382 psh =PendingManagersHolder()383 psl =psh.getPendingByEmail(self._email)384 def tearDown(self): 385 psh = PendingManagersHolder() 386 psl = psh.getPendingByEmail(self._email) 384 387 for e in psl: 385 388 e.getConference().getPendingQueuesMgr().removePendingManager(e) … … 436 439 437 440 class _PendingConfManagerNotification(_PendingNotification): 438 439 441 def getBody( self ): 440 442 url = urlHandlers.UHUserCreation.getURL() … … 463 465 return participations 464 466 467 465 468 class PendingConfManagerReminder(PendingReminder): 466 467 469 def run(self): 468 470 hasAccount=PendingReminder.run(self) … … 474 476 mail.GenericMailer.send( notif ) 475 477 476 def endTask(self):477 psh =PendingManagersHolder()478 psl =psh.getPendingByEmail(self._email)478 def tearDown(self): 479 psh = PendingManagersHolder() 480 psl = psh.getPendingByEmail(self._email) 479 481 for e in psl: 480 482 e.getConference().getPendingQueuesMgr().removePendingManager(e) 481 483 482 484 def getPendings(self): 483 psh =PendingManagersHolder()485 psh = PendingManagersHolder() 484 486 return psh.getPendingByEmail(self._email) 485 487 #---END MANAGERS … … 560 562 return participations 561 563 564 562 565 class PendingCoordinatorReminder(PendingReminder): 563 564 566 def run(self): 565 567 hasAccount=PendingReminder.run(self) 566 568 if not hasAccount: 567 psh =PendingCoordinatorsHolder()568 psl =psh.getPendingByEmail(self._email)569 psh = PendingCoordinatorsHolder() 570 psl = psh.getPendingByEmail(self._email) 569 571 if psl != [] and psl is not None: 570 notif = _PendingCoordinatorNotification( psl)571 mail.GenericMailer.send( notif)572 573 def endTask(self):574 psh =PendingCoordinatorsHolder()575 psl =psh.getPendingByEmail(self._email)572 notif = _PendingCoordinatorNotification(psl) 573 mail.GenericMailer.send(notif) 574 575 def tearDown(self): 576 psh = PendingCoordinatorsHolder() 577 psl = psh.getPendingByEmail(self._email) 576 578 for e in psl: 577 579 e.getConference().getPendingQueuesMgr().removePendingCoordinator(e) 578 580 579 581 def getPendings(self): 580 psh =PendingCoordinatorsHolder()582 psh = PendingCoordinatorsHolder() 581 583 return psh.getPendingByEmail(self._email) 582 584 … … 584 586 585 587 #--GENERAL--- 586 class PendingQueuesHolder :588 class PendingQueuesHolder(object): 587 589 588 590 _pendingQueues=[PendingSubmittersHolder, \ -
indico/MaKaC/common/timerExec.py
r8e9fd9 r3c1479 18 18 ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., 19 19 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 21 '''TODO TASKDAEMON: remove this file once the migration to the new taskDaemon is complete''' 20 22 21 23 import time, signal, copy, sys, traceback … … 533 535 self.smtpServer = Config.getInstance().getSmtpServer() 534 536 TrashCanManager().remove(self) 535 536 537 class FoundationSync( obj ):538 """539 Synchronizes room data (along with associated room managers540 and equipment) with Foundation database.541 542 Also, updates list of CERN Official Holidays543 544 (This is object for a task class)545 """546 def __init__(self):547 obj.__init__(self)548 549 def run(self):550 from MaKaC.common.FoundationSync.foundationSync import FoundationSync551 FoundationSync().doAll()552 553 def delete(self):554 TrashCanManager().add( self )555 556 def recover(self):557 TrashCanManager().remove( self )558 559 @staticmethod560 def register():561 """562 Run ONCE to add FoundationSync task563 """564 # Connect to Indico DB565 db.DBMgr.getInstance().startRequest()566 db.DBMgr.getInstance().sync()567 TASK_ID = 'FoundationSyncTask'568 569 t = task()570 t.setId( TASK_ID )571 d = nowutc() + timedelta( days = 1 )572 t.setStartDate( d.replace( hour=0, minute=0, second=0, microsecond=0 )) # This midnight573 t.setInterval( timedelta( days = 1 ) )574 t.addObj( FoundationSync() )575 576 # Check if tasks existis577 taskList = HelperTaskList.getTaskListInstance()578 for existing in taskList.getTasks():579 if existing.getId() == t.getId():580 print TASK_ID + " is already registered"581 return582 583 # Task does not exist: add it584 taskList.addTask( t )585 586 # Disconnect from Indico DB587 db.DBMgr.getInstance().endRequest()588 print "Successfully registered " + TASK_ID589 537 590 538 … … 880 828 TrashCanManager().remove(self) 881 829 882 class StatisticsUpdater(obj):883 def __init__(self, cat):884 self._cat = cat885 886 def run( self ):887 CategoryStatistics.updateStatistics(self._cat)888 889 def delete(self):890 for obj in self.getObjList():891 self.removeObj(obj)892 # Id the delete method doesn't exist for obj it has to be893 # implemented.894 obj.delete()895 self.conf = None896 TrashCanManager().add(self)897 898 def recover(self):899 TrashCanManager().remove(self)900 901 830 if __name__ == "__main__": 902 831 """ -
indico/MaKaC/consoleScripts/taskDaemon.py
rbdd862 r3c1479 22 22 import sys, getopt, os, time 23 23 24 duration = 15*60 # seconds25 linuxPIDFile="/var/run/IndicoTaskDaemon.pid"26 logFile="/opt/indico/log/taskDaemon.log"27 28 24 def _isPosix(): 29 25 return os.name == "posix" … … 32 28 return os.name == "nt" 33 29 34 def _savePID(pid ):30 def _savePID(pid, pid_file): 35 31 try: 36 f=open(linuxPIDFile, "w") 37 f.write(str(pid)) 38 f.close() 32 open(pid_file, "w").write(str(pid)) 39 33 except IOError, e: 40 print "Exception while trying to store the daemon PID in the file '%s':\n%s"%(linuxPIDFile, e) 34 print "Exception while trying to store the daemon PID in the file '%s':\n%s" % (linuxPIDFile, e) 35 41 36 42 37 def _getPID(printExceptions=True): 43 38 try: 44 f=open(linuxPIDFile, "r") 45 pid=f.read() 46 pid=pid.strip() 47 pid=int(pid) 48 f.close() 39 pid = int(open(linuxPIDFile, "r").read().strip()) 49 40 return pid 50 41 except IOError, e: 51 42 if printExceptions: 52 print "Exception while opening the file '%s' with the daemon PID:\n%s" %(linuxPIDFile, e)43 print "Exception while opening the file '%s' with the daemon PID:\n%s" % (linuxPIDFile, e) 53 44 except ValueError, e: 54 45 if printExceptions: 55 print "Exception while reading the file '%s' with the daemon PID:\nThere is not a PID in the file" %(linuxPIDFile)46 print "Exception while reading the file '%s' with the daemon PID:\nThere is not a PID in the file" % (linuxPIDFile) 56 47 return -1 57 48 49 58 50 def _killProcess(): 59 if _isPosix(): 60 pid=_getPID() 61 if pid != -1: 62 try: 63 os.kill(pid, 9) 64 except OSError, e: 65 print e 66 return False 51 if not _isPosix(): 52 return False 53 54 pid = _getPID() 55 if pid != -1: 56 try: 57 os.kill(pid, 9) 58 except OSError, e: 59 print e 60 else: 67 61 os.remove(linuxPIDFile) 68 62 return True 63 69 64 return False 70 65 … … 108 103 print "" 109 104 110 def fileExists(f):111 try:112 fi = open(f,'a')113 fi.close()114 except IOError:115 exists = False116 else:117 exists = True118 return exists119 120 105 121 106 def run(log=None): 122 from MaKaC.common.timerExec import timer 123 124 if _isPosix() and (not log or not fileExists(log)): 125 print "\nPlease enter an existing log file, and start again\nDaemon stopped!\n" 126 os.remove(linuxPIDFile) 127 sys.exit(2) 128 t = timer(duration, log) 129 initDefaultTasks() 130 t.start() 107 from MaKaC.tasks.controllers import Supervisor 108 Supervisor.getInstance().run() 109 # initDefaultTasks() 110 131 111 132 112 def startTaskDaemon(): … … 138 118 print "Task daemon is already running" 139 119 sys.exit(0) 120 140 121 if _isPosix(): 141 122 pid=os.fork() 142 123 if pid==0: 143 124 #Child 144 run( log=logFile)125 run() 145 126 else: 146 127 #Parent 147 _savePID(pid )128 _savePID(pid, linuxPIDFile) 148 129 print "Daemon started! (pid=%s)\n"%pid 149 130 time.sleep(3) … … 154 135 print "Impossible to start the daemon" 155 136 137 156 138 def stopTaskDaemon(): 157 139 if _killProcess(): … … 160 142 print "Impossible to stop the process 'taskDaemon', please do it manually" 161 143 144 162 145 def restartTaskDaemon(): 163 _killProcess() 164 print "Daemon stopped!" 146 stopTaskDaemon() 165 147 startTaskDaemon() 148 166 149 167 150 def main(): 168 151 "Main" 169 152 try: 170 opts, args = getopt.getopt(sys.argv[1:],"hstr", \ 171 [ \ 172 "help", \ 173 "start", \ 174 "stop", \ 175 "restart" \ 176 ] 177 ) 153 opts, args = getopt.getopt(sys.argv[1:],"hstr", [ "help", "start", "stop", "restart" ]) 178 154 except getopt.GetoptError, e: 179 help()155 usage() 180 156 sys.exit(2) 181 157 182 arg =None158 arg = None 183 159 if len(args) == 1: 184 160 arg=args[0] 185 161 elif len(opts)==1: 186 162 arg=opts[0][0] 187 if arg is not None: 188 if arg in ("start", "s", "-s"): 163 164 if arg: 165 if arg in ("start", "s", "-s"): 189 166 startTaskDaemon() 190 167 elif arg in ("stop", "t", "-t"): … … 193 170 restartTaskDaemon() 194 171 elif arg in ("help", "h", "-h", "--help"): 195 help()172 usage() 196 173 sys.exit() 197 174 else: 198 help()175 usage() 199 176 sys.exit(2) 200 177 return 201 178 else: 202 help()179 usage() 203 180 sys.exit(2) 204 181 205 182 206 def help(): 207 "Print out info" 183 def usage(): 184 print "\nUsage: python taskDaemon.py start|stop|restart [-h]\n" 185 print " -h Help" 186 print " -s Start the task daemon" 187 print " -t Stop the task daemon" 188 print " -r Restart the task daemon" 208 189 209 print "\nUsage: python taskDaemon.py start|stop|restart [-h]\n"210 print " -h Help"211 print " -s Start the task daemon"212 print " -t Stop the task daemon"213 print " -r Restart the task daemon"214 190 215 191 if __name__ == "__main__": 192 from MaKaC.common.Configuration import Config 193 cfg = Config.getInstance() 194 linuxPIDFile = "%s/IndicoTaskDaemon.pid" % cfg.getLogDir() 195 logFile = "%s/taskDaemon.log" % cfg.getLogDir() 216 196 main() -
indico/MaKaC/modules/base.py
rbdd862 r3c1479 50 50 import MaKaC.modules.cssTpls as cssTpls 51 51 import MaKaC.modules.upcoming as upcoming 52 52 import MaKaC.modules.tasks as tasks 53 53 54 ModulesHolder._availableModules = { 54 news.NewsModule.id:news.NewsModule, 55 cssTpls.CssTplsModule.id:cssTpls.CssTplsModule, 56 upcoming.UpcomingEventsModule.id:upcoming.UpcomingEventsModule 55 news.NewsModule.id : news.NewsModule, 56 cssTpls.CssTplsModule.id : cssTpls.CssTplsModule, 57 upcoming.UpcomingEventsModule.id : upcoming.UpcomingEventsModule, 58 tasks.TasksModule.id : tasks.TasksModule 57 59 } 58 60 -
setup.py
r80f35b r3c1479 114 114 115 115 base = ['pytz', 'zope.index', 'zope.interface', 'simplejson', 'suds', 116 'lxml', 'cds-indico-extras' ]116 'lxml', 'cds-indico-extras', 'zc-queue'] 117 117 if sys.version_info[1] < 5: #for Python older than 2.5 118 118 base.append('hashlib') # hashlib isn't a part of Python older than 2.5
Note: See TracChangeset
for help on using the changeset viewer.
