Package Ganga :: Package Utility :: Package AMGAServerTools :: Module mdinterface
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Utility.AMGAServerTools.mdinterface

  1  # 
  2  # $Id: mdinterface.py,v 1.1 2008-07-17 16:41:01 moscicki Exp $ 
  3  # 
4 -class CommandException(Exception):
5 """ Raised when the command failed to execute on the server. 6 This is not a fatal error, the connection is not necessarily 7 broken after this exception is raised. 8 """
9 - def __init__(self, errorCode, msg):
10 self.errorCode = errorCode 11 self.msg = msg
12
13 - def __str__(self):
14 return repr(self.errorCode) + ' - ' + repr(self.msg)
15
16 -class MDInterface:
17 - def eot(self):
18 print "Please implement eot"
19 20
21 - def getattr(self, file, attributes):
22 print "Please implement getattr"
23 24
25 - def getEntry(self):
26 print "Please implement getEntry"
27 28
29 - def setAttr(self, file, keys, values):
30 print "Please implement setAttr"
31 32
33 - def addEntry(self, file, keys, values):
34 print "Please implement addEntry"
35 36
37 - def addEntries(self, entries):
38 print "Please implement addEntries"
39 40
41 - def addAttr(self, file, name, t):
42 print "Please implement addAttr"
43 44
45 - def removeAttr(self, file, name):
46 print "Please implement removeAttr"
47 48
49 - def clearAttr(self, file, name):
50 print "Please implement clearAttr"
51 52
53 - def listEntries(self, pattern):
54 print "Please implement listEntries"
55 56
57 - def pwd(self):
58 print "Please implement pwd"
59 60
61 - def listAttr(self, file):
62 print "Please implement listAttr"
63 64
65 - def createDir(self, dir):
66 print "Please implement createDir"
67 68
69 - def removeDir(self, dir):
70 print "Please implement removeDir"
71 72
73 - def rm(self, path):
74 print "Please implement rm"
75 76
77 - def selectAttr(self, attributes, query):
78 print "Please implement selectAttr"
79 80
81 - def getSelectAttrEntry(self):
82 print "Please implement getSelectAttrEntry"
83 84
85 - def updateAttr(self, pattern, updateExpr, condition):
86 print "Please implement updateAttr"
87 88
89 - def upload(self, collection, attributes):
90 print "Please implement upload"
91 92
93 - def put(self, file, values):
94 print "Please implement put"
95 96
97 - def abort(self):
98 print "Please implement abort"
99 100
101 - def commit(self):
102 print "Please implement commit"
103 104
105 - def sequenceCreate(self, name, directory, increment=1, start=1):
106 print "Please implement sequenceCreate"
107 108
109 - def sequenceNext(self, name):
110 print "Please implement sequenceNext"
111 112
113 - def sequenceRemove(self, name):
114 print "Please implement sequenceRemove"
115 116
117 - def splitUpdateClause(self, clause):
118 #skip leading white space 119 i = 0 120 while i<len(clause) and (clause[i] == ' ' or clause[i] == '\t'): 121 i = i +1 122 clause=clause[i:] 123 124 espcaped = False 125 quoted = False 126 i = 0 127 while i < len(clause): 128 if clause[i] == "'" and not escaped: 129 quoted = not quoted 130 if clause[i] == '/': 131 escaped = not escaped 132 if (clause[i] == ' ' or clause[i] == '/t') and not quoted: 133 break 134 i = i + 1 135 if i==0 or i>=len(clause)-1: 136 raise mdinterface.CommandException(3, "Invalid update statement") 137 138 var = clause[0:i] 139 exp = clause[i+1:] 140 i1 = exp.find("'") 141 i2 = exp.rfind("'") 142 if i1==0 and i2 == len(exp)-1: 143 exp = exp[i1+1:i2] 144 i1 = var.find("'") 145 i2 = var.rfind("'") 146 if i1==0 and i2 == len(var)-1: 147 var = var[i1+1:i2] 148 return var, exp
149