From 16d1e0224e87e85353e3e64db5a4a49682e25971 Mon Sep 17 00:00:00 2001 From: temitchell Date: Sat, 28 Aug 2004 00:19:39 +0000 Subject: [PATCH] - change path finding to use os.path - hopefully this will fix these scripts for the (new) windows server - CFgetPaths is now dead and will be removed - change your scripts if you use it. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/trunk/maps@2891 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/CFBank.py | 6 ++-- python/CFBoard.py | 6 ++-- python/CFGamble.py | 4 +-- python/CFLog.py | 60 +++++++++++++++++----------------- python/CFMail.py | 5 +-- python/CFgetPaths.py | 3 ++ python/IPO/banksay.py | 3 +- python/IPO/board.py | 3 +- python/IPO/receive.py | 3 +- python/IPO/say.py | 3 +- python/IPO/seen.py | 3 +- python/IPO/send.py | 3 +- python/casino/diamondslots.py | 3 +- python/casino/goldslots.py | 3 +- python/casino/imperialslots.py | 3 +- python/casino/platinumslots.py | 3 +- python/casino/silverslots.py | 3 +- 17 files changed, 66 insertions(+), 51 deletions(-) diff --git a/python/CFBank.py b/python/CFBank.py index 94d1dd2ad..8d3d18f0b 100644 --- a/python/CFBank.py +++ b/python/CFBank.py @@ -20,16 +20,16 @@ # #Updated to use new path functions in CFPython -Todd Mitchell - +import os.path import shelve -import CFgetPaths +import CFPython class CFBank: bankdb = {} def __init__(self, bankfile): - self.bankdb_file = '%s%s' % (CFgetPaths.getPaths('localdir'),bankfile) + self.bankdb_file = os.path.join(CFPython.GetLocalDirectory(),bankfile) self.bankdb = shelve.open(self.bankdb_file) def deposit(self, user, amount): diff --git a/python/CFBoard.py b/python/CFBoard.py index 95669fd38..3675d7ffd 100644 --- a/python/CFBoard.py +++ b/python/CFBoard.py @@ -20,14 +20,14 @@ # #Updated to use new path functions in CFPython -Todd Mitchell - +import os.path import shelve -import CFgetPaths +import CFPython class CFBoard: - boarddb_file = '%scrossfireboard' % (CFgetPaths.getPaths('localdir')) + boarddb_file = os.path.join(CFPython.GetLocalDirectory(),'crossfireboard') boarddb = {} total = 0 diff --git a/python/CFGamble.py b/python/CFGamble.py index 1de64116f..fa2d3953d 100644 --- a/python/CFGamble.py +++ b/python/CFGamble.py @@ -8,13 +8,13 @@ import os.path import shelve import random -import CFgetPaths +import CFPython class SlotMachine: #sets up the file that holds all the slotmachine jackpots #make sure this points to your writable var/crossfire directory #you can delete that file to reset all the slotmachine jackpots - slotfile = '%sSlotMachine_file' %(CFgetPaths.getPaths("localdir")) + slotfile = os.path.join(CFPython.GetLocalDirectory(),'SlotMachine_file') slotdb = {} def __init__(self,slotname,slotlist,minpot,maxpot): slotdb = shelve.open(self.slotfile) diff --git a/python/CFLog.py b/python/CFLog.py index ed43ef21c..943526198 100644 --- a/python/CFLog.py +++ b/python/CFLog.py @@ -21,43 +21,43 @@ #Updated to use new path functions in CFPython -Todd Mitchell import shelve +import os.path - -import CFgetPaths +import CFPython from time import localtime, strftime, time class CFLog: - logdb_file = '%scrossfirelog' % (CFgetPaths.getPaths('localdir')) - logdb = {} + logdb_file = os.path.join(CFPython.GetLocalDirectory(),'crossfirelog') + logdb = {} - def __init__(self): - self.logdb = shelve.open(self.logdb_file) + def __init__(self): + self.logdb = shelve.open(self.logdb_file) - def create(self, name): - date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time())) - count=1 - self.logdb[name]=['unknown', date, count] + def create(self, name): + date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time())) + count=1 + self.logdb[name]=['unknown', date, count] - def update(self, name, ip): - date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time())) - count=0 - if self.logdb.has_key(name): - oldip, olddate, count=self.logdb[name] - count+=1 - self.logdb[name]=[ip, date, count] + def update(self, name, ip): + date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time())) + count=0 + if self.logdb.has_key(name): + oldip, olddate, count=self.logdb[name] + count+=1 + self.logdb[name]=[ip, date, count] - def remove(self, name): - if self.logdb.has_key(name): - del self.logdb[name] - - def exist(self, name): - if self.logdb.has_key(name): - return 1 - else: - return 0 + def remove(self, name): + if self.logdb.has_key(name): + del self.logdb[name] + + def exist(self, name): + if self.logdb.has_key(name): + return 1 + else: + return 0 - def info(self, name): - if self.exist(name): - ip, date, count=self.logdb[name] - return ip, date, count + def info(self, name): + if self.exist(name): + ip, date, count=self.logdb[name] + return ip, date, count diff --git a/python/CFMail.py b/python/CFMail.py index d4263d3fd..33bb01a3f 100644 --- a/python/CFMail.py +++ b/python/CFMail.py @@ -20,13 +20,14 @@ # #Updated to use new path functions in CFPython -Todd Mitchell +import os.path import shelve -import CFgetPaths +import CFPython class CFMail: - maildb_file = '%scrossfiremail' % (CFgetPaths.getPaths('localdir')) + maildb_file = os.path.join(CFPython.GetLocalDirectory(),'crossfiremail') maildb = {} total = 0 diff --git a/python/CFgetPaths.py b/python/CFgetPaths.py index 67055e08c..217a4846b 100644 --- a/python/CFgetPaths.py +++ b/python/CFgetPaths.py @@ -2,6 +2,9 @@ ## Todd Mitchell (temitchell@sympatico.ca) ## Generates the proper Crossfire directory paths ## returns the absolute paths with a nice "/" at the end. +## +## It is depreciated as it is of dubuois value and breaks paths for win32 systems +## DON"T USE THIS ANYMORE! It is being removed shortly. import CFPython diff --git a/python/IPO/banksay.py b/python/IPO/banksay.py index fb92f9808..a5761f718 100644 --- a/python/IPO/banksay.py +++ b/python/IPO/banksay.py @@ -25,7 +25,8 @@ import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import string import random diff --git a/python/IPO/board.py b/python/IPO/board.py index db60efbdb..f9668b961 100755 --- a/python/IPO/board.py +++ b/python/IPO/board.py @@ -26,7 +26,8 @@ import CFPython import CFBoard import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import string board = CFBoard.CFBoard() diff --git a/python/IPO/receive.py b/python/IPO/receive.py index e392b3b99..c6bc89775 100755 --- a/python/IPO/receive.py +++ b/python/IPO/receive.py @@ -22,7 +22,8 @@ import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import CFMail import string diff --git a/python/IPO/say.py b/python/IPO/say.py index 2429729b0..242262a44 100755 --- a/python/IPO/say.py +++ b/python/IPO/say.py @@ -34,7 +34,8 @@ priceMailScroll=5 import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import string import CFLog diff --git a/python/IPO/seen.py b/python/IPO/seen.py index 38c870d5b..c47dfb5a6 100644 --- a/python/IPO/seen.py +++ b/python/IPO/seen.py @@ -25,7 +25,8 @@ import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import CFLog diff --git a/python/IPO/send.py b/python/IPO/send.py index 20e5d4d7c..1ddcf503c 100755 --- a/python/IPO/send.py +++ b/python/IPO/send.py @@ -22,7 +22,8 @@ import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import CFMail import string diff --git a/python/casino/diamondslots.py b/python/casino/diamondslots.py index 543e7dae3..4179a4023 100644 --- a/python/casino/diamondslots.py +++ b/python/casino/diamondslots.py @@ -5,7 +5,8 @@ import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import CFGamble import CFItemBroker diff --git a/python/casino/goldslots.py b/python/casino/goldslots.py index 685a485b0..cdbfa90b2 100644 --- a/python/casino/goldslots.py +++ b/python/casino/goldslots.py @@ -4,7 +4,8 @@ import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import CFGamble import CFItemBroker diff --git a/python/casino/imperialslots.py b/python/casino/imperialslots.py index e8273605d..4a021a002 100644 --- a/python/casino/imperialslots.py +++ b/python/casino/imperialslots.py @@ -5,7 +5,8 @@ import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import CFGamble import CFItemBroker diff --git a/python/casino/platinumslots.py b/python/casino/platinumslots.py index 01e2b6066..2a37df05e 100644 --- a/python/casino/platinumslots.py +++ b/python/casino/platinumslots.py @@ -4,7 +4,8 @@ import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import CFGamble import CFItemBroker diff --git a/python/casino/silverslots.py b/python/casino/silverslots.py index dab76f8f8..0d5324b86 100644 --- a/python/casino/silverslots.py +++ b/python/casino/silverslots.py @@ -3,7 +3,8 @@ import CFPython import sys -sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) +import os.path +sys.path.append(os.path.join(CFPython.GetDataDirectory(),CFPython.GetMapDirectory(),'python')) import CFGamble import CFItemBroker