Ich brauche mal etwas Hilfe, wenn ich das ganze über den debugger starte, funktioniert es. Im HS funktioniert das ganze nicht. Wo ist mein Fehler ?
---
# Kompilieranweisung: python 11202_Digestauth.py
import base64
import marshal
import re
import md5
#doByteCode=False
doByteCode=True
LOGIKNAME="digestauth"
LOGIKID="11202"
VERSION=""
LOGIKFILE=LOGIKID+"_"+LOGIKNAME+VERSION
LOGIK = """
5000|"digest auth"|0|6|"E1 User"|"E2 Password"|"E3 IP"|"E4 URL"|"E5 Get-Param"|"E6 Param2"|1|"A1 Result"|"v1.1"
# Anzahl Eingaenge | #Ausgaenge | #Zeitspeicher | #Speichervariablen | #Berechung bei init | Kodierter Formel
5001|6|1|0|0|1
#Definition der Eingaenge:
5002|1|""|1
5002|2|""|1
5002|3|""|1
5002|4|""|1
5002|5|""|1
5002|6|""|1
#5004|Ausgang|Init.-Wert|Binaer|Typ|Datenformat
5004|1|""|0|1|0
"""
code = """
global urllib2
import urllib2
debugurl = ""
def authfetch(username,password,url,path,param,param2) :
#print username
auth = urllib2.HTTPPasswordMgrWithDefaultRealm()
auth.add_password (None, url, username, password)
opener = urllib2.build_opener(urllib2.HTTPBasicAuthHandler( auth), urllib2.HTTPDigestAuthHandler(auth))
urllib2.install_opener(opener)
req = ""
if (len(path)>0):
req += path
if (len(param)>0):
req += "?" + param;
if (len(param2)>0):
req += param2
try:
debugurl = url + req
page_content = urllib2.urlopen(url + req)
return (page_content.code)
except urllib2.HTTPError, e:
#print url + "?" + param
return (e.code)
if (len(EN[1])> 0 and len(EN[2])>0 and len(EN[3])>0 ):
AN[1] = authfetch (EN[1], EN[2], EN[3], EN[4], EN[5],EN[6])
AC[1] = 1
"""
if doByteCode:
data=compile(code,"<string>","exec")
data=marshal.dumps(data)
#5012|Ende Ausf.|Bedingung|Formel|Zeitformel|Ausgang|Zeitspei cher|Speichervar|Neg.Ausgang
formel = "5012|0|"EC[1]"|"eval(__import__('marshal').loads(__import__('ba se64').decodestring('"+re.sub("\n","",base64.encod estring(data))+"')))"|""|0|0|0|0"
else:
formel = "5012|0|"EC[1]"|"eval(compile(__import__('base64').decodestring( '"+re.sub("\n","",base64.encodestring(code))+"'),' <string>','exec'))"|""|0|0|0|0"
open(LOGIKFILE+".hsl",'w').write(LOGIK+"\n"+formel +"\n")
print "File "" + LOGIKFILE + "" created"
---
# Kompilieranweisung: python 11202_Digestauth.py
import base64
import marshal
import re
import md5
#doByteCode=False
doByteCode=True
LOGIKNAME="digestauth"
LOGIKID="11202"
VERSION=""
LOGIKFILE=LOGIKID+"_"+LOGIKNAME+VERSION
LOGIK = """
5000|"digest auth"|0|6|"E1 User"|"E2 Password"|"E3 IP"|"E4 URL"|"E5 Get-Param"|"E6 Param2"|1|"A1 Result"|"v1.1"
# Anzahl Eingaenge | #Ausgaenge | #Zeitspeicher | #Speichervariablen | #Berechung bei init | Kodierter Formel
5001|6|1|0|0|1
#Definition der Eingaenge:
5002|1|""|1
5002|2|""|1
5002|3|""|1
5002|4|""|1
5002|5|""|1
5002|6|""|1
#5004|Ausgang|Init.-Wert|Binaer|Typ|Datenformat
5004|1|""|0|1|0
"""
code = """
global urllib2
import urllib2
debugurl = ""
def authfetch(username,password,url,path,param,param2) :
#print username
auth = urllib2.HTTPPasswordMgrWithDefaultRealm()
auth.add_password (None, url, username, password)
opener = urllib2.build_opener(urllib2.HTTPBasicAuthHandler( auth), urllib2.HTTPDigestAuthHandler(auth))
urllib2.install_opener(opener)
req = ""
if (len(path)>0):
req += path
if (len(param)>0):
req += "?" + param;
if (len(param2)>0):
req += param2
try:
debugurl = url + req
page_content = urllib2.urlopen(url + req)
return (page_content.code)
except urllib2.HTTPError, e:
#print url + "?" + param
return (e.code)
if (len(EN[1])> 0 and len(EN[2])>0 and len(EN[3])>0 ):
AN[1] = authfetch (EN[1], EN[2], EN[3], EN[4], EN[5],EN[6])
AC[1] = 1
"""
if doByteCode:
data=compile(code,"<string>","exec")
data=marshal.dumps(data)
#5012|Ende Ausf.|Bedingung|Formel|Zeitformel|Ausgang|Zeitspei cher|Speichervar|Neg.Ausgang
formel = "5012|0|"EC[1]"|"eval(__import__('marshal').loads(__import__('ba se64').decodestring('"+re.sub("\n","",base64.encod estring(data))+"')))"|""|0|0|0|0"
else:
formel = "5012|0|"EC[1]"|"eval(compile(__import__('base64').decodestring( '"+re.sub("\n","",base64.encodestring(code))+"'),' <string>','exec'))"|""|0|0|0|0"
open(LOGIKFILE+".hsl",'w').write(LOGIK+"\n"+formel +"\n")
print "File "" + LOGIKFILE + "" created"
Kommentar