added direct file upload and a desktop file for custom file manager actions

This commit is contained in:
kageru 2017-11-15 14:12:51 +01:00
parent b9fa6dc19c
commit b635bef081
2 changed files with 12 additions and 2 deletions

8
pyshare.desktop Normal file
View File

@ -0,0 +1,8 @@
[Desktop Entry]
Type=Action
Name=Upload with pyshare
Profiles=profile-zero;
[X-Action-Profile profile-zero]
Exec=/home/kageru/pyshare/pyshare.py -f %f
Name=Default profile

6
pyshare.py Normal file → Executable file
View File

@ -6,7 +6,7 @@ from pysftp import Connection
from subprocess import call
from random import choices
import pyperclip
import config as config
import config
import sys
import os
import re
@ -48,6 +48,7 @@ def take_screenshot(filename: str) -> None:
def ftp_upload(mode='screenshot', ext=None, sourcefile=None) -> tuple:
if ext is None:
# TODO files without extension
exts = {
'screenshot': 'png',
'text': 'txt',
@ -64,9 +65,10 @@ def ftp_upload(mode='screenshot', ext=None, sourcefile=None) -> tuple:
if mode == 'screenshot':
take_screenshot(fullpath)
conn.put(fullpath)
notify_user(config.url_template.format(filename))
elif mode == 'file':
conn.put(sourcefile, filename)
notify_user(config.url_template.format(filename))
return fullpath, filename