source: mauRepo/MolesManager/trunk/src/libs/migration/client.py @ 8092

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/libs/migration/client.py@8092
Revision 8092, 1.4 KB checked in by mnagni, 8 years ago (diff)

reverted client.py to previous version because of erroneous commit (not critical mistake, just for clean code)

Line 
1'''
2Created on 9 Nov 2011
3
4@author: mnagni
5'''
6from libs.migration.processor.loadResources import LoadResources
7from libs.migration.processor.migrationProcess import MigrationProcess
8
9import threading
10import time
11from threading import Timer
12from libs.migration.db.classes import MigrationObject
13from libs.migration.processor.commons import DS_pUBLISHED, DO_BADC
14
15
16
17class MigrationThread(threading.Thread):
18    """
19        Constructs a scheduler for the Moles2 to Moles3 migration.
20        @param interval: define the minimal time, in seconds, between an execution and the successive.
21        If the current migration run takes more than the defined interval the next will starts
22        as soon the previous ends.         
23    """
24    def __init__(self, interval=600):
25        threading.Thread.__init__(self)
26        self._doRun = True   
27        self.interval = interval
28   
29    def stop(self):
30        self._doRun = False
31   
32    def run(self):
33        while self._doRun:
34            startTime = (int)(time.time())
35            timer = Timer(5, self._migrate, ())
36            timer.start()
37            timer.join()
38            diffTime = startTime + self.interval - (int)(time.time()) 
39            if diffTime > 0:
40                time.sleep(diffTime)
41   
42    def _printTime(self):
43        print "From print_time", time.time()   
44
45    def _migrate(self):
46        lr = LoadResources()
47        lr.process()
48
49        mp = MigrationProcess()
50        mp.process()
51
Note: See TracBrowser for help on using the repository browser.