Error on OnTimer??? Könnt ihr helfen?

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
trend
User
Beiträge: 11
Registriert: Sonntag 4. Juni 2006, 09:12

Hallo
Ich hab folgendes problem, es handelt sich um Rufus 'bittorrent client'
Nich immer aber so wie ich es gemerkt habe, bekommt der Rufus ein Fehler wenn ich ihn schliesse, aber nur wenn der Program auch bentutzt wurde (wenn peers bestanden, aber nicht immer.. )
Der Error sieht so aus:

Exception in thread Thread-xxx:
Traceback (most recent call last):
File "threading.pyo", line 444, in __bootstrap
File "threading.pyo", line 607, in run
File "peerlistcache.pyo", line 69, in OnTimer
TypeError: list objects are unhashable

Fehlt mir vielleicht ein Plugin? Der Programmierer vom Rufus schreibt seit einem halben Jahr nichts mehr an der Site und dort meldet sich auch keiner darum versuch ich es hier..
Danke euch
Leonidas
Python-Forum Veteran
Beiträge: 16025
Registriert: Freitag 20. Juni 2003, 16:30
Kontaktdaten:

Das ist ganz einfach ein Bug in deinem BT-Client. Versuch einfach einen anderen, es gibt ja zig sehr gute Clients. Dazu gibts sogar einen Feature-Vergleich.
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
trend
User
Beiträge: 11
Registriert: Sonntag 4. Juni 2006, 09:12

:shock:
Es steckt schon viel zu viel Arbeit dahinter..
Als ein 'Anfänger' in Python, php ist mein Fach

Kann man nicht im Python error reporting ausschalten :D ?
Oder wie könnte ich den Fehler vielleicht rausfinden?
Leonidas
Python-Forum Veteran
Beiträge: 16025
Registriert: Freitag 20. Juni 2003, 16:30
Kontaktdaten:

trend hat geschrieben::shock:
Es steckt schon viel zu viel Arbeit dahinter..
Was meinst du mit zu viel Arbeit? Das klingt so, als würdest du das Programm nur nutzen. Wenn es Fehler macht, dann ersetz es doch einfach durch einen anderen Client (es gibt einige gute Clients).
trend hat geschrieben:Kann man nicht im Python error reporting ausschalten :D ?
Kann man. Mit

Code: Alles auswählen

try:
    # dein code
except:
    pass
Ist allerdings nicht zu empfehlen weil es das Problem nicht löst sondern versteckt.
trend hat geschrieben:Oder wie könnte ich den Fehler vielleicht rausfinden?
Debuggen. Wird allerdings nicht einfach, weil du in die inneren Strukturen des Programms einsteigen müsstest.
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
trend
User
Beiträge: 11
Registriert: Sonntag 4. Juni 2006, 09:12

Danke dir, werde es mal probieren mit error reporting auszuschalten.
So wie es aussieht ist es nicht so wichtig, wie ich die sourcecode gesehen hab ist der fehler darin, dass der Rufus irgendwie ein problem verursacht beim schliessen von connection's
trend
User
Beiträge: 11
Registriert: Sonntag 4. Juni 2006, 09:12

Wenn ich den Code so einfüge:

Code: Alles auswählen

import os.path
try:
try:
    import cjkcodecs.aliases
except:
    pass
try:
    import iconv_codec
except:
    pass

if win32_flag:
    from os import startfile
    from webbrowser import open_new
else:
..und den Rest
und am schluss noch:

Code: Alles auswählen

except: 
    pass
Dann bekomme ich ein Fehler:
'Indentation Error: Espected indeted block'
Wie soll denn dass genau aussehen?
trend
User
Beiträge: 11
Registriert: Sonntag 4. Juni 2006, 09:12

Der Fehler liegt darin:
dass ist ein teil von peerlistcashe

