?? dvd-server,v
字號:
raise DVD.MEMBERSHIP.NOSUCHMEMBER
def create (self, recordtoadd):
lastid = DBMAX["members"]
lastid = lastid + 1
logit("Membership", "Create new member record - %d" % lastid)
DBMAX["members"] = lastid
recordtoadd.memberid = lastid
recordtoadd.memberno = "%d" % lastid
SHMEMBERS[idtostring(lastid)]=stringizemember(recordtoadd)
SHMEMBERS.sync()
logit("Membership", "Create new member for %d" % lastid)
return lastid
def search (self, lname):
rseq = []
try:
(key,value)=SHMEMBERS.first()
while 1 == 1:
lst=string.split(value, "\\")
surname=lst[4]
if string.upper(surname) == string.upper(lname):
rseq.append (string.atoi(key))
(key,value)=SHMEMBERS.next()
except:
done = ""
logit("Membership", "Search for %s" % lname)
return rseq
def idfromnumber (self, memberno):
logit("Membership", "id-to-number for %s" % memberno)
try:
(key,value)=SHMEMBERS.first()
while 1 == 1:
lst = string.split(value, "\\")
no = lst[1]
if no == memberno:
return string.atoi(key)
(key,value) = SHMEMBERS.next()
except:
raise DVD.MEMBERSHIP.NOSUCHMEMBER
d265 60
a324 57
def set (self, recordtoupdate):
try:
SHTITLES[idtostring(recordtoupdate.titleid)]= stringizetitle(recordtoupdate)
SHTITLES.sync()
except:
logit("TITLING", "Failure of set() contents for title %d" % recordtoupdate.titleid)
logit("TITLING", "Success of set() contents for title %d" % recordtoupdate.titleid)
def get (self, titleid):
try:
record=SHTITLES[idtostring(titleid)]
except:
logit("TITLING", "failure of get() contents for title %d" % titleid)
raise DVD.TITLING.NOSUCHTITLE
logit("TITLING", "Success of get() contents for title %d" % titleid)
return destringizetitle(record)
def delete (self, titleid):
try:
del SHTITLES[idtostring(titleid)]
SHTITLES.sync()
logit("Titling", "delete contents for %d" % titleid)
except:
raise DVD.TITLING.NOSUCHTITLE
def create (self, recordtoadd):
lastid = DBMAX["titles"]
lastid = lastid + 1
logit("Titling", "Create new title record - %d" % lastid)
DBMAX["titles"] = lastid
recordtoadd.memberid = lastid
SHTITLES[idtostring(lastid)]=stringizetitle(recordtoadd)
SHTITLES.sync()
return lastid
def search (self, title, name):
rseq = []
try:
(key,value)=SHTITLES.first()
while 1 == 1:
lst=string.split(value, "\\")
titletext=lst[1]
director=lst[3]
actor1=lst[6]
actor2=lst[7]
keep="NO"
if string.upper(director) == string.upper(name):
keep = "YES"
if string.upper(actor1) == string.upper(name):
keep = "YES"
if string.upper(actor2) == string.upper(name):
keep = "YES"
if string.upper(titletext) == string.upper(title):
keep = "YES"
if keep == "YES":
rseq.append (string.atoi(key))
(key,value)=SHTITLES.next()
except:
done = ""
logit("Titling", "Search for %s" % title)
return rseq
d328 2
a329 2
SHDISKS[idtostring(recordtoupdate.diskid)]= stringizedisk(recordtoupdate)
SHDISKS.sync()
d331 1
a331 1
logit("DISKS", "Failure to set %d" % recordtoupdate.diskid)
d335 1
a335 1
record=SHDISKS[idtostring(diskid)]
d337 2
logit("DISKS", "Failure of get() contents for disk %d" % diskid)
raise DVD.DISKS.NOSUCHDISK
d353 3
a355 3
del SHDISKS[idtostring(diskid)]
SHDISKS.sync()
logit("Disks", "delete contents for %d" % diskid)
d357 1
a357 1
raise DVD.DISKS.NOSUCHDISK
d361 6
a366 6
(key,value)= SHDISKS.first()
while 1 == 1:
lst=string.split(value, "\\")
if string.atoi(lst[1]) == titleid:
rseq.append (string.atoi(key))
(key,value)= SHDISKS.next()
d368 1
a368 1
done = ""
d374 17
a390 1
print "Finish RENTAL::renttitle()"
a420 1
print "Errortext..."
d435 7
a441 7
logior = open("./logger.ior").readline()
LOGORB = orb.string_to_object(logior)
print LOGORB.__repo_id
LOGORB.addlog(LOG.loginfo(hostname="knuth", userid="cbbrowne",
application="dvd-server",
messagetype="info",
shortmessage="Start up DVD Server"))
d443 1
a443 1
print "Could not open Logger!"
@
1.2
log
@*** empty log message ***
@
text
@a12 1
print "SHMEMBERS: ", SHMEMBERS
a18 1
print "SHDISKS in maxfordisks()", SHDISKS
d22 10
a31 6
max = 1
for i in SHDISKS.keys():
iint=string.atoi(i)
if iint > max:
max=iint+1
DBMAX["disks"] = max
a32 1
print "SHMEMBERS in maxformembers()", SHMEMBERS
d37 9
a45 5
for i in SHMEMBERS.keys():
iint=string.atoi(i)
if iint > max:
max=iint+1
DBMAX["members"] = max
a46 1
print "SHTITLES in maxfortitles()", SHTITLES
d50 10
a59 6
max = 1
for i in SHTITLES.keys():
iint=string.atoi(i)
if iint > max:
max=iint+1
DBMAX["titles"] = max
a114 2
for i in DBMAX.keys():
print " Max for ", i, " is : ", DBMAX[i]
d173 16
a199 1
print "Update id:", recordtoupdate.memberid, " with: ", recordtoupdate
a201 1
print "Finish MEMBERSHIP::set()"
a210 1
logit("Membership", "delete contents for %d" % memberid)
d213 1
d216 1
a216 1
raise MEMBERSHIP.NOSUCHMEMBER
a219 1
print ("New Member ID: %d" % lastid)
d226 1
d230 11
a240 6
for i in SHMEMBERS.keys():
print SHMEMBERS[i]
lst=string.split(SHMEMBERS[i], "\\")
surname=lst[4]
if string.upper(surname) == string.upper(lname):
rseq.append (string.atoi(i))
d243 11
a253 5
for i in SHMEMBERS.keys():
(id, no) = string.split(SHMEMBERS(i))
if no == memberno:
return string.atoi(id)
raise MEMBERSHIP.NOSUCHMEMBER
d257 2
a258 1
SHTITLES[idtostring(recordtoupdate.titleid)]=recordtoupdate
a260 1
raise MEMBERSHIP.NOSUCHTITLE
d262 1
a262 2
print "Finish TITLING::set()"
def get (self, memberid):
d264 1
a264 1
record=SHTITLES[idtostring(memberid)]
d266 4
a269 6
logit("TITLING", "failure of get() contents for title %d" % recordtoupdate.titleid)
raise TITLING.NOSUCHTITLE
logit("TITLING", "Success of get() contents for title %d" % recordtoupdate.titleid)
return record
def create (self, recordtoadd):
print "Finish TITLING::get()"
d273 2
d276 1
a276 2
raise MEMBERSHIP.NOSUCHMEMBER
print "Finish TITLING::delete()"
d278 34
a311 4
print "Finish TITLING::get()"
def search (self, name):
print "Finish TITLING::search()"
d314 6
a319 1
print "Finish DISKS::set()"
d321 7
a327 1
print "Finish DISKS::get()"
d329 9
a337 1
print "Finish DISKS::get()"
d339 6
a344 1
print "Finish DISKS::delete()"
d346 12
a357 1
print "Finish DISKS::search()"
@
1.1
log
@Initial revision
@
text
@d2 1
a2 1
import CORBA, sys, regex, string, random, time, shelve, bsddb
d6 104
d115 1
d124 1
d133 1
d142 1
d151 1
d160 1
d165 10
d177 4
a180 5
try:
print "Update id:", recordtoupdate.memberid, " with: ", recordtoupdate
SHMEMBERS[idtostring(recordtoupdate.memberid)]=recordtoupdate
except:
raise MEMBERSHIP.NOSUCHMEMBER
d186 4
a189 2
raise MEMBERSHIP.NOSUCHMEMBER
return record
d191 1
d194 1
d198 10
a207 1
print "Finish MEMBERSHIP::create()"
d209 8
a216 1
print "Finish MEMBERSHIP::search()"
d218 5
a222 1
print "Finish MEMBERSHIP::idfromnumber()"
d228 1
d230 1
d236 1
d238 1
d289 1
d292 1
d296 1
a307 84
class SETUPCOUNTERS:
def maxforall(self):
self.maxfordisks()
self.maxformembers()
self.maxfortitles()
def maxfordisks(self):
if DBMAX.has_key("disks"):
max = DBMAX["disks"]
else:
max = 1
for i in SHDISKS.keys():
rec=SHDISKS[i]
if rec.diskid > max:
max=rec.diskid+1
DBMAX["disks"] = max
def maxformembers(self):
if DBMAX.has_key("members"):
max = DBMAX["members"]
else:
max = 1
for i in SHMEMBERS.keys():
rec=SHMEMBERS[i]
if rec.memberid > max:
max=rec.memberid+1
DBMAX["members"] = max
def maxfortitles(self):
if DBMAX.has_key("titles"):
max = DBMAX["titles"]
else:
max = 1
for i in SHTITLES.keys():
rec=SHTITLES[i]
if rec.titleid > max:
max=rec.titleid+1
DBMAX["titles"] = max
def idtostring (id):
return "%d" % id
### Initialization of non-ORB stuff...
FACTORYOBJECT = {}
DBMAX = {}
ERRNDICT = {
-1 : "DVD_ERR_NO_FILE" ,
-2 : "DVD_ERR_BAD_TABLE" ,
-3 : "DVD_ERR_NO_MEMBER_TABLE" ,
-4 : "DVD_ERR_BAD_MEMBER_TABLE",
-5 : "DVD_ERR_BAD_TITLE_TABLE" ,
-6 : "DVD_ERR_BAD_DISK_TABLE" ,
-7 : "DVD_ERR_BAD_SEEK" ,
-8 : "DVD_ERR_NULL_POINTER" ,
-9 : "DVD_ERR_BAD_WRITE" ,
-10 : "DVD_ERR_BAD_READ" ,
-11 : "DVD_ERR_NOT_FOUND" ,
-12 : "DVD_ERR_NO_MEMORY" ,
-13 : "DVD_ERR_BAD_RENTAL_TABLE" ,
-14 : "DVD_ERR_BAD_RESERVE_TABLE" }
ERRMSGDICT = {
"DVD_SUCCESS" : "no error",
"DVD_ERR_NO_FILE" : "cannot open file",
"DVD_ERR_BAD_TABLE" : "corrupt table file",
"DVD_ERR_NO_MEMBER_TABLE" : "no member table",
"DVD_ERR_BAD_MEMBER_TABLE" : "corrupt member table",
"DVD_ERR_BAD_TITLE_TABLE" : "corrupt title table",
"DVD_ERR_BAD_DISK_TABLE" : "corrupt disk table",
"DVD_ERR_BAD_RENTAL_TABLE" : "corrupt rental table",
"DVD_ERR_BAD_RESERVE_TABLE" : "corrupt reserve table",
"DVD_ERR_BAD_SEEK" : "cannot seek in file",
"DVD_ERR_NULL_POINTER" : "null data pointer",
"DVD_ERR_BAD_WRITE" : "cannot write to file",
"DVD_ERR_BAD_READ" : "cannot read file",
"DVD_ERR_NOT_FOUND" : "no match found",
"DVD_ERR_NO_MEMORY" : "out of memory"}
### Connect Python "Shelves" to the various objects
SHDISKS=shelve.open("disks.db")
SHMEMBERS=shelve.open("members.db")
SHRENTALS=shelve.open("rentals.db")
SHRESERVATIONS=shelve.open("reservations.db")
SHTITLES=shelve.open("titles.db")
SETUP=SETUPCOUNTERS()
SETUP.maxforall()
d312 1
a312 2
try:
@
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -