marxjohnson / btsyncindicator Goto Github PK
View Code? Open in Web Editor NEWBittorrent Sync indicator for linux desktops
License: GNU Lesser General Public License v3.0
Bittorrent Sync indicator for linux desktops
License: GNU Lesser General Public License v3.0
Sometime 2 instances of btsyncindicator are started. I don't know when this happens. Here the processes after a fresh boot of Ubuntu 12.04 at the first login:
jochen 2688 1 0 08:01 ? 00:00:00 python /usr/lib/btsync-user/btsyncindicator.py --config /home/jochen/.btsync.conf --iconpath /usr/share/icons/hicolor/22x22/status
jochen 2691 1 0 08:01 ? 00:00:00 /bin/sh /usr/lib/btsync-user/btsync-starter
jochen 2699 2691 0 08:01 ? 00:00:00 python /usr/lib/btsync-user/btsyncindicator.py --config /home/jochen/.btsync.conf --iconpath /usr/share/icons/hicolor/22x22/status
jochen 2708 1 0 08:01 ? 00:00:01 /usr/lib/btsync-user/btsync-agent --config /home/jochen/.btsync.conf
Process no. 2699 is started by btsync-starter. But who starts process no. 2688? This is started before launch of btsync-starter, and this is not in my startup programs.
Under KDE Plasma 5 (plasma-next) on Arch Linux, libappindicator is necessary for the tray icon to show up. Maybe add this as a dependency?
On second thought, it would be better as an optional dependency, because libappindicator doesn't always build happily.
There are two problems related with the implementation of the menu item "Enable Debug Logging".
Forwarded from Tuxpoldo/btsync-deb Issue #2
I think the indicator code uses version specific functionality of some libraries.
Traceback (most recent call last):
File "/usr/lib/btsync-user/btsyncindicator.py", line 96, in setup_session
html = tokenresponse.text
AttributeError: 'Response' object has no attribute 'text'
BTW: I have python-requests 0.8.2-1
Reported by forum user krychek:
I'm having a problem on two Ubuntu 14.04 boxes after the latest btsync update:
hostname$ btsync start hostname$ BitTorrent Sync forked to background. pid = 8506. default port = 8888 WARNING:root:Communication Error caught, displaying error message WARNING:root:Communication Error caught, displaying error message
I also have an exclamation mark in the btsync icon and and error message: Communication Error 400.
The btsync indicator should add support for the upcoming function PAUSE and RESUME provided by the next version of the btsync-user suite
Reported by M. van Workum via Launchpad:
Hi Leo,
The btsync indicator seems to crash constantly. I does show the indicator with it's menu to open the web interface, but no syncing data.
Traceback (most recent call last):
File "/usr/lib/btsync-user/btsyncindicator.py", line 220, in
setup_session
self.token = r.group(1)
AttributeError: 'NoneType' object has no attribute 'group'
I'm using ubuntu 13.10 with gnome-shell. Hope you can do something with this information.
Cheers,
M. van Workum
On start the indicator throws this exception:
Traceback (most recent call last):
File "/usr/lib/btsync-user/btsyncindicator.py", line 254, in setup_session
self.info[a] = self.get_response_json(response)
File "/usr/lib/btsync-user/btsyncindicator.py", line 650, in get_response_json
response_json = response.json()
TypeError: 'dict' object is not callable
Apparently it seems not to have any visible effects, but who knows
Wrong. It has effects. No folders are shown...
Reported by [email protected]
Hello Leo, Mark!
I'm using bt-sync in ubuntu you're build as PPA. Thank you for your work.
But I've mentioned that daemon started too slow on my laptop (HDD, encrypted partition - slow IO).
I've checked up the source and found that you were usingdpkg -S
to find what package contains file and later checks if it wasbtsync-user
.
dpkg -S btsyncindicator.py
works too slow, it has to process lots of data to make answer. You only want to know ifbtsync-user
is installed.
I advice you to checkdpkg -s btsync-user
(lowercased "s") - it returns 0 exit code if package is installed, nonzero otherwise. Ant works 100 times faster on my system.
Verified on a freshly installed Debian Wheezy. After installing and starting:
BitTorrent Sync forked to background. pid = 19493
/usr/lib/btsync-user/btsyncindicator.py:137: Warning: /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./gobject/gsignal.c:2459: signal `child-added' is invalid for instance `0x9798020'
self.ind.set_menu(self.menu)
At least on Debian it seems not to produce any side effects but it may have some relationship with what's reported here: http://forum.bittorrent.com/topic/19560-debian-and-ubuntu-desktop-unofficial-packages-for-bittorrent-sync/?p=78179
First off thank you for making btsyncindicator, it is a nice tool. I just discovered that the reason I was getting folder statistics on one computer and no statistics and a "!" in the icon was because my password contained a "#" character. After replacing this character in my password and restarting both btsync and btsyncindicator I got the normal statistics. This probably indicates that the password (and perhaps other config values) isn't being parsed out in a reliable manner.
To produce more log output I modified btsync-starter to add the option --log info when starting the btsyncindicator.py (is this the only way to do it or is there an official way to enable logging of the python script?) and then when I start it the following happens:
--(bernd@Saturn)-(/home/bernd)--
--($)-- btsync start
--(bernd@Saturn)-(/home/bernd)--
--($)-- BitTorrent Sync forked to background. pid = 2557
INFO:root:Opening config file /home/bernd/.config/btsync/btsync-auto.conf
INFO:root:Config loaded
INFO:root:Creating menu
INFO:root:Menu initalisation complete
INFO:root:Requesting Token from http://127.0.0.1:9999/gui/token.html
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
INFO:root:Token response <Response [200]>
INFO:root:HTML Response <html><div id='token' style='display:none;'>BuZa4-Bq65kQu7quPGr4pKHyi8imqUNK2Mkc9w3cthOqrBYUsKHczNYXClMAAAAA</div></html>
INFO:root:Token BuZa4-Bq65kQu7quPGr4pKHyi8imqUNK2Mkc9w3cthOqrBYUsKHczNYXClMAAAAA Retrieved
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
Traceback (most recent call last):
File "/usr/lib/btsync-user/btsyncindicator.py", line 254, in setup_session
self.info[a] = response.json()
AttributeError: 'Response' object has no attribute 'json'
At the same time a yellow KDE notification icon pops up in the notification area (translated from german back into english it reads something like: "an application on your system has crashed (either right now or some time ago)" and the btsyncindicator icon only contains the menu entries "pause syncing", "open web interface", "enable debug logging", "quit bittorrent sync" and it is missing the menu for my shared folders and also does not detect activity (icon not spinning anymore).
These symptoms started happening today after I got a new update from the ppa.
When I startup btsync, I get the error:
Traceback (most recent call last):
File "/usr/lib/btsync-user/btsyncindicator.py", line 302, in check_status
submenu = self.build_folder_menu(folder)
File "/usr/lib/btsync-user/btsyncindicator.py", line 406, in build_folder_menu
readonly.connect("activate", self.copy_secret,folder['readonlysecret'])
KeyError: 'readonlysecret'
The first folder in my btsync directory is read-only. This seems to fix the issue for me:
--- btsyncindicator.py 2013-11-16 05:20:36.000000000 -0500
+++ btsyncindicator.py 2014-01-23 09:48:11.735236159 -0500
@@ -402,19 +402,20 @@
menu.append(sep)
folderitem['bottomsepitem'] = sep
- readonly = gtk.MenuItem('Get Read Only Secret')
- readonly.connect("activate", self.copy_secret, folder['readonlysecret'])
- readwrite = gtk.MenuItem('Get Full Access Secret')
- readwrite.connect("activate", self.copy_secret, folder['secret'])
+ if folder['iswritable']:
+ readonly = gtk.MenuItem('Get Read Only Secret')
+ readonly.connect("activate", self.copy_secret, folder['readonlysecret'])
+ readwrite = gtk.MenuItem('Get Full Access Secret')
+ readwrite.connect("activate", self.copy_secret, folder['secret'])
- readonly.show()
- readwrite.show()
+ readonly.show()
+ readwrite.show()
- menu.append(readonly)
- menu.append(readwrite)
+ menu.append(readonly)
+ menu.append(readwrite)
return menu
Currently every shared directory creates in the menu the following structure:
/my/shared/dir 15.5 MB in 8 files
bookpoldo: Synched on 09/16/13 13:44:10
macpoldo: Synched on 09/15/13 22:23:01
yeasoft-gate2: Synched on 09/16/13 16:23:09
Get Secret -> Read Only
Full Access
The menu would be more reliable, if it would contain for each share the following structure:
/my/shared/dir -> Share Size: 15.5 MB in 8 files
bookpoldo: Synched on 09/16/13 13:44:10
macpoldo: Synched on 09/15/13 22:23:01
yeasoft-gate2: Synched on 09/16/13 16:23:09
-------------------------------------------------
Get Read Only Secret
Get Full Access Secret
There are some missing type casts (my fault)....
WARNING:root:Communication Error caught, displaying error message
Traceback (most recent call last):
File "/usr/lib/btsync-user/btsyncindicator.py", line 270, in setup_session
self.show_error("Communication Error "+response.status_code)
TypeError: cannot concatenate 'str' and 'int' objects
It's quite simple to fix...
Provide a menu entry "Enable Debug Logging" with the following functionality:
PSEUDOCODE BEGIN
VarStorageDir = get_storage_dir_from_config_file
OnMenuEntryUpdate() {
if file exist $VarStorageDir . "/debug.txt" {
add checkmark to menu entry
} else {
remove checkmark from menu entry
}
}
OnMenuEntrySelect() {
if file exist $VarStorageDir . "/debug.txt" {
delete $VarStorageDir . "/debug.txt"
} else {
echo "FFFF" > $VarStorageDir . "/debug.txt"
}
}
PSEUDOCODE END
In Ubuntu it seems that the default icon size for indicators is 22x22 - btsync-user packaging installs the icons there, but lintian complains about the wrong size.
What should we do? Create a dedicated directory or adapt the icon size?
W: btsync-user: icon-size-and-directory-name-mismatch usr/share/icons/hicolor/22x22/status/btsync-active.png 17x19
W: btsync-user: icon-size-and-directory-name-mismatch usr/share/icons/hicolor/22x22/status/btsync-attention.png 17x19
W: btsync-user: icon-size-and-directory-name-mismatch usr/share/icons/hicolor/22x22/status/btsync-error.png 17x19
W: btsync-user: icon-size-and-directory-name-mismatch usr/share/icons/hicolor/22x22/status/btsync.png 17x19
Provide a menu entry "Open BitTorrent Sync..." that launches the URL of the WebUI. The URL shall be computed based on the information in the btsync configuration file
If btsyncindicator.py is running, and the agent is stopped (let's say that the user changes something in the configuration file and then restarts it) producing a connection error, the btsyncindicator correctly shows the disconnection state in the icon and the menu is cleaned up showing "Lost connection to BitTorrent Sync". After the agent is restarted, the btsyncindicator icon changes back to the connected icon but the menu is not restored correctly:
Menu on first start:
Menu when btsync-agent is not running:
Menu after reconnecting to btsync-agent:
I am Brazilian, so I tried to set btsync web ui to Portuguese. After doing that the indicator does not work correctly. The reason is that the information it retrieves from th server is translates, so, for example the status "Synced", becomes "Sincronizado". The indicator fails then to parse the information.
In fact, to check this I added a line to the source code to print the information retrieved from the server (at line 249 of current source code of v. 0.10). If I set bitsync web interface to English this is what I get (I ERASED the secrets):
{u'folders': [{u'peers': [{u'status': u'Synced on 10/19/13 09:08:30', u'direct': 1, u'name': u'quorra -- pjssilva'}, {u'status': u'Synced on 10/19/13 09:07:55', u'direct': 1, u'name': u'trinity - pjssilva'}], u'name': u'/home/pjssilva/syncdir', u'iswritable': 1, u'secret': u'ERASED', u'readonlysecret': u'ERASED', u'size': u'112.0 MB in 168 files'}], u'speed': u'0.0 kB/s up, 0.0 kB/s down'}
Look at the status result, it starts with "Synced", a string that is used in the code. Now, If I change the interface to Portuguese (Brasil), it becomes:
{u'folders': [{u'peers': [{u'status': u'Sincronizado em 10/19/13 09:08:30', u'direct': 1, u'name': u'quorra -- pjssilva'}, {u'status': u'Sincronizado em 10/19/13 09:07:55', u'direct': 1, u'name': u'trinity - pjssilva'}], u'name': u'/home/pjssilva/syncdir', u'iswritable': 1, u'secret': u'ERASED', u'readonlysecret': u'ERASED', u'size': u'112.0 MB em 168 arquivos '}], u'speed': u'0.0 kB/s upload, 0.0 kB/s download'}
Now, the status starts with "Sincronizado", which is synced in Portuguese. This was making the indicator behave badly until I switched it back to English.
User cedricbr reported in the forum:
On debian jessie, i'm getting the following error
No indicator visible. I'm using the newest version of btsync-user and btsync-common
dpkg -l | grep btsync
ii btsync-common 1.2.82-1 amd64 Private network P2P file synchronisation daemon
ii btsync-user 1.14.2-1 all Private network P2P file synchronisation daemon(s)
BitTorrent Sync forked to background. pid = 9236
/usr/lib/btsync-user/btsyncindicator.py:138: Warning: /tmp/buildd/glib2.0-2.38.2/./gobject/gsignal.c:2475: signal 'child-added' is invalid for instance '0x19af230' of >type 'GtkMenu'
self.ind.set_menu(self.menu)
BitTorrent Sync on Mac OSX and Windows has a very similar interface: there is an indicator on the menu bar / task bar that opens a menu if clicked:
In order to make btsyncindicator.py act as similar as possible to the original BitTorrent software, the following changes should be implemented:
Patched it in my fork for my own use.
https://github.com/BrandonIngalls/btsyncindicator/blob/master/btsyncindicator.py
I added a re rule in the config loader to remove starting at a '/' all the way to '/'
Example comment...
"""
/* storage_path dir contains auxilliary app files
if no storage_path field: .sync dir created in the directory
where binary is located.
otherwise user-defined directory will be used
*/
"""
btsyncindicator.py searches by default its bitmap files in subdirectory located below btsyncindicator.py itself. Currently the Debian package installs btsyncindicator.py in /usr/lib/btsync-user and the bitmaps in /usr/lib/btsync-user/icons but this does not conforms to the Debian policy - in fact lintian complains:
W: btsync-user: image-file-in-usr-lib usr/lib/btsync-user/icons/btsync-active.png
W: btsync-user: image-file-in-usr-lib usr/lib/btsync-user/icons/btsync-attention.png
W: btsync-user: image-file-in-usr-lib usr/lib/btsync-user/icons/btsync-error.png
W: btsync-user: image-file-in-usr-lib usr/lib/btsync-user/icons/btsync.png
Solution approach 1 (preferred):
Allow the user to override the bitmap subdirectory with a command line parameter
Solution approach 2:
On startup, test if there are bitmap files in the icons/-subsdirectory. If not, use the subdirectory /usr/share/btsync-user/icons
After the refurbishing of the web interface, btsyncindicator.py does not work any more.
There are errors with the encoding:
/usr/lib/btsync-user/btsyncindicator.py:138: Warning: /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./gobject/gsignal.c:2459: signal `child-added' is invalid for instance `0x9242020'
self.ind.set_menu(self.menu)
Traceback (most recent call last):
File "/usr/lib/btsync-user/btsyncindicator.py", line 315, in check_status
folder['name'] = self.fix_encoding(folder['name'])
File "/usr/lib/btsync-user/btsyncindicator.py", line 675, in fix_encoding
return text.encode('latin-1').decode('utf-8')
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd6 in position 15: invalid continuation byte
After applying a workaround (let func fix_encoding
simply return text
), there are other errors:
/usr/lib/btsync-user/btsyncindicator.py:138: Warning: /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./gobject/gsignal.c:2459: signal `child-added' is invalid for instance `0x991c020'
self.ind.set_menu(self.menu)
Traceback (most recent call last):
File "/usr/lib/btsync-user/btsyncindicator.py", line 335, in check_status
submenu = self.build_folder_menu(folder)
File "/usr/lib/btsync-user/btsyncindicator.py", line 412, in build_folder_menu
folderitem['sizeitem'] = gtk.MenuItem(folder['size'])
TypeError: GtkMenuItem.__init__() argument 1 must be string or None, not int
In case of disconnection from the btsync agent, btsyncindicator.py reacts by removing the folder menu items, adding an error message as the first disabled menu item and showing an error status icon.
Unfortunately also other functional menu items are removed (and not added back after reconnection).
It would be correct to leave the other functional items (like "Enable Debug Logging" and "Open Web Interface") in the menu and only disable the ones that make not sense ("Open Web Interface") in case of disconnection.
This is not an important issue, but the indicator is starting two times after I log in, that is, there are two icons of BitTorrent Sync.
When closing one, it also closes the other one...
Environment:
I Btsync updated yesterday and I noticed that the indicator didn't show up in the KDE indicator bar correctly. I stopped and restarted btsync manually (btsync-stopper & btsync-starter), and here is the error from the indicator start:
Traceback (most recent call last):
File "/usr/lib/btsync-user/btsyncindicator.py", line 252, in setup_session
response = requests.get(self.urlroot, params=params, cookies=self.cookies, auth=self.auth)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 55, in get
return request('get', url, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 327, in request
self.cookies = cookiejar_from_dict(cookies, cookiejar=self.cookies, overwrite=False)
File "/usr/local/lib/python2.7/dist-packages/requests/cookies.py", line 410, in cookiejar_from_dict
cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
File "/usr/local/lib/python2.7/dist-packages/requests/cookies.py", line 256, in getitem
return self._find_no_duplicates(name)
File "/usr/local/lib/python2.7/dist-packages/requests/cookies.py", line 311, in _find_no_duplicates
raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name=Cookie(version=0, name='GUID', value='qa2jAaS3h5XqiV8zE8cu', port=None, port_specified=False, domain='127.0.0.1', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={}, rfc2109=False), domain=None, path=None"
Note: btsync and the web UI work properly and the indicator icon does appear, but the defined shares do not appear when right-clicking the indicator icon.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.