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

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

the infodb session was not injected in the migration process

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.processor.EPBRepo import EPBRepo
13
14class MigrationThread(threading.Thread):
15    """
16        Constructs a scheduler for the Moles2 to Moles3 migration.
17        Only one instance should be running for each python interpreter
18        @param interval: define the minimal time, in seconds, between an execution and the successive.
19        If the current migration run takes more than the defined interval the next will starts
20        as soon the previous ends.         
21    """
22   
23    def __init__(self, moles3EPB, migrationEPB, infodbEPB, interval=600):
24        EPBRepo.moles3EPB = moles3EPB
25        EPBRepo.migrationEPB = migrationEPB
26        EPBRepo.infodbEPB = infodbEPB
27       
28        threading.Thread.__init__(self)
29        self._doRun = True   
30        self.interval = interval
31   
32    def stop(self):
33        self._doRun = False
34   
35    def run(self):
36        while self._doRun:
37            startTime = (int)(time.time())
38            timer = Timer(5, self._migrate, ())
39            timer.start()
40            timer.join()
41            diffTime = startTime + self.interval - (int)(time.time()) 
42            if diffTime > 0:
43                time.sleep(diffTime)
44   
45    def _printTime(self):
46        print "From print_time", time.time()   
47
48    def _migrate(self):
49        lr = LoadResources()
50        ex = lr.process()
51        for e in ex:
52            print e
53
54        mp = MigrationProcess()
55        ex = mp.process()
56        for e in ex:
57            print e
Note: See TracBrowser for help on using the repository browser.