mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 22:46:04 +03:00
Nautilus shell integration: Port to Python 3
This commit is contained in:
parent
497b327d43
commit
f254ee3211
1 changed files with 8 additions and 7 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
import os
|
||||
import urllib
|
||||
import urllib.parse
|
||||
import socket
|
||||
import tempfile
|
||||
|
||||
|
@ -34,7 +35,7 @@ print("Initializing "+appname+"-client-nautilus extension")
|
|||
def get_local_path(url):
|
||||
if url[0:7] == 'file://':
|
||||
url = url[7:]
|
||||
return urllib.unquote(url)
|
||||
return urllib.parse.unquote(url)
|
||||
|
||||
def get_runtime_dir():
|
||||
"""Returns the value of $XDG_RUNTIME_DIR, a directory path.
|
||||
|
@ -56,7 +57,7 @@ class SocketConnect(GObject.GObject):
|
|||
self._watch_id = 0
|
||||
self._sock = None
|
||||
self._listeners = [self._update_registered_paths]
|
||||
self._remainder = ''
|
||||
self._remainder = ''.encode()
|
||||
self.nautilusVFSFile_table = {} # not needed in this object actually but shared
|
||||
# all over the other objects.
|
||||
|
||||
|
@ -74,7 +75,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()
|
||||
|
@ -113,17 +114,17 @@ class SocketConnect(GObject.GObject):
|
|||
# Prepend the remaining data from last call
|
||||
if len(self._remainder) > 0:
|
||||
data = self._remainder + data
|
||||
self._remainder = ''
|
||||
self._remainder = ''.encode()
|
||||
|
||||
if len(data) > 0:
|
||||
# Remember the remainder for next round
|
||||
lastNL = data.rfind('\n');
|
||||
lastNL = data.rfind('\n'.encode());
|
||||
if lastNL > -1 and lastNL < len(data):
|
||||
self._remainder = data[lastNL+1:]
|
||||
data = data[:lastNL]
|
||||
|
||||
for l in data.split('\n'):
|
||||
self._handle_server_response(l)
|
||||
for l in data.split('\n'.encode()):
|
||||
self._handle_server_response(l.decode())
|
||||
else:
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in a new issue