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

AttributeError: 'str' object has no attribute 'append' #78

Closed
s243a opened this issue Jan 3, 2020 · 9 comments
Closed

AttributeError: 'str' object has no attribute 'append' #78

s243a opened this issue Jan 3, 2020 · 9 comments
Labels
bug Something isn't working daemon

Comments

@s243a
Copy link

s243a commented Jan 3, 2020

I'm trying to run Maestral on fatdog64, the folder ~/"Dropbox (Maestral)" is symlinked from a ext4 save file (in a aufs layered file system), to a folder on a NTFS partition. The syncing was working for a fair bit then I got the unexpected error.

Maestral GUI

An Unexpected error occured

Please restart Maestral to continue syncing and contact the developer with the information below:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/maestral/sync/monitor.py", line 1725, in download_worker
    sync.get_remote_dropbox()
  File "/usr/lib/python3.6/site-packages/maestral/sync/monitor.py", line 243, in wrapper
    res = func(self, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/maestral/sync/monitor.py", line 1305, in get_remote_dropbox
    success.append(self.apply_remote_changes(root_result, save_cursor=False))
  File "/usr/lib/python3.6/site-packages/maestral/sync/monitor.py", line 1413, in apply_remote_changes
    success += [f.result()]
  File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 425, in result
    return self.__get_result()
  File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/maestral/sync/monitor.py", line 243, in wrapper
    res = func(self, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/maestral/sync/monitor.py", line 1597, in _create_local_entry
    self._save_to_history(entry.path_display)
  File "/usr/lib/python3.6/site-packages/maestral/sync/monitor.py", line 1651, in _save_to_history
    recent_changes.append(dbx_path)
AttributeError: 'str' object has no attribute 'append'

When I closed the dialog the syncing than resumed.

@s243a
Copy link
Author

s243a commented Jan 3, 2020

On another note, if I hover over the icon on the task bar it looks like a lot of items are being upload. However:

  1. I didn't add any files to the dropbox folder since I installed maestral
  2. The web site only shows two recent files were uploaded.

The message makes me worry about some unintended mass upload but so far this doesn't seem to be happening.

@samschott
Copy link
Owner

I'm trying to run Maestral on fatdog64, the folder ~/"Dropbox (Maestral)" is symlinked from a ext4 save file (in a aufs layered file system), to a folder on a NTFS partition.

This is a very unusual configuration and I am not sure I fully understand it. Do you give the full path or the symlinked path to Maestral? In the second case, there may be some issues with tracking file changes.

The error which you are seeing is caused by the config file. It keeps a list of the 30 most recently changed files, for display in the GUI. However, when reading this list recent_changes from the config file, it seems like a string is returned instead a list of strings. This indicates some issue with reading and writing the config.

Could you check the following?

  1. There is a menu item "Recently changed files" in the main menu. Does it show any entries? Are they what you expect?

  2. Could you post the contents of your config file? It should be located at '~/.config/maestral/maestral.ini'. Feel free to redact all personal information. The last section should look like this:

[internal]
cursor = AAFi1HsN7eusTjZbKn7Q5lmyRv_t9DHLkJAfCOQUpdPc_B3MqLMZ-2u39QggJeF7IxWApmq4qqYs0QvwYQUxbrFAGe0q4ZFRYNYbDlBFB2BhIoPxEeiedgabY8QG74rS07557SHSq06Xud60pRoayjTj3II8mu4Msv1yJZRdz7Kp4CAzbAYOYJafDr9bckOyYvEuAXcQaDg9FXT6LBeqWBmv1GVz2wuC5rI-bJhex0J7GkQKVTix6Sr59WkS4REaBAWnkKi-b6WXZpyUoAtmuI8ufF5KqJMQjVW6cJong9JnE9BqDdyQCg9UrJ2qGIVr5HSbrPOiW9vZEnWIXctUg-D1OmDhGc-KeGSFmQfHMyn0rXUqy7JUiAuGg1VD9nsDgK7UwffzIIP68zWfVJf9MCFI-NBNPKsohzcuWdmZ2Se6T-Xuc0NzGkuU6JJEiRZnr4F5FG6BkztCgv08tX-OKGir9FkTuR53rlLinTNsYzmwMTq4F4qtDd2lqW8BgWbMUHlBTjlsi_G5Q1RnZHv5kJSYOzLPbXomAoW29pVHUcjkSjoi-eBwiai1LeTorUV8dmQqbCG6oUzo3TqYX4AubHe-9uQm5UjMGZczr6xc61bXURxzvXxR-k-t9LsCRmic80MLTvfKM6z1YO8CRsUh8F-N
lastsync = 1578074677
recent_changes = ['path1', 'path2', 'path3', ...]

@samschott samschott added bug Something isn't working daemon labels Jan 3, 2020
@s243a
Copy link
Author

s243a commented Jan 4, 2020

he config file, it seems like a string is returne

It looks like the string is getting truncated. I'm guessing that my paths are longer than you expected. Maybe, some code needs to be implemented to change how many entries to include in recent changes if a valid list isn't returned.

recent_changes = ['/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/squid/rc.squid.new', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/squid/slack-desc', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/squid/squid.src2pkg', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/doinst.sh', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/rc.webmin', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/README.webmin-setup', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/slack-desc', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/webmin-minimal.src2pkg', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/webmin-setup', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/icons/hicolor/16x16/apps/src2pkg.png', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/icons/hicolor/24x24/apps/src2pkg.png', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/icons/hicolor/32x32/apps/src2pkg.png', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/icons/hicolor/48x48/apps/src2pkg.png', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/kernel/kernel-modules/kernel-modules.src2pkg', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/kernel/kernel-modules/README', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/kernel/kernel-tiny/kernel-tiny.src2pkg', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/kernel/kernel-tiny/README', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/sou

Notice that there is no closing single quote or right bracket.

@s243a
Copy link
Author

s243a commented Jan 4, 2020

I sent you the following dropbox invite so that you can view the folder:

AttributeError: 'str' object has no attribute 'append' #78

This is the folder which had a path too long for the current maestral-dropbox application. The files are simple-mind files, which is a mind mapping tool that works on both android and windows.

The full path to this folder is:
/home/root/Subjects/sci/phy/tech/tech/comp/soft/op/POSIX/dist/light/medium/puppy/install/pack/install/source

@s243a
Copy link
Author

s243a commented Jan 4, 2020

I'm not sure exactly how the dropbox api works but I know that for some parses, you can't get a parsed result until you read enough data. I see the following in your code:

                more_results = self.dbx.files_list_folder_continue(results[-1].cursor)
                results.append(more_results)

https://github.com/SamSchott/maestral-dropbox/blob/43c3e73f43b7606721c025c7de4f0126ac1ce288/maestral/sync/client.py#L459

I see that other people are first checking the datatype before appending:

            if isinstance(i, dropbox.files.FileMetadata):
                flist.append([i.name, i.size])

https://stackoverflow.com/a/54818092

Perhaps the maestral code needs to do a similar check, to make sure the dropbox parser has read enough data to parse the whole path. I only started looking at the code tonight and have never used the dropbox api before so this is just a guess.

@s243a
Copy link
Author

s243a commented Jan 4, 2020

I just edited the ".ini" file so that the last "erroneously named path" on the list of recently changed files was removed, and I added the closing bracket So that it looked like,

recent_changes = ['/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/squid/rc.squid.new', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/squid/slack-desc', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/squid/squid.src2pkg', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/doinst.sh', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/rc.webmin', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/README.webmin-setup', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/slack-desc', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/webmin-minimal.src2pkg', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/webmin/webmin-setup', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/icons/hicolor/16x16/apps/src2pkg.png', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/icons/hicolor/24x24/apps/src2pkg.png', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/icons/hicolor/32x32/apps/src2pkg.png', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/icons/hicolor/48x48/apps/src2pkg.png', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/kernel/kernel-modules/kernel-modules.src2pkg', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/kernel/kernel-modules/README', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/kernel/kernel-tiny/kernel-tiny.src2pkg', '/root/subjects/sci/phy/tech/tech/comp/soft/op/posix/dist/light/medium/puppy/install/pack/install/source/pet/src2pkg/files/src2pkg-3.0-noarch-2/usr/share/doc/src2pkg-3.0/examples/kernel/kernel-tiny/README']

So far it seems to be working. I'll let you know if I get said error again. Perhaps, the code could do the same if the following line:
`https://github.com/SamSchott/maestral-dropbox/blob/43c3e73f43b7606721c025c7de4f0126ac1ce288/maestral/sync/monitor.py#L1650

Doesn't return a valid list then the code could try the same (i.e. strip the last comma and all subsequent text and then add the closing bracket. There is a raw option in config.get() but my guess is that even without the raw option the config.get() method will returns a string anyway if it can't parse a valid list and consequently the raw option probably isn't necessary. Finally if all else fails, we just set this config value for recently changed files to the defaut (i.e. []).

My guess about what happened is something interrupted maestral during the processes of writing the ini. Consequently, the check that I suggested in the previous post might not be necessary.

@samschott
Copy link
Owner

Thanks for following up on this!

I see that other people are first checking the datatype before appending:

This should not be necessary, the Dropbox Python SDK already checks the results returned from the dropbox api. The referenced stack overflow code only checks if the returned entries are instances of dropbox.files.FileMetadata instead of dropbox.files.FolderMetadata or dropbox.files.DeletedMetadata.

My guess about what happened is something interrupted maestral during the processes of writing the ini. Consequently, the check that I suggested in the previous post might not be necessary.

Agreed. I tried to reproduce this by joining your shared folder (many thanks!) but could sync it without issues. This doesn't seem to be an issue with the length of the path but could be related to thread safety. The config file is accessed from multiple threads.

The config code is one of the few pieces which I did not write myself but took from the spyder project. It is built around Python's ConfigParser. I will look into it...

@samschott
Copy link
Owner

samschott commented Jan 6, 2020

I have been looking through the config code and merging changes from the upstream spyder project.

The actual config file is read only on startup, subsequent changes are written to the file but cached and read from memory. Therefore, even if writing a new value fails, the value in memory should still be a valid list. This is of course not true between restarts: if the last write has failed for some reason, an incorrect value will be loaded.

I have now added a lock to prevent concurrent writes from the same process, I hope this fixes the issue.

@samschott
Copy link
Owner

Closing as this seems fixed. Feel free to reopen if the issue reoccurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working daemon
Projects
None yet
Development

No branches or pull requests

2 participants