Code: Alles auswählen

    def OnTimer(self):
        if self.doneflag.isSet():
            print "TIMER: peerinfo timer ending s0"
            return False
        
        self.counter += 1    
        ip_list = []
        peerid_list = []
        
        self.lock.acquire(True)
        # every 15 mins, purge items from peerinfo db that have not been accessed for 60mins
        if not (self.counter % 180):
            for ip in self.peerinfo_db.items():
                if (ip[1][7] + 3600) < time():
                    self.peerinfo_db.pop(ip)

        
        # collect list of unresolved peer names/ids
        for key, value in self.peerinfo_db.items():
            if self.doneflag.isSet():
                break
            if value[0] == None: 
                ip_list.append(key)
            if value[3] == '': 
                peerid_list.append(key)
        self.lock.release()

        for ip in peerid_list:
            if self.doneflag.isSet():
                break
            peer_id = self.peerinfo_db[ip][6]

            if peer_id != None:
                name = GetPeerName(peer_id)
                client = GetClientName(peer_id)
                raw_id = GetRawPeerid(peer_id)
            else:
                name = ''
                client = ''
                raw_id = ''

            self.lock.acquire(True)

            self.peerinfo_db[ip][3] = client
            self.peerinfo_db[ip][4] = name
            self.peerinfo_db[ip][5] = raw_id
            self.peerinfo_db[ip][7] = time()

            self.lock.release()  

        for ip in ip_list:
            if self.doneflag.isSet():
                break
            address = self.get_address(ip)
            
            self.lock.acquire(True)
            self.peerinfo_db[ip][0] = address
            self.peerinfo_db[ip][7] = time()
            self.lock.release()       

                    
        if self.doneflag.isSet():
            print "TIMER: peerinfo timer ending s1"
            return False

        self.Start()

wie soll ich das Reporting ausschalten?
BlackJack

Okay, schauen wir erstmal wodurch so eine Ausnahme ausgelöst werden kann:

Code: Alles auswählen

In [1]:a = {}

In [2]:b = [1, 2, 3]

In [3]:a[b] = None
---------------------------------------------------------------------------
exceptions.TypeError          Traceback (most recent call last)

/home/bj/<ipython console>

TypeError: list objects are unhashable
Jetzt musst Du nur noch die betreffende Zeile finden -- die steht ja im Traceback, und genau diese Zeile in einen ``try``/``except`` Block packen:

Code: Alles auswählen

try:
    # Böse Zeile
except TypeError:
    pass
trend
User
Beiträge: 11
Registriert: Sonntag 4. Juni 2006, 09:12

Danke dir für die Antwort, aber ich habe immer noch ein Problem, der 'Traceback' befindet sich in Python 2.4 Install Dir.
Der Rufus tut ja nur:

Code: Alles auswählen

from traceback import print_exc
Kannst du mir zeigen wie ich das genau machen soll in Traceback.py?
Der Teil von Traceback.py der dafür verantwortlich ist:

Code: Alles auswählen

def print_exception(etype, value, tb, limit=None, file=None):
    """Print exception up to 'limit' stack trace entries from 'tb' to 'file'.

    This differs from print_tb() in the following ways: (1) if
    traceback is not None, it prints a header "Traceback (most recent
    call last):"; (2) it prints the exception type and value after the
    stack trace; (3) if type is SyntaxError and value has the
    appropriate format, it prints the line where the syntax error
    occurred with a caret on the next line indicating the approximate
    position of the error.
    """
    if file is None:
        file = sys.stderr
    if tb:
        _print(file, 'Traceback (most recent call last):')
        print_tb(tb, limit, file)
    lines = format_exception_only(etype, value)
    for line in lines[:-1]:
        _print(file, line, ' ')
    _print(file, lines[-1], '')

def format_exception(etype, value, tb, limit = None):
    """Format a stack trace and the exception information.

    The arguments have the same meaning as the corresponding arguments
    to print_exception().  The return value is a list of strings, each
    ending in a newline and some containing internal newlines.  When
    these lines are concatenated and printed, exactly the same text is
    printed as does print_exception().
    """
    if tb:
        list = ['Traceback (most recent call last):\n']
        list = list + format_tb(tb, limit)
    else:
        list = []
    list = list + format_exception_only(etype, value)
    return list

def format_exception_only(etype, value):
    """Format the exception part of a traceback.

    The arguments are the exception type and value such as given by
    sys.last_type and sys.last_value. The return value is a list of
    strings, each ending in a newline.  Normally, the list contains a
    single string; however, for SyntaxError exceptions, it contains
    several lines that (when printed) display detailed information
    about where the syntax error occurred.  The message indicating
    which exception occurred is the always last string in the list.
    """
    list = []
    if type(etype) == types.ClassType:
        stype = etype.__name__
    else:
        stype = etype
    if value is None:
        list.append(str(stype) + '\n')
    else:
        if etype is SyntaxError:
            try:
                msg, (filename, lineno, offset, line) = value
            except:
                pass
            else:
                if not filename: filename = "<string>"
                list.append('  File "%s", line %d\n' %
                            (filename, lineno))
                if line is not None:
                    i = 0
                    while i < len(line) and line[i].isspace():
                        i = i+1
                    list.append('    %s\n' % line.strip())
                    if offset is not None:
                        s = '    '
                        for c in line[i:offset-1]:
                            if c.isspace():
                                s = s + c
                            else:
                                s = s + ' '
                        list.append('%s^\n' % s)
                    value = msg
        s = _some_str(value)
        if s:
            list.append('%s: %s\n' % (str(stype), s))
        else:
            list.append('%s\n' % str(stype))
    return list

