Code: Alles auswählen
#!/usr/bin/python3
import cgi
print('Content-type: text/html') # the mime-type header.
print() # header must be separated from body by 1 empty line.
print("Hello World")
Funktioniert und gibt ganz normal "Hello World" wieder.
Code: Alles auswählen
#!/usr/bin/python3
import cgi
print('Content-type: text/html') # the mime-type header.
print() # header must be separated from body by 1 empty line.
result = 1/0
print(result)
Gibt wieder nur eine weiße Seite wieder. Jetzt habe ich allerdings zusätzlich
hinzugefügt und bekomme den Division by Zero Fehler im Browser angezeigt. Nun habe ich das ganze nochmal in das vorherige Skript mit der mySQL Datenbankverbindung eingefügt und bekomme eine ganze Reihe an Fehlern angezeigt:
Code: Alles auswählen
--> -->
OperationalError Python 3.8.8: /usr/bin/python3
Sun Mar 28 00:15:25 2021
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/home/strato/xxx/htdocs/cgi-bin/abc_test.py in <module>
12
13
=> 14 cnx = mysql.connector.connect(user='xxx',
=> 15 password='xxx',
=> 16 host='rdbms.strato.de',
cnx undefined, mysql = <module 'mysql' from '/home/strato/xxx/lib/python3.8/site-packages/mysql/__init__.py'>, mysql.connector = <module 'mysql.connector' from '/home/strato/www...on3.8/site-packages/mysql/connector/__init__.py'>, mysql.connector.connect = <function connect>, user undefined, password undefined, host undefined, database undefined
/home/strato/xxx/htdocs/.local/lib/python3.8/site-packages/mysql/connector/__init__.py in connect(*args=(), **kwargs={'database': 'xxx', 'host': 'rdbms.strato.de', 'password': 'xxx', 'user': 'xxx'})
276 if HAVE_CEXT and not use_pure:
277 return CMySQLConnection(*args, **kwargs)
=> 278 return MySQLConnection(*args, **kwargs)
279 Connect = connect # pylint: disable=C0103
280
global MySQLConnection = <class 'mysql.connector.connection.MySQLConnection'>, args = (), kwargs = {'database': 'xxx', 'host': 'rdbms.strato.de', 'password': 'xxx', 'user': 'xxx'}
/home/strato/www/ac/xxx/htdocs/.local/lib/python3.8/site-packages/mysql/connector/connection.py in __init__(self=<mysql.connector.connection.MySQLConnection object>, *args=(), **kwargs={'database': 'xxx', 'host': 'rdbms.strato.de', 'password': 'xxx', 'user': 'xxx'})
106 if kwargs:
107 try:
=> 108 self.connect(**kwargs)
109 except:
110 # Tidy-up underlying socket on failure
self = <mysql.connector.connection.MySQLConnection object>, self.connect = <bound method MySQLConnectionAbstract.connect of...sql.connector.connection.MySQLConnection object>>, kwargs = {'database': 'xxx', 'host': 'rdbms.strato.de', 'password': 'xxx', 'user': 'xxx'}
/home/strato/xxx/htdocs/.local/lib/python3.8/site-packages/mysql/connector/abstracts.py in connect(self=<mysql.connector.connection.MySQLConnection object>, **kwargs={'database': 'xxx', 'host': 'rdbms.strato.de', 'password': 'xxx', 'user': 'xxx'})
1001
1002 self.disconnect()
=> 1003 self._open_connection()
1004 # Server does not allow to run any other statement different from ALTER
1005 # when user's password has been expired.
self = <mysql.connector.connection.MySQLConnection object>, self._open_connection = <bound method MySQLConnection._open_connection o...sql.connector.connection.MySQLConnection object>>
/home/strato/xxx/htdocs/.local/lib/python3.8/site-packages/mysql/connector/connection.py in _open_connection(self=<mysql.connector.connection.MySQLConnection object>)
350 try:
351 self._socket.open_connection()
=> 352 self._do_handshake()
353 self._do_auth(self._user, self._password,
354 self._database, self._client_flags, self._charset_id,
self = <mysql.connector.connection.MySQLConnection object>, self._do_handshake = <bound method MySQLConnection._do_handshake of <mysql.connector.connection.MySQLConnection object>>
/home/strato/www/ac/xxx/htdocs/.local/lib/python3.8/site-packages/mysql/connector/connection.py in _do_handshake(self=<mysql.connector.connection.MySQLConnection object>)
148 def _do_handshake(self):
149 """Get the handshake from the MySQL server"""
=> 150 packet = self._socket.recv()
151 if packet[4] == 255:
152 raise errors.get_exception(packet)
packet undefined, self = <mysql.connector.connection.MySQLConnection object>, self._socket = None, self._socket.recv undefined
/home/strato/www/ac/xxx/htdocs/.local/lib/python3.8/site-packages/mysql/connector/network.py in recv_plain(self=<mysql.connector.network.MySQLTCPSocket object>)
291 return packet
292 except IOError as err:
=> 293 raise errors.OperationalError(
=> 294 errno=2055, values=(self.get_address(), _strioerror(err)))
295
global errors = <module 'mysql.connector.errors' from '/home/str...thon3.8/site-packages/mysql/connector/errors.py'>, errors.OperationalError = <class 'mysql.connector.errors.OperationalError'>, errno undefined, values undefined, self = <mysql.connector.network.MySQLTCPSocket object>, self.get_address = <bound method MySQLTCPSocket.get_address of <mysql.connector.network.MySQLTCPSocket object>>, global _strioerror = <function _strioerror>, err undefined
OperationalError: 2055: Lost connection to MySQL server at 'rdbms.strato.de:3306', system error: 104 Connection reset by peer
args = (2055, "2055: Lost connection to MySQL server at 'rdbms....3306', system error: 104 Connection reset by peer", None)
errno = 2055
msg = "Lost connection to MySQL server at 'rdbms.strato...3306', system error: 104 Connection reset by peer"
sqlstate = None
with_traceback = <built-in method with_traceback of OperationalError object>
Ich muss allerdings gestehen, dass mich persönlich das leider noch nicht auf die Lösung führt. Ein kleiner Hinweis noch dazu: Ich habe mittlerweile doch Fehlermeldungen von den Skriptausführungen früher am Abend gefunden, seltsamerweise scheint es, als würden diese bei meinem Strato Account ca 30min verzögert angezeigt werden. Den letzten Error im Log sehe ich von vor 35 Minuten, obwohl ich gerade eben mehrere produziert habe.