|
|
@@ -15,8 +15,13 @@
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
# for more details.
|
|
|
|
|
|
+import sys
|
|
|
+python3 = sys.version_info[0] >= 3
|
|
|
+
|
|
|
import os
|
|
|
import urllib
|
|
|
+if python3:
|
|
|
+ import urllib.parse
|
|
|
import socket
|
|
|
import tempfile
|
|
|
import time
|
|
|
@@ -31,11 +36,11 @@ appname = 'ownCloud'
|
|
|
|
|
|
print("Initializing "+appname+"-client-nautilus extension")
|
|
|
|
|
|
-
|
|
|
def get_local_path(url):
|
|
|
if url[0:7] == 'file://':
|
|
|
url = url[7:]
|
|
|
- return urllib.unquote(url)
|
|
|
+ unquote = urllib.parse.unquote if python3 else urllib.unquote
|
|
|
+ return unquote(url)
|
|
|
|
|
|
def get_runtime_dir():
|
|
|
"""Returns the value of $XDG_RUNTIME_DIR, a directory path.
|
|
|
@@ -57,7 +62,7 @@ class SocketConnect(GObject.GObject):
|
|
|
self._watch_id = 0
|
|
|
self._sock = None
|
|
|
self._listeners = [self._update_registered_paths, self._get_version]
|
|
|
- self._remainder = ''
|
|
|
+ self._remainder = ''.encode()
|
|
|
self.protocolVersion = '1.0'
|
|
|
self.nautilusVFSFile_table = {} # not needed in this object actually but shared
|
|
|
# all over the other objects.
|
|
|
@@ -76,7 +81,7 @@ class SocketConnect(GObject.GObject):
|
|
|
# print("Server command: " + cmd)
|
|
|
if self.connected:
|
|
|
try:
|
|
|
- self._sock.send(cmd)
|
|
|
+ self._sock.send(cmd.encode())
|
|
|
except:
|
|
|
print("Sending failed.")
|
|
|
self.reconnect()
|
|
|
@@ -126,12 +131,12 @@ class SocketConnect(GObject.GObject):
|
|
|
|
|
|
# Parses response lines out of collected data, returns list of strings
|
|
|
def get_available_responses(self):
|
|
|
- end = self._remainder.rfind('\n')
|
|
|
+ end = self._remainder.rfind('\n'.encode())
|
|
|
if end == -1:
|
|
|
return []
|
|
|
data = self._remainder[:end]
|
|
|
self._remainder = self._remainder[end+1:]
|
|
|
- return data.split('\n')
|
|
|
+ return data.decode().split('\n')
|
|
|
|
|
|
# Notify is the raw answer from the socket
|
|
|
def _handle_notify(self, source, condition):
|