def print_exc(limit=None, file=None):
    """Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'.
    (In fact, it uses sys.exc_info() to retrieve the same information
    in a thread-safe way.)"""
    if file is None:
        file = sys.stderr
    try:
        etype, value, tb = sys.exc_info()
        print_exception(etype, value, tb, limit, file)
    finally:
        etype = value = tb = None
murph
User
Beiträge: 622
Registriert: Freitag 14. April 2006, 19:23
Kontaktdaten:

also traceback sollte eigentlich nur ein "Fehlermanager" sein, der dir eine genaue auskunft gibt, worin der Fehler liegt.
Wenn da ein Fehler drin sein sollte, hast du eine verdammt defekte version ( ;) )
trend
User
Beiträge: 11
Registriert: Sonntag 4. Juni 2006, 09:12

Die Ver. hier ist 0,70 aber die stable ver. 0.69 hat das gleiche problem
Ist es schwer den Fehler raus zu finden?
Oder wie bringe ich es den Fehler nicht mehr zu zeigen?
Der entsteht erst bei schliessen vom Rufus (und es geht glaube um die Funktion dass er die Peers die er nicht im 60min aufgebaut hat trotzdem es versucht oder so was, aber wieso er erst am Schluss den Fehler gibt, weiss ich auch nicht.)
Ich habe vor 2Wochen das erste mal Python compiliert :)..
Wenn mir nur jemand helfen könnte den Fehler zu beheben..
murph
User
Beiträge: 622
Registriert: Freitag 14. April 2006, 19:23
Kontaktdaten:

nimm deine pfoten aus traceback.py!!!
du sollst das in der anderen datei ändern, die traceback.py aufruft!!!
Lies doch, wenn man dir schreibt!

//edit: wie hast du denn python komiliert? verrate mir das mal bitte!
selbst cx_Freeze und py2exe kompilieren nicht im klassischem sinne
oder hast du http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi oä genutzt?
trend
User
Beiträge: 11
Registriert: Sonntag 4. Juni 2006, 09:12

Habe folgendes gemacht:
python-2.4.3 instaliert
wxPython2.6-win32-ansi-2.6.3.2-py24
und die
py2exe-0.6.5.win32-py2.4

Als Editor benutze ich: SPE-0.8.2.a-wx2.6.1.0-py24

und dann mit der 'bat' datei die so aussieht geschafft:

Code: Alles auswählen

del /F /S /Q build dist
c:\python24\python.exe -OO winsetup.py py2exe -p encodings
mkdir dist\images
mkdir dist\images\flags
copy images dist\images\
copy images\flags dist\images\flags
copy pravila.txt dist\
copy search.ini dist\
copy unicows.dll dist\
rem "makensis.exe" Rufus.nsi
murph
User
Beiträge: 622
Registriert: Freitag 14. April 2006, 19:23
Kontaktdaten:

wieso machst du nicht erstmal das, was dir oben empfohlen wird?
wenn du keine fehlermeldungen magst, suche die zeile aus dem skript, in dem OnTime() deklariert wird und machst das mit try&except.
das wurde dir schon geraten und erklärt!
BlackJack

trend hat geschrieben:Danke dir für die Antwort, aber ich habe immer noch ein Problem, der 'Traceback' befindet sich in Python 2.4 Install Dir.
Der Rufus tut ja nur:

Code: Alles auswählen

from traceback import print_exc
Kannst du mir zeigen wie ich das genau machen soll in Traceback.py?
Der Teil von Traceback.py der dafür verantwortlich ist:
Da liegt wohl ein Missverständniss vor. Du sollst nicht in `Traceback.py`, sondern im Traceback selbst schauen in welcher Datei und welcher Zeile die Ausnahme ausgelöst wird. Traceback nennt sich die Ausgabe in der eine Ausnahme detailliert inklusive Aufrufhistorie aufgeführt wird. Also das was Du als "Fehler" bezeichnest.
Antworten