a python script for compiling swf
import sysimport osimport xml.etree.ElementTree as etimport loggingimport reimport getopt pathList={}#read the xml filedef load_xml_file(fileName): root = et.parse(fileName).getroot() for child in root: pathList[child.tag]=child.text #End of load_xml_file #log the informationdef logTofile(msg,toFile=True): if msg=='\n': return if (toFile): m=re.search('error',msg,re.IGNORECASE) if bool(m): logging.error(msg) else: logging.info(msg) print(msg)#End of logTofile def usage(): print("""DBAutoCompiler [-h|-l]Options and arguments:-h : Help-l : Load the config file""")#End of usage def main(argv): if __name__ == '__main__': try: opts,args=getopt.getopt(argv[1:],"hl:") except getopt.GetoptError: usage() sys.exit() else: logTofile("It's not allowed from other module") sys.exit() #the default configure file configFilePath="config.xml" for opt,arg in opts: if opt =='-h': usage() sys.exit() elif opt == '-l': configFilePath=arg #end of if #end of for #load the configure load_xml_file(configFilePath) #Get all file in dir files=os.listdir(pathList["filePath"]) #Avoid the Access Denied Error os.chdir(pathList["filePath"]) #Init the logging system logging.basicConfig(filename = os.path.join(os.getcwd(), 'log.txt'), level = logging.DEBUG,filemode = 'w', format = '%(asctime)s - %(levelname)s: %(message)s') #file counter finishedFile=0 for f in files: os.chdir(pathList["filePath"]) logTofile("Compiling "+str(finishedFile)+"th file Total File(s) :"+str(len(files))) if (os.path.isdir(pathList["filePath"]+os.sep+f)): logTofile("Not a file ,pass it") pass else: #print(f) if (os.path.isfile(pathList["filePath"]+os.sep+f)): #print("Is a file") if ((f.split('.')[-1]=='as')): #print("mxmlc "+f)v #if os.path.isfile(pathList["outputPath"]+os.sep+f.split('.')[0]+".swf"): # os.chmod(pathList["outputPath"]+os.sep+f.split('.')[0]+".swf", stat.S_IWRITE) # os.remove(pathList["outputPath"]+os.sep+f.split('.')[0]+".swf") command = pathList["flexSDKPath"]+os.sep+"mxmlc "+pathList["filePath"]+os.sep+f #if ("outputPath" in pathList ): # os.chdir(pathList["outputPath"]) # command =command + " -output "+pathList["outputPath"] if ("libraryPath" in pathList): command =command + " -library-path+="+pathList["libraryPath"] if ("staticLinkRuntimeSharedLibraries" in pathList): command =command + " -static-link-runtime-shared-libraries=" +pathList["staticLinkRuntimeSharedLibraries"] logTofile("Compilation command:") logTofile(command) result= os.popen(command).read() logTofile("Compilation result:") for line in result.split('\n'): if line.split(): logTofile(line) if ("outputPath" in pathList ): if 'nt'==os.name: result=os.popen("move /y " +f.split('.')[0]+".swf "+ pathList["outputPath"]).read() else: result=os.popen("mv -f "+f.split('.')[0]+".swf "+ pathList["outputPath"]).read() for line in result.split('\n'): if line.split(): logTofile(line) else: logTofile("Not a as file ,pass it.") pass #end of if #end of if #end of if finishedFile=finishedFile+1 logTofile("Finished File(s):"+str(finishedFile)+" Total File(s) :"+str(len(files))) logTofile("================================================================",False) logTofile("Compilation is finished.Total file number is :"+str(len(files))) #end of for#End of mainmain(sys.argv)
You must Sign up as a member of Effecthub to view the content.
ChOw
2013-08-30
A PHP Error was encountered
Severity: Notice
Message: Undefined index: HTTP_ACCEPT_LANGUAGE
Filename: helpers/time_helper.php
Line Number: 22
1819 views 1 comments
You must Sign up as a member of Effecthub to join the conversation.