Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rules_model_qt won't work - AttributeError: 'unicode' object has no attribute 'toString' #19

Open
erm3nda opened this issue Apr 20, 2017 · 2 comments

Comments

@erm3nda
Copy link

erm3nda commented Apr 20, 2017

This happens when you hit "new regexp rule"

Traceback (most recent call last):
  File "/home/m3nda/Descargas/track-master/track_qt/rules_model_qt.py", line 84, in setData
    regex_str=str(value.toString())
AttributeError: 'unicode' object has no attribute 'toString'
Abortado (`core' generado)

To reproduce that:

  • Open it python track or ./track. Qy5 windows opens.
  • Click on new regexp rule. Nothing happens than "Connect to server".
  • If you hit it again, now it just clear the current regexp items, and show them as blank.
  • Write anything into one of them and click outside of that element to "save".
  • Then voila: Abortado (`core' generado)

I am currently using Ubuntu16.04, Python 2.7.12-final and Pytqt5 (as per my version of Python2)

@stderr-enst
Copy link

stderr-enst commented Aug 26, 2017

I just started looking into track, but my guess is, that this is just a consequence from migrating the application from python2 to python3.

Your issue is kind of easily resolved. Just drop the .toString() part for value in track_qt/rules_model_qt.py:setData(), since value is already a string:

#Makes it editable:
def setData(self, index, value, role):
    if value != "":
        regex_str=str(value.toString())
        try:
            re.compile(regex_str)
            is_valid = True
        except re.error:
            is_valid = False
        if(is_valid):
            self._rules[index.row()][index.column()-1] = str(value.toString())
            self.modified_rules.emit()
            self.save_to_disk()
        else:
            self._rules[index.row()][index.column()-1] = "invalid regex"
    return True

Sadly after succeeding with that, we run into another issue, since save_to_disk() does not exist at all.

As a workaround you can add your rules by adding them to ~/.track/category_rules, while the track-server is not running. (I had to kill it using python track-cli quit)

@stderr-enst
Copy link

stderr-enst commented Aug 26, 2017

Just had a look at the history of rules_model_qt.py.
save_to_disk() went out in 2e663db
The old mechanism appears to be replaced with a new one in time_track.py, which probably wasn't meant to be called from rules_model_qt.py:setData() directly.
So I guess self.save_to_disk() should either be removed or something else has to take its place?

edit:
well, removing the function call and both toString()s resolved the crash, but the file containing the rules is not updated.

sosiax added a commit to sosiax/track that referenced this issue Mar 3, 2020
…st#19

Removing "toString" unneeded method and "save_to_disk()" call as is not implemented (keep this in TODO list)
frans-fuerst added a commit that referenced this issue Mar 4, 2020
Removing some crashes that are allready  commented in isue #19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants