Crossfire Server, Trunk
CFMail_Init.py
Go to the documentation of this file.
1 import os.path
2 
3 import Crossfire
4 import CFMail
5 
6 def convert_bdb(mail):
7  filename = 'crossfiremail.db'
8  path = os.path.join(Crossfire.LocalDirectory(), filename)
9  if os.path.isfile(path):
10  Crossfire.Log(Crossfire.LogInfo, "Converting crossfiremail.db (BDB)")
11  import berkeleydb.dbshelve as shelve
12  old_db = shelve.open(path, 'r')
13  for to in old_db.keys():
14  allmail = old_db[to]
15  toname = to.decode('ascii')
16  for (t, fromname, msg) in allmail:
17  mail.send(t, toname, fromname, msg)
18  old_db.close()
19  bak_file = os.path.join(Crossfire.LocalDirectory(), filename + '.bak')
20  os.rename(path, bak_file)
21 
22 def main():
23  Crossfire.Log(Crossfire.LogInfo, "Initializing CFMail")
24  with CFMail.CFMail() as mail:
25  mail.init_schema()
26  convert_bdb(mail)
27 
28 main()
CFMail.CFMail
Definition: CFMail.py:7
CFMail_Init.main
def main()
Definition: CFMail_Init.py:22
CFMail_Init.convert_bdb
def convert_bdb(mail)
Definition: CFMail_Init.py:6