Hi Bob.

Thanks for your prompt answer.
Yes, you were obvioulsy right, my sources files had null bytes on
them. The funny thing is, I got them cutting and pasting code from the
the wx demo... evil...

If I can make a suggestions, when you can, write an error message that
will warn about this together with the offending source file, line
number and char number. If that's possible, that would be great help!

I've hacked a utility to remove null byte chars from python source
files. It's not very efficient(the way it's reading the sources files
and all) but it works, maybe it can help somebody. I am attaching it
to this email, maybe it will be useful.

Again, thanks for you help, 
Arthur

2005/6/27, Bob Ippolito <[EMAIL PROTECTED]>:
> On Jun 27, 2005, at 12:36 AM, Arthur Debert wrote:
> 
> > Sorry if this is too basic, but I'm having real trouble getting
> > py2app working.
> > I have an application writen in python 2.4 that uses wxPython(2.6)
> > and 4Suite.
> >
> > Two questions:
> > a) i can't make much sense about this on the documentation. From what
> > I understood, all I have to do is point the setup.py script to the
> > 'main' script of my application, and the module graph should find and
> > package all the needed frameworks (such as wxPython and 4Suite). Is
> > this right? If not, where should I specify that I am using these
> > frameworks?
> >
> > b) when tryiing to build setup.py I get the following error:
> > "
> > TypeError: compile() expected string without null bytes
> >
> >> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/
> >> site-packages/py2app/modulegraph/modulegraph.py(376)load_module()
> >>
> > -> co = compile (fp.read().replace("\r\n", "\n")+'\n',pathname,
> > 'exec')
> > "
> >
> > ouch! what does that mean?
> 
> It means what it says, one of your Python scripts has null bytes in
> it.  That shouldn't happen.  I've never seen it happen with wx, so
> it's either your code or 4suite.  I'll have the next version of
> py2app do something nicer when that happens.  No idea when I'll have
> time to do that, though.
> 
> -bob
> 
>
def getPythonFiles(basePath):
	import os
	os.chdir(basePath)
	pythonFiles = []
	for file in os.listdir(os.getcwd()):
		if file[-3:]=='.py' and file.count('nullbyteremover')==0:
			pythonFiles.append(file)
	return pythonFiles

def replaceTextInFile(filePath, toFind, toReplace):
	print 'File: %s' % filePath
	file = open(filePath, 'r')
	fileContent = file.readlines()
	file.close()
	
	ocurrences = 0
	outText = []
	for line in fileContent:
		ocurrences += line.count(toFind)
		outText.append(line.replace(toFind, toReplace))
	
	print 'found %s ocurrences\n%s' % (str(ocurrences), 30*'*')
	fileOut = open(filePath, 'w')
	fileOut.writelines(outText)
	fileOut.close()
	return ocurrences

def runMain(basePath, toFind, ToReplace):
	files = getPythonFiles(basePath)
	totalOcurrences = 0
	for file in files:
		totalOcurrences += replaceTextInFile(file, toFind, ToReplace)
	print '\n%s\nfound and replaced a total of %s' % (30*'*', str(totalOcurrences))

if __name__ == '__main__':
	import os
	base_path  =  raw_input("where should I look for sources?")
	if base_path=='':
		base_path = os.getcwd()
	runMain(base_path, '\000', '')
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to