mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-29 12:19:03 +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 os
|
||||||
import urllib
|
import urllib
|
||||||
|
import urllib.parse
|
||||||
import socket
|
import socket
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ print("Initializing "+appname+"-client-nautilus extension")
|
||||||
def get_local_path(url):
|
def get_local_path(url):
|
||||||
if url[0:7] == 'file://':
|
if url[0:7] == 'file://':
|
||||||
url = url[7:]
|
url = url[7:]
|
||||||
return urllib.unquote(url)
|
return urllib.parse.unquote(url)
|
||||||
|
|
||||||
def get_runtime_dir():
|
def get_runtime_dir():
|
||||||
"""Returns the value of $XDG_RUNTIME_DIR, a directory path.
|
"""Returns the value of $XDG_RUNTIME_DIR, a directory path.
|
||||||
|
@ -56,7 +57,7 @@ class SocketConnect(GObject.GObject):
|
||||||
self._watch_id = 0
|
self._watch_id = 0
|
||||||
self._sock = None
|
self._sock = None
|
||||||
self._listeners = [self._update_registered_paths]
|
self._listeners = [self._update_registered_paths]
|
||||||
self._remainder = ''
|
self._remainder = ''.encode()
|
||||||
self.nautilusVFSFile_table = {} # not needed in this object actually but shared
|
self.nautilusVFSFile_table = {} # not needed in this object actually but shared
|
||||||
# all over the other objects.
|
# all over the other objects.
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ class SocketConnect(GObject.GObject):
|
||||||
# print("Server command: " + cmd)
|
# print("Server command: " + cmd)
|
||||||
if self.connected:
|
if self.connected:
|
||||||
try:
|
try:
|
||||||
self._sock.send(cmd)
|
self._sock.send(cmd.encode())
|
||||||
except:
|
except:
|
||||||
print("Sending failed.")
|
print("Sending failed.")
|
||||||
self.reconnect()
|
self.reconnect()
|
||||||
|
@ -113,17 +114,17 @@ class SocketConnect(GObject.GObject):
|
||||||
# Prepend the remaining data from last call
|
# Prepend the remaining data from last call
|
||||||
if len(self._remainder) > 0:
|
if len(self._remainder) > 0:
|
||||||
data = self._remainder + data
|
data = self._remainder + data
|
||||||
self._remainder = ''
|
self._remainder = ''.encode()
|
||||||
|
|
||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
# Remember the remainder for next round
|
# Remember the remainder for next round
|
||||||
lastNL = data.rfind('\n');
|
lastNL = data.rfind('\n'.encode());
|
||||||
if lastNL > -1 and lastNL < len(data):
|
if lastNL > -1 and lastNL < len(data):
|
||||||
self._remainder = data[lastNL+1:]
|
self._remainder = data[lastNL+1:]
|
||||||
data = data[:lastNL]
|
data = data[:lastNL]
|
||||||
|
|
||||||
for l in data.split('\n'):
|
for l in data.split('\n'.encode()):
|
||||||
self._handle_server_response(l)
|
self._handle_server_response(l.decode())
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue