1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
 
import os
import os.path
from Common import mylog
from DBCommon import error
 
def DumpData(root, subDir, fileName, data):
    filePath = os.path.join(root, subDir)
    if not os.path.exists(filePath):
        os.makedirs(filePath)
    fileFullName = os.path.join(filePath, fileName)
    try:
        saveFile = open(fileFullName, 'wb')    #¸²¸Çʽ
        saveFile.write(data)
    except IOError, (errno, strerror):
        msg = error.formatMsg('error', error.ERROR_NO_37, 'I/O error(%s):%s fileName = %s'%(errno, strerror, fileFullName))
        mylog.error(msg)
    except:
        msg = error.formatMsg('error', error.ERROR_NO_38, 'DumpData!fileName = %s'%fileFullName)
        mylog.error(msg)
    else:
        saveFile.close()