ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/RefDBInfo.py
Revision: 1.2
Committed: Wed Sep 27 14:20:46 2006 UTC (18 years, 7 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Log Message:
remove obsolete ORCA related files

File Contents

# Content
1 #!/usr/bin/env python
2 import sys, os, string, re
3 import urllib, urllister
4 import urllib2
5 from UnserializePHP import *
6
7 class RefDBError:
8 def __init__(self, owner, dataset):
9 print '\nERROR accessing RefDB for Owner/Dataset: '+owner+'/'+dataset+'\n'
10 pass
11 class RefDBNoCollectionError:
12 def __init__(self, owner, dataset):
13 print '\nERROR No Collection Owner/Dataset found in RefDB : '+owner+'/'+dataset+'\n'
14 pass
15 class NoPHPError:
16 def __init__(self, url):
17 #print '\nERROR accessing PHP at '+url+' \n'
18 print 'ERROR accessing PHP: ',url,'isn\'t updated version \n'
19 pass
20 class RefDBResult:
21 def __init__(self,
22 contents):
23 self.contents=contents
24
25 ##################################################################################
26 # Class to connect to RefDB and download the data in one shot using the serialized PHP data.
27 # Python doesn't allow to un-serialize PHP serialized objects. An "ad hoc" un-serialization is thus used.
28 ###############################################################################
29
30 class RefDBInfo:
31 def __init__(self, owner, dataset):
32 self.owner = owner
33 self.dataset = dataset
34 self.RefDBurl_ = 'http://cmsdoc.cern.ch/cms/production/www/'
35 self.RefDBMotherphp_ = 'cgi/SQL/CollectionTree.php'
36
37
38 def GetRefDBInfo(self):
39 try:
40 f = urllib.urlopen(self.RefDBurl_+self.RefDBMotherphp_+'?format=serialized&owner='+self.owner+'&dataset='+self.dataset)
41 except IOError:
42 raise RefDBError(self.owner,self.dataset)
43
44 data = f.read()
45 if len(data)>0:
46 if data[0]=='<':
47 if (data.find("down") > -1) :
48 print "\n WARNING: RefDB is temporarily down for a short maintenace \n"
49 raise RefDBError(self.owner,self.dataset)
50 else:
51 raise RefDBNoCollectionError(self.owner,self.dataset)
52 try:
53 collections = PHPUnserialize().unserialize(data)
54 except IOError:
55 raise PHPUnserializeError(data)
56 collinfos=[]
57 try:
58 for k in collections.keys():
59 #if collections[k]['type']!='PU':
60 collinfos.append([collections[k]['id'],collections[k]['name'],collections[k]['type'],collections[k]['oname'],collections[k]['dname']])
61 except IOError:
62 raise PHPUnserializeError(data)
63 return collinfos
64
65
66
67
68
69
70