Leider habe ich ein Problem, bei dem ich nicht weiter weiß:
Ich habe ein Script namens "SCL_UTF8_TO_ANSI.py":
Code: Alles auswählen
#!/Python24/python.exe
# -*- coding: iso-8859-1 -*-
# File: SCL_UTF8_TO_ANSI.py
import os
def main():
path = path = os.getcwd() + '\\'
filepath_utf8 = path + 'UTF8.xml'
print filepath_utf8
pos = filepath_utf8.find('.')
filepath_ansi = filepath_utf8[:pos] + '_ansi' + filepath_utf8[pos:]
file_utf8 = file(filepath_utf8, 'r')
code_utf8 = file_utf8.read()
code_ansi = code_utf8.decode('utf-8').encode('iso-8859-1')
file_ansi = file(filepath_ansi, 'w')
file_ansi.write(code_ansi)
file_utf8.close()
file_ansi.close()
#-----------------------------------------------------
if __name__ == '__main__':
main()
Das obige Skript funktioniert wunderbar. Es legt die Datei "UTF8.xml" als "UTF8_ansi.xml" in ANSI-Kodierung ins selbe Verzeichnis.
Nun zu meinem Problem:
Ich benötige eine ausführbare *.exe-Datei. Hierfür verwende ich (bisher immer erfolgreich) FreezePython. Ich habe mir ein kleines Skript geschrieben, mit welchem ich FreezePython aufrufe, damit es mir aus dem obigen Skript "SCL_UTF8_TO_ANSI.py" eine "SCL_UTF8_TO_ANSI.exe" erstellt:
Code: Alles auswählen
#!/Python24/python.exe
# -*- coding: iso-8859-1 -*-
# File: setup_erstellen.py
import os
import subprocess
import sys
CWD = os.getcwd()
PATH = CWD + '\\'
SCRIPTNAME = 'SCL_UTF8_TO_ANSI.py' # name of main script file to compile with Freeze
SCRIPTPATH = PATH + SCRIPTNAME
EXENAME = 'SCL_UTF8_TO_ANSI.exe'
#-----------------------------------------------------
class Installer:
def __init__(self):
self.compile()
#-----------------------------------------------------
def compile(self):
# compile python script
if os.path.isfile(SCRIPTPATH):
cmd = 'FreezePython -c --install-dir=%s --base-name=Console.exe --target-name=%s %s'%(
PATH, EXENAME, SCRIPTPATH)
print cmd
p = subprocess.Popen(cmd, shell = True)
result = p.wait()
success = not result
if not success:
raw_input('Fehler:\nFreezePython konnte\n"%s"\nnicht kompilieren!\nFehlercode: %d%s'%(result, success, ErrMsg))
return -1
#-----------------------------------------------------
if __name__ == '__main__':
Installer()
Versionen:
Python: 2.5.1
FreezePython: 3.0.3
Vielleicht hat ja jemand eine Idee?
Viele Grüße
JR