Hi, No-one answered to my previous email, maybe you didn't know the answer or maybe it wasn't received properly. Anyway here is it again, does any of you know the answer? Im still struggling with it..
Previous email: I'm trying to convert my Python script, which is a COM server, to an exe file. I'm using py2exe 0.6.5. But I ran into a few problems. After a lot of work I was able to run py2exe on my script and create the exe file. I was able to use exectablename.exe --register and --unregister and it returned text that it registered/unregistered the com server, but I wasn't able to connect to it using VB .NET. VB gave me an error saying that it couldn't create the ActiveX component. The normal python file works normally if I try to import the com object from VB, but the exe doesn't work. So I think there's something I do wrong in the setup file or so, or maybe I have to put something else in my Python file, I dont know, I hope some of you do. Here is my Python script and the setup.py (for py2exe) script: setup.py: from distutils.core import setup import py2exe setup(console=['testcomserver.py'], scripts=['testcomserver.py'], name='testcomserver') actual script: from urllib import urlopen import sys import pythoncom class Runescape1: _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER if hasattr(sys, 'importers'): # In the py2exe-packed version, specify the module.class # to use. In the python script version, python is able # to figure it out itself. _reg_class_spec_ = "__main__.Runescape1" _reg_clsid_ = "{6CF99217-4AE8-486A-9858-BE798F8671BC}" _reg_progid_ = "Python.Runescape1" _public_methods_ = ['Lookup', 'ChangeXP', 'ServerStatus', 'MultiplyString'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls'] def __init__(self): self.softspace = 1 self.noCalls = 0 def Lookup(self, nick): url = "http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=" + nick f = urlopen(url, 'r').read() search_start = '<a href="overall.ws?table=0&user=' search_end = '</table>' f = f[f.find(search_start):f.find(search_end)] f = f.replace('Not Ranked', 'N/A N/A N/A') while '<' in f: a = f.find('<') b = f.find('>') f = f[:a] + f[b+1:] if 'does not feature in the hiscores' in f: f = '' for x in range(89): f += ' ' return f def ChangeXP(self, xp): if len(xp) > 3: xp = xp[:len(xp)-3] + ',' + xp[len(xp)-3:] if len(xp) > 7: xp = xp[:len(xp)-7] + ',' + xp[len(xp)-7:] return xp def ServerStatus(self): servers = [] servers1 = '' url = 'http://www.runescape.com/serverlist.ws?plugin=0&lores.x=232&lores.y=82' f = urlopen(url).read() f = f[f.find('<img src="http://www.runescape.com/lang/en/aff/runescape/img/serverlist/harrow_down.gif'):] while '<' in f: a = f.find('<') b = f.find('>') f = f[:a] + f[b+1:] for a in range(1,122): search = 'World ' + str(a) + ' ' start = f.find(search) servers += [f[start+6:start+len(search)+4]] if ';Type Wo' in servers: del servers[servers.index(';Type Wo')] servers = servers[:115] + ['116 DOWN'] + servers[115:] for a in servers: servers1 += a + ',' return servers1 def MultiplyString(self, string, times): string = times*string return string if hasattr(sys, 'importers'): # we are running as py2exe-packed executable pythoncom.frozen = 1 if __name__=='__main__': if hasattr(sys, 'importers'): # running as packed executable. if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]: # --register and --unregister work as usual import win32com.server.register win32com.server.register.UseCommandLine(Runescape1) else: # start the server. from win32com.server import localserver localserver.main() else: import win32com.server.register win32com.server.register.UseCommandLine(Runescape1) That was my whole file, not all of this is probably needed for an answer, but I thought I'd mail the whole py file. You can ignore every function in the Runescape1 class if you want :P. Thanks in advance, Floris _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32