Skip to content

Commit

Permalink
Fix sending directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragoncraft89 committed Dec 23, 2018
1 parent cf8912b commit 0d2ffa2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
15 changes: 8 additions & 7 deletions kdeconnect-ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from gi.repository import GObject
from kdeconnect import send_files, get_available_devices
import zipfile
import urllib
import urlparse

TARGET = "%%TARGET%%".title()
Nautilus = importlib.import_module("gi.repository.{}".format(TARGET))
Expand All @@ -17,22 +19,21 @@ def zipdir(self, path, ziph):
import os
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file))
print(dirs + [file])
ziph.write(os.path.join(root, file), os.path.join(*(dirs + [file])))

def menu_activate_cb(self, menu, files, device_id, device_name, folder_list):
import zipfile
import os
for folder_name in folder_list:
zip_name = folder_name + '.zip'
zipf = zipfile.ZipFile(zip_name[7:], 'w', zipfile.ZIP_DEFLATED)
self.zipdir(folder_name + '/', zipf)
zip_name = urllib.url2pathname(urlparse.urlparse(folder_name + '.zip').path)
zipf = zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED)
self.zipdir(zip_name[:-4] + '/', zipf)
zipf.close()
zipfile = Nautilus.FileInfo.create_for_uri(zip_name)
zipfile = Nautilus.FileInfo.create_for_uri(folder_name + '.zip')
files.append(zipfile)

send_files(files, device_id, device_name)
for folder_name in folder_list:
os.remove(folder_name[7:] + '.zip')

def get_file_items(self, window, files):
try:
Expand Down
8 changes: 0 additions & 8 deletions kdeconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
import re

def send_files(files, device_id, device_name):
# results=[]
# failed=0
for file in files:
print("filename", file.get_uri())
return_code=call(["kdeconnect-cli", "-d", device_id, "--share", file.get_uri()])
# if (return_code != 0):
# failed += 1
# results.append(return_code)
call(["notify-send", "Sending {num_files} file(s) to {device_name}. Check your device.".format(num_files=len(files), device_name=device_name)])
# return results

def get_available_devices():
devices_a=[]
Expand Down

0 comments on commit 0d2ffa2

Please sign in to comment.