[Bio] / BioSimScratch / buildNewBssCatalog.py Repository:
ViewVC logotype

Annotation of /BioSimScratch/buildNewBssCatalog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (view) (download) (as text)

1 : efrank 1.1 #########################################################################
2 :     # This is a program that transforms the old style BSS catalog to
3 :     # the new style. It exercises a few things in the catalog code, but
4 :     # is probably NOT a good example of how to code: it drills into
5 :     # various things that ought to be encapsulated. This is needed to effect
6 :     # the migration.
7 :     #########################################################################
8 :    
9 :    
10 :     from FaST.BssFactory import BssFactory
11 :     from CatalogServices.Catalog import Catalog
12 : efrank 1.5 from FoundryInfo.FoundryItemKey import FoundryItemKey
13 : efrank 1.1
14 : efrank 1.4 b=BssFactory("biosimscratch/bss@db02", "oracle")
15 : efrank 1.1
16 : efrank 1.2 oldEntryDict = {}
17 : efrank 1.1 oldEntryList = b.getLsCat()
18 :     print "Old Style Catalog Entries:"
19 :     for o in oldEntryList:
20 :     print o
21 : efrank 1.2 oldEntryDict[ o[0] ] = o[1]
22 : efrank 1.1 print ""
23 :    
24 :    
25 : efrank 1.2
26 : efrank 1.1 bssTop=b.getCatalogTop()
27 :     print "Previously Existing New Style Entries:"
28 :     for be in bssTop.entries():
29 :     print "\t", (be.name())
30 :     print
31 :    
32 :     print "Adding new style entries"
33 :     for o in oldEntryList:
34 :     try:
35 :     newItem = bssTop.mkItem( o[0] )
36 :     print "\tAdded new item with name ", newItem.name()
37 :     except Exception, e:
38 :     print "FAILed to add new item with name ", o[0]
39 :     print "Exception raised is", e
40 :    
41 :    
42 :    
43 : efrank 1.2 #
44 :     # tack on the actual reconstructions
45 :     #
46 :    
47 : efrank 1.1 bssTop=b.getCatalogTop()
48 :     print
49 :     print "New state of New Styple Catalog:"
50 :     for be in bssTop.entries():
51 :     print "\t", (be.name())
52 : efrank 1.2 procId = oldEntryDict[ be.name() ]
53 : efrank 1.3 k = FoundryItemKey( b.getFoundryId(), [procId], [] )
54 :     print "\thas versions: ", be.versions()
55 : efrank 1.2 try:
56 :     be.setFoundryItem( k )
57 :     except:
58 :     print "Could not add foundry item for ", be.name()
59 :    
60 : efrank 1.3 print "\thas versions: ", be.versions()
61 : efrank 1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3