Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
69578e4281 | ||
![]() |
2344c7b8af |
23
.drone.yml
23
.drone.yml
@@ -1,26 +1,17 @@
|
|||||||
pipeline:
|
pipeline:
|
||||||
pretty:
|
|
||||||
image: unibeautify/autopep8
|
|
||||||
commands:
|
|
||||||
- autopep8 imports -r --in-place
|
|
||||||
- autopep8 main.py --in-place
|
|
||||||
modules:
|
modules:
|
||||||
image: python:3.5
|
image: python:3.5
|
||||||
commands:
|
commands:
|
||||||
- rm -rf modules
|
- ./make-modules.sh
|
||||||
- mkdir -p .pip3
|
|
||||||
- ./make-modules.sh --cache-dir .pip3
|
|
||||||
package:
|
package:
|
||||||
image: kramos/alpine-zip
|
image: kramos/alpine-zip
|
||||||
commands:
|
commands:
|
||||||
- zip seafile.zip -r modules icon.png main.py metadata.xml settings.ui
|
- zip seafile.zip -r modules icon.png main.py metadata.xml settings.ui
|
||||||
release:
|
upload_package:
|
||||||
image: plugins/gitea-release
|
image: vividboarder/drone-webdav
|
||||||
api_key:
|
file: seafile.zip
|
||||||
from_secret: gitea_token
|
destination: https://git.shimun.net/files/screencloud-seafile/$$TAG.zip
|
||||||
base_url: https://git.shimun.net
|
username: git
|
||||||
files: seafile.zip
|
secrets: [webdav_password]
|
||||||
checksum:
|
|
||||||
- sha256
|
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +0,0 @@
|
|||||||
modules
|
|
||||||
.pip3
|
|
||||||
seafile.zip
|
|
||||||
lib
|
|
@@ -1,5 +1,3 @@
|
|||||||
from Crypto.Signature import PKCS1_v1_5
|
|
||||||
from Crypto.Hash import SHA256
|
|
||||||
import bson#, scrypt
|
import bson#, scrypt
|
||||||
|
|
||||||
from Crypto.Cipher import AES
|
from Crypto.Cipher import AES
|
||||||
@@ -7,13 +5,7 @@ from Crypto.Util import Counter
|
|||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
from Crypto.PublicKey import DSA
|
from Crypto.PublicKey import DSA
|
||||||
from salsa20 import Salsa20_keystream
|
from salsa20 import Salsa20_keystream
|
||||||
import os
|
import os, struct, time, hashlib, hashlib, random, binascii
|
||||||
import struct
|
|
||||||
import time
|
|
||||||
import hashlib
|
|
||||||
import hashlib
|
|
||||||
import random
|
|
||||||
import binascii
|
|
||||||
|
|
||||||
|
|
||||||
class EncryptedScreenshot:
|
class EncryptedScreenshot:
|
||||||
@@ -32,16 +24,14 @@ class EncryptedScreenshot:
|
|||||||
self.password_encryptor = password_encryptor
|
self.password_encryptor = password_encryptor
|
||||||
|
|
||||||
def caesar_encrypted_password(self):
|
def caesar_encrypted_password(self):
|
||||||
caesar_key = reduce(lambda sum, charcode: sum +
|
caesar_key = reduce(lambda sum,charcode: sum+charcode, map(ord,list(self.id)))
|
||||||
charcode, map(ord, list(self.id)))
|
|
||||||
caesar_plaintext = map(ord, self.password)
|
caesar_plaintext = map(ord, self.password)
|
||||||
caesar_ciphertext = Caesar().encrypt(caesar_plaintext,caesar_key)
|
caesar_ciphertext = Caesar().encrypt(caesar_plaintext,caesar_key)
|
||||||
return ''.join(map(chr,caesar_ciphertext))
|
return ''.join(map(chr,caesar_ciphertext))
|
||||||
|
|
||||||
def passphrase(self):
|
def passphrase(self):
|
||||||
# new ScryptParameters(64, 8, 1,32, new Uint8List.fromList(new List<int>()))
|
# new ScryptParameters(64, 8, 1,32, new Uint8List.fromList(new List<int>()))
|
||||||
print("Password units: %s" %
|
print("Password units: %s" % (map(ord, self.password.encode("utf-8")),))
|
||||||
(map(ord, self.password.encode("utf-8")),))
|
|
||||||
sha = hashlib.sha256()
|
sha = hashlib.sha256()
|
||||||
sha.update(self.password.encode("utf-8"))
|
sha.update(self.password.encode("utf-8"))
|
||||||
return sha.digest() # scrypt.hash(self.password.encode("utf-8"), '', 64, 8, 1, 32)
|
return sha.digest() # scrypt.hash(self.password.encode("utf-8"), '', 64, 8, 1, 32)
|
||||||
@@ -51,8 +41,7 @@ class EncryptedScreenshot:
|
|||||||
self.metadata["hash"] = image_digest
|
self.metadata["hash"] = image_digest
|
||||||
unencrypted_metadata = bson.dumps(self.metadata)
|
unencrypted_metadata = bson.dumps(self.metadata)
|
||||||
if len(unencrypted_metadata) % 16 != 0:
|
if len(unencrypted_metadata) % 16 != 0:
|
||||||
unencrypted_metadata += b' ' * \
|
unencrypted_metadata += b' ' * (16 - len(unencrypted_metadata) % 16)
|
||||||
(16 - len(unencrypted_metadata) % 16)
|
|
||||||
(encryptor, iv) = self.encryptor(len(unencrypted_metadata))
|
(encryptor, iv) = self.encryptor(len(unencrypted_metadata))
|
||||||
encrypted_metadata = b''
|
encrypted_metadata = b''
|
||||||
|
|
||||||
@@ -75,12 +64,10 @@ class EncryptedScreenshot:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.signer is not None:
|
if self.signer is not None:
|
||||||
fields["signature"] = self.signer.signature(
|
fields["signature"] = self.signer.signature(encrypted_metadata if self.metadata_encryption else bson.dumps(self.metadata))
|
||||||
encrypted_metadata if self.metadata_encryption else bson.dumps(self.metadata))
|
|
||||||
|
|
||||||
if self.password_encryptor is not None:
|
if self.password_encryptor is not None:
|
||||||
fields["password"] = self.password_encryptor.encrypt_password(
|
fields["password"] = self.password_encryptor.encrypt_password(self.password)
|
||||||
self.password)
|
|
||||||
|
|
||||||
return bson.dumps(fields)
|
return bson.dumps(fields)
|
||||||
|
|
||||||
@@ -122,6 +109,8 @@ class EncryptedScreenshot:
|
|||||||
binary += encryptor(chunk)
|
binary += encryptor(chunk)
|
||||||
return (digest.digest(), iv + binary)
|
return (digest.digest(), iv + binary)
|
||||||
|
|
||||||
|
from Crypto.Signature import PKCS1_v1_5
|
||||||
|
from Crypto.Hash import SHA256
|
||||||
|
|
||||||
class Signer:
|
class Signer:
|
||||||
|
|
||||||
@@ -164,7 +153,6 @@ class EncryptedPassword:
|
|||||||
"password": self.encrypt(password)
|
"password": self.encrypt(password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Caesar:
|
class Caesar:
|
||||||
|
|
||||||
def __init__(self,charset = map(ord,list("1234567890ABCDEFGHIJKLMNOPQRSTUWVXYZabcdefghijklmnopqrstuwvxyz"))):
|
def __init__(self,charset = map(ord,list("1234567890ABCDEFGHIJKLMNOPQRSTUWVXYZabcdefghijklmnopqrstuwvxyz"))):
|
||||||
@@ -194,8 +182,7 @@ if __name__ == "__main__":
|
|||||||
password_encryptor=EncryptedPassword(RSA.importKey(publicKey.decode("base64")),"PUBLIC"))
|
password_encryptor=EncryptedPassword(RSA.importKey(publicKey.decode("base64")),"PUBLIC"))
|
||||||
fixed_id = encrypted.id #"W9u9Zm0u"
|
fixed_id = encrypted.id #"W9u9Zm0u"
|
||||||
print(len(encrypted.passphrase()))
|
print(len(encrypted.passphrase()))
|
||||||
out = open(
|
out = open("/home/marvin/Dokumente/IdeaProjects/EncryptedScreencloud/Frontend/WebApp/web/data/" + fixed_id, 'wb')
|
||||||
"/home/marvin/Dokumente/IdeaProjects/EncryptedScreencloud/Frontend/WebApp/web/data/" + fixed_id, 'wb')
|
|
||||||
assembled = encrypted.assemble("5x5red.png")
|
assembled = encrypted.assemble("5x5red.png")
|
||||||
out.write(assembled)
|
out.write(assembled)
|
||||||
b = bson.loads(assembled)
|
b = bson.loads(assembled)
|
||||||
@@ -203,14 +190,11 @@ if __name__ == "__main__":
|
|||||||
print(b)
|
print(b)
|
||||||
#print(assembled.encode("base64").replace("\n","")
|
#print(assembled.encode("base64").replace("\n","")
|
||||||
print("http://localhost:8080/#%s%s" % (fixed_id, encrypted.password))
|
print("http://localhost:8080/#%s%s" % (fixed_id, encrypted.password))
|
||||||
caesar_key = reduce(lambda sum, charcode: sum +
|
caesar_key = reduce(lambda sum,charcode: sum+charcode, map(ord,list(fixed_id)))
|
||||||
charcode, map(ord, list(fixed_id)))
|
|
||||||
caesar_plaintext = map(ord,encrypted.password)
|
caesar_plaintext = map(ord,encrypted.password)
|
||||||
caesar_ciphertext = Caesar().encrypt(caesar_plaintext,caesar_key)
|
caesar_ciphertext = Caesar().encrypt(caesar_plaintext,caesar_key)
|
||||||
assert caesar_plaintext == Caesar().decrypt(caesar_ciphertext,caesar_key)
|
assert caesar_plaintext == Caesar().decrypt(caesar_ciphertext,caesar_key)
|
||||||
print("caesar_key=%s %s -> %s" %
|
print("caesar_key=%s %s -> %s" % (caesar_key,encrypted.password,''.join(map(chr,caesar_ciphertext))))
|
||||||
(caesar_key, encrypted.password, ''.join(map(chr, caesar_ciphertext))))
|
print("http://localhost:8080/#%s%sC" % (fixed_id, encrypted.caesar_encrypted_password()))
|
||||||
print("http://localhost:8080/#%s%sC" %
|
|
||||||
(fixed_id, encrypted.caesar_encrypted_password()))
|
|
||||||
print("http://localhost:8080/#%s" % (fixed_id, ))
|
print("http://localhost:8080/#%s" % (fixed_id, ))
|
||||||
out.close()
|
out.close()
|
||||||
|
@@ -2,7 +2,6 @@ import hashlib
|
|||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
|
|
||||||
class HashDerivedKey:
|
class HashDerivedKey:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -14,15 +13,13 @@ class HashDerivedKey:
|
|||||||
assert isinstance(b, bytes)
|
assert isinstance(b, bytes)
|
||||||
return b
|
return b
|
||||||
ensure_bytes(master)
|
ensure_bytes(master)
|
||||||
|
|
||||||
def derive(seed):
|
def derive(seed):
|
||||||
ensure_bytes(seed)
|
ensure_bytes(seed)
|
||||||
sha = hashlib.sha256()
|
sha = hashlib.sha256()
|
||||||
sha.update(master)
|
sha.update(master)
|
||||||
sha.update(seed)
|
sha.update(seed)
|
||||||
return sha.digest()
|
return sha.digest()
|
||||||
|
hex = lambda b: binascii.hexlify(b).decode("utf-8")
|
||||||
def hex(b): return binascii.hexlify(b).decode("utf-8")
|
|
||||||
self.master = master
|
self.master = master
|
||||||
self.master_hex = lambda: hex(master)
|
self.master_hex = lambda: hex(master)
|
||||||
self.derive = derive
|
self.derive = derive
|
||||||
|
@@ -2,49 +2,29 @@ import time
|
|||||||
|
|
||||||
from encryptedscreenshot import EncryptedScreenshot, Signer
|
from encryptedscreenshot import EncryptedScreenshot, Signer
|
||||||
from hashderive import HashDerivedKey
|
from hashderive import HashDerivedKey
|
||||||
import getpass
|
import getpass, os, sys
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from PythonQt.QtGui import QInputDialog
|
from PythonQt.QtGui import QInputDialog
|
||||||
from PythonQt.QtCore import QSettings
|
from PythonQt.QtCore import QSettings
|
||||||
from seafapi import *
|
from seafapi import *
|
||||||
|
|
||||||
|
|
||||||
class Processor:
|
class Processor:
|
||||||
|
|
||||||
def name(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def configure(self,parent):
|
def configure(self,parent):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def is_configured(self):
|
def is_configured(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def load_settings(self, settings):
|
def upload(self,file):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def save_settings(self, settings):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def upload(self, file, name):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class DummyProcessor(Processor):
|
class DummyProcessor(Processor):
|
||||||
|
|
||||||
def name(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def is_configured(self):
|
def is_configured(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class DefaultProcessor(Processor):
|
class DefaultProcessor(Processor):
|
||||||
|
|
||||||
def name(self):
|
|
||||||
return "default"
|
|
||||||
|
|
||||||
def __init__(self,seaf_lib,lib_path):
|
def __init__(self,seaf_lib,lib_path):
|
||||||
self.seaf_lib = seaf_lib
|
self.seaf_lib = seaf_lib
|
||||||
self.lib_path = lib_path
|
self.lib_path = lib_path
|
||||||
@@ -52,12 +32,8 @@ class DefaultProcessor(Processor):
|
|||||||
def upload(self,file,name):
|
def upload(self,file,name):
|
||||||
return self.seaf_lib.upload(file,name,self.lib_path).share()
|
return self.seaf_lib.upload(file,name,self.lib_path).share()
|
||||||
|
|
||||||
|
|
||||||
class EncryptedProcessor(Processor):
|
class EncryptedProcessor(Processor):
|
||||||
|
|
||||||
def name(self):
|
|
||||||
return "enc"
|
|
||||||
|
|
||||||
def __init__(self,seaf_lib,lib_path):
|
def __init__(self,seaf_lib,lib_path):
|
||||||
self.seaf_lib = seaf_lib
|
self.seaf_lib = seaf_lib
|
||||||
self.lib_path = lib_path
|
self.lib_path = lib_path
|
||||||
@@ -65,18 +41,22 @@ class EncryptedProcessor(Processor):
|
|||||||
self.derived_key = HashDerivedKey(os.urandom(32))
|
self.derived_key = HashDerivedKey(os.urandom(32))
|
||||||
self.load_settings()
|
self.load_settings()
|
||||||
|
|
||||||
def load_settings(self, settings=QSettings()):
|
def load_settings(self):
|
||||||
|
settings = QSettings()
|
||||||
|
settings.beginGroup("uploaders")
|
||||||
|
settings.beginGroup("seafile")
|
||||||
self.host = settings.value("encscreen-url", None)
|
self.host = settings.value("encscreen-url", None)
|
||||||
if settings.value("encscreen-derived-key", None):
|
if settings.value("encscreen-derived-key", None):
|
||||||
self.derived_key = HashDerivedKey.from_hex(
|
self.derived_key = HashDerivedKey.from_hex(settings.value("encscreen-derived-key", None))
|
||||||
settings.value("encscreen-derived-key", None))
|
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
|
|
||||||
def save_settings(self, settings=QSettings()):
|
def save_settings(self):
|
||||||
|
settings = QSettings()
|
||||||
|
settings.beginGroup("uploaders")
|
||||||
|
settings.beginGroup("seafile")
|
||||||
settings.setValue("encscreen-url", self.host)
|
settings.setValue("encscreen-url", self.host)
|
||||||
if self.derived_key:
|
if self.derived_key: settings.setValue(self.derived_key.master_hex())
|
||||||
settings.setValue(self.derived_key.master_hex())
|
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
|
|
||||||
@@ -84,10 +64,8 @@ class EncryptedProcessor(Processor):
|
|||||||
return self.host is not None and self.host != ""
|
return self.host is not None and self.host != ""
|
||||||
|
|
||||||
def configure(self,parent):
|
def configure(self,parent):
|
||||||
self.host = QInputDialog.getText(parent, 'Encscreen Server Setup', 'Enter server url (ex. https://servertld/s#%id%key):',
|
self.host = QInputDialog.getText(parent, 'Encscreen Server Setup', 'Enter server url (ex. https://servertld/s#%id%key):', text=(self.host or "https://screens.shimun.net/s#%id%key"))
|
||||||
text=(self.host or "https://screens.shimun.net/s#%id%key"))
|
master = QInputDialog.getText(parent, 'Encscreen Master Key Setup', 'Enter master key (hex encoded):', text=(self.derived_key.master_hex() if self.derived_key else "<random>"))
|
||||||
master = QInputDialog.getText(parent, 'Encscreen Master Key Setup', 'Enter master key (hex encoded):', text=(
|
|
||||||
self.derived_key.master_hex() if self.derived_key else "<random>"))
|
|
||||||
try:
|
try:
|
||||||
self.derived_key = HashDerivedKey.from_hex(master)
|
self.derived_key = HashDerivedKey.from_hex(master)
|
||||||
except:
|
except:
|
||||||
@@ -111,8 +89,7 @@ class EncryptedProcessor(Processor):
|
|||||||
tmpHandle = open(file + "c", 'wb')
|
tmpHandle = open(file + "c", 'wb')
|
||||||
tmpHandle.write(enrypted.assemble(file))
|
tmpHandle.write(enrypted.assemble(file))
|
||||||
tmpHandle.close()
|
tmpHandle.close()
|
||||||
seaf_file = self.seaf_lib.upload(
|
seaf_file = self.seaf_lib.upload(file + "c",name + ".enc",self.lib_path)
|
||||||
file + "c", name + ".enc", self.lib_path)
|
|
||||||
if not seaf_file:
|
if not seaf_file:
|
||||||
return
|
return
|
||||||
seaf_link = seaf_file.share()
|
seaf_link = seaf_file.share()
|
||||||
@@ -121,3 +98,5 @@ class EncryptedProcessor(Processor):
|
|||||||
return self.host.replace('%id', id).replace('%key',"%s" % enrypted.password)
|
return self.host.replace('%id', id).replace('%key',"%s" % enrypted.password)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import time
|
import time, os
|
||||||
import os
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
class SeafileClient:
|
class SeafileClient:
|
||||||
|
|
||||||
def __init__(self,server,username,password=None,token=None):
|
def __init__(self,server,username,password=None,token=None):
|
||||||
@@ -10,8 +8,7 @@ class SeafileClient:
|
|||||||
self.token = token
|
self.token = token
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
if token:
|
if token:
|
||||||
self.session.headers.update(
|
self.session.headers.update({'Authorization': "Token %s" % self.token.token})
|
||||||
{'Authorization': "Token %s" % self.token.token})
|
|
||||||
self.login = (username,password)
|
self.login = (username,password)
|
||||||
|
|
||||||
def api_endpoint(self):
|
def api_endpoint(self):
|
||||||
@@ -23,11 +20,11 @@ class SeafileClient:
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def obtain_token(self):
|
def obtain_token(self):
|
||||||
user,passw = self.login
|
user,passw = self.login
|
||||||
try:
|
try:
|
||||||
req = requests.post("%s/auth-token/" % self.api_endpoint(),
|
req=requests.post("%s/auth-token/" % self.api_endpoint(), data = {'username': user, 'password': passw })
|
||||||
data={'username': user, 'password': passw})
|
|
||||||
json = req.json()
|
json = req.json()
|
||||||
if "non_field_errors" in json:
|
if "non_field_errors" in json:
|
||||||
print(json["non_field_errors"])
|
print(json["non_field_errors"])
|
||||||
@@ -39,24 +36,19 @@ class SeafileClient:
|
|||||||
def authorize(self):
|
def authorize(self):
|
||||||
self.token = self.obtain_token()
|
self.token = self.obtain_token()
|
||||||
if self.token:
|
if self.token:
|
||||||
self.session.headers.update(
|
self.session.headers.update({'Authorization': "Token %s" % self.token.token})
|
||||||
{'Authorization': "Token %s" % self.token.token})
|
|
||||||
return self.token != False
|
return self.token != False
|
||||||
|
|
||||||
#curl -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/
|
#curl -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/
|
||||||
def libraries(self):
|
def libraries(self):
|
||||||
resp = self.session.get("%s/repos/" % self.api_endpoint(), headers={
|
resp=self.session.get("%s/repos/" % self.api_endpoint(), headers = {'Authorization': "Token %s" % self.token.token, 'Accept': 'application/json; indent=4' })
|
||||||
'Authorization': "Token %s" % self.token.token, 'Accept': 'application/json; indent=4'})
|
if not resp.status_code == 200: return
|
||||||
if not resp.status_code == 200:
|
|
||||||
return
|
|
||||||
libraries=[]
|
libraries=[]
|
||||||
for lib in resp.json():
|
for lib in resp.json():
|
||||||
if not lib['encrypted']:
|
if not lib['encrypted']:
|
||||||
libraries.append(SeafileLibrary(
|
libraries.append(SeafileLibrary(self,lib['id'],lib['name'],lib['owner']))
|
||||||
self, lib['id'], lib['name'], lib['owner']))
|
|
||||||
return libraries
|
return libraries
|
||||||
|
|
||||||
|
|
||||||
class SeafileLibrary:
|
class SeafileLibrary:
|
||||||
|
|
||||||
def __init__(self,client,id,name,owner):
|
def __init__(self,client,id,name,owner):
|
||||||
@@ -73,16 +65,13 @@ class SeafileLibrary:
|
|||||||
def obtain_link():
|
def obtain_link():
|
||||||
#curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-925367374cf0/upload-link/
|
#curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-925367374cf0/upload-link/
|
||||||
print("%s/upload-link" % self.api_endpoint())
|
print("%s/upload-link" % self.api_endpoint())
|
||||||
quoted = self.session.get("%s/upload-link" % self.api_endpoint(), headers={
|
quoted = self.session.get("%s/upload-link" % self.api_endpoint(), headers = {'Authorization': "Token %s" % self.client.token.token,}).text
|
||||||
'Authorization': "Token %s" % self.client.token.token, }).text
|
|
||||||
return quoted[1:-1]
|
return quoted[1:-1]
|
||||||
|
|
||||||
#curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -F file=@test.txt -F filename=test.txt -F parent_dir=/ http://cloud.seafile.com:8082/upload-api/73c5d117-3bcf-48a0-aa2a-3f48d5274ae3
|
#curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -F file=@test.txt -F filename=test.txt -F parent_dir=/ http://cloud.seafile.com:8082/upload-api/73c5d117-3bcf-48a0-aa2a-3f48d5274ae3
|
||||||
resp = self.session.post(link or obtain_link() ,
|
resp = self.session.post(link or obtain_link() ,
|
||||||
files={'file': (file_name, open(
|
files={'file': (file_name,open(file, 'rb')), 'parent_dir': directory, 'target_file': "%s/%s" % (directory,file_name)},
|
||||||
file, 'rb')), 'parent_dir': directory, 'target_file': "%s/%s" % (directory, file_name)},
|
headers = {'Authorization': "Token %s" % self.client.token.token,}
|
||||||
headers={
|
|
||||||
'Authorization': "Token %s" % self.client.token.token, }
|
|
||||||
)
|
)
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
return SeafileFile(self,("%s/%s" % (directory,file_name)).replace('//','/').replace('//','/'),resp.text)
|
return SeafileFile(self,("%s/%s" % (directory,file_name)).replace('//','/').replace('//','/'),resp.text)
|
||||||
@@ -90,8 +79,7 @@ class SeafileLibrary:
|
|||||||
|
|
||||||
#curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/detail/?p=/foo.c
|
#curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/detail/?p=/foo.c
|
||||||
def file_info(self,path):
|
def file_info(self,path):
|
||||||
resp = self.session.get("%s/file/detail/?p=%s" % (self.api_endpoint(), path), headers={
|
resp=self.session.get("%s/file/detail/?p=%s" % (self.api_endpoint(),path), headers = {'Authorization': "Token %s" % self.token.token, 'Accept': 'application/json; indent=4' })
|
||||||
'Authorization': "Token %s" % self.token.token, 'Accept': 'application/json; indent=4'})
|
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
json = resp.json()
|
json = resp.json()
|
||||||
return SeafileFile(self,path,json['id'],json['size'])
|
return SeafileFile(self,path,json['id'],json['size'])
|
||||||
@@ -100,7 +88,6 @@ class SeafileLibrary:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s on %s by %s" % (self.name,self.client.server,self.owner)
|
return "%s on %s by %s" % (self.name,self.client.server,self.owner)
|
||||||
|
|
||||||
|
|
||||||
class SeafileFile:
|
class SeafileFile:
|
||||||
|
|
||||||
def __init__(self,library,path,id,size=0):
|
def __init__(self,library,path,id,size=0):
|
||||||
@@ -111,27 +98,26 @@ class SeafileFile:
|
|||||||
self.size = size
|
self.size = size
|
||||||
|
|
||||||
#curl -v -X PUT -d "p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/afc3b694-7d4c-4b8a-86a4-89c9f3261b12/file/shared-link/
|
#curl -v -X PUT -d "p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/afc3b694-7d4c-4b8a-86a4-89c9f3261b12/file/shared-link/
|
||||||
def share(self,expire_days=None):
|
def share(self,expire=None,password=None):
|
||||||
data = {'p': self.path}
|
parameters = {'p': self.path }
|
||||||
if expire_days and not expire_days == 0:
|
if expiry:
|
||||||
data['expire'] = expire_days
|
parameters['expire'] = int(expire)
|
||||||
|
if password:
|
||||||
|
parameters['password'] = str(password)
|
||||||
resp = self.session.put("%s/repos/%s/file/shared-link/" % (self.library.client.api_endpoint(),self.library.id),
|
resp = self.session.put("%s/repos/%s/file/shared-link/" % (self.library.client.api_endpoint(),self.library.id),
|
||||||
headers={'Authorization': "Token %s" % self.library.client.token.token,
|
headers = {'Authorization': "Token %s" % self.library.client.token.token, 'Accept': 'application/json; indent=4'},
|
||||||
'Accept': 'application/json; indent=4'},
|
data = parameters
|
||||||
data = data
|
|
||||||
)
|
)
|
||||||
return resp.headers.get("location")
|
return resp.headers.get("location")
|
||||||
|
|
||||||
def update(self,file):
|
def update(self,file):
|
||||||
def obtain_link():
|
def obtain_link():
|
||||||
#curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-925367374cf0/upload-link/
|
#curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-925367374cf0/upload-link/
|
||||||
quoted = self.session.get("%s/update-link" % self.library.api_endpoint(), headers={
|
quoted = self.session.get("%s/update-link" % self.library.api_endpoint(), headers = {'Authorization': "Token %s" % self.library.client.token.token,}).text
|
||||||
'Authorization': "Token %s" % self.library.client.token.token, }).text
|
|
||||||
return quoted[1:-1]
|
return quoted[1:-1]
|
||||||
directory, name = os.path.split(self.path)
|
directory, name = os.path.split(self.path)
|
||||||
return self.library.upload(file,name,directory,obtain_link())
|
return self.library.upload(file,name,directory,obtain_link())
|
||||||
|
|
||||||
|
|
||||||
class SeafileToken:
|
class SeafileToken:
|
||||||
|
|
||||||
def __init__(self,username,token):
|
def __init__(self,username,token):
|
||||||
@@ -140,3 +126,5 @@ class SeafileToken:
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s@%s" % (self.token,self.username)
|
return "%s@%s" % (self.token,self.username)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,76 +0,0 @@
|
|||||||
from processors import DummyProcessor, DefaultProcessor, EncryptedProcessor
|
|
||||||
from seafapi import *
|
|
||||||
|
|
||||||
|
|
||||||
class SeafScreencloudSettings:
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.processor = DummyProcessor()
|
|
||||||
self.library = None # (Id, Name)
|
|
||||||
self.library_path = "/"
|
|
||||||
self.token = None # SefileToken
|
|
||||||
self.upload_scheme = "regular"
|
|
||||||
self.url = None
|
|
||||||
self.link_expiry = None
|
|
||||||
|
|
||||||
def _client(self):
|
|
||||||
if self.token and self.url:
|
|
||||||
client = SeafileClient(
|
|
||||||
self.url, self.token.username, token=self.token)
|
|
||||||
|
|
||||||
def c():
|
|
||||||
return client
|
|
||||||
self.client = c
|
|
||||||
return c()
|
|
||||||
return None
|
|
||||||
|
|
||||||
def load(self, settings):
|
|
||||||
|
|
||||||
self.client = self._client
|
|
||||||
|
|
||||||
self.url = settings.value("seafile-url", None)
|
|
||||||
self.link_expiry = int(settings.value("link-expiry", None))
|
|
||||||
lib = tuple(settings.value("library", "/").split("/"))
|
|
||||||
(id, name) = lib
|
|
||||||
if len(id) == 0 or self.client() == None:
|
|
||||||
self.library = None
|
|
||||||
else:
|
|
||||||
self.library = SeafileLibrary(self.client(), id, name, name)
|
|
||||||
self.library_path = settings.value("library-path", "/")
|
|
||||||
(user, tkn) = (settings.value("auth-username", None),
|
|
||||||
settings.value("auth-token", None))
|
|
||||||
if user == None or tkn == None:
|
|
||||||
self.token = None
|
|
||||||
else:
|
|
||||||
self.token = SeafileToken(user, tkn)
|
|
||||||
|
|
||||||
processors = {
|
|
||||||
"default": DefaultProcessor,
|
|
||||||
"enc": EncryptedProcessor
|
|
||||||
}
|
|
||||||
|
|
||||||
if settings.value("processor", None) in processors:
|
|
||||||
self.processor = processors[settings.value("processor", None)](
|
|
||||||
self.library, self.library_path)
|
|
||||||
self.processor.load_settings(settings)
|
|
||||||
elif self.library:
|
|
||||||
self.processor = DefaultProcessor(self.library, self.library_path)
|
|
||||||
else:
|
|
||||||
self.processor = DummyProcessor()
|
|
||||||
|
|
||||||
# TODO:
|
|
||||||
self.upload_scheme = "regular"
|
|
||||||
|
|
||||||
def save(self, settings):
|
|
||||||
settings.setValue("seafile-url", self.url)
|
|
||||||
if self.library is not None:
|
|
||||||
settings.setValue("library", "%s/%s" %
|
|
||||||
(self.library.id, self.library.name))
|
|
||||||
if self.link_expiry is not None:
|
|
||||||
settings.setValue("link-expiry", self.link_expiry)
|
|
||||||
settings.setValue("library-path", self.library_path)
|
|
||||||
if self.token != None:
|
|
||||||
settings.setValue("auth-username", self.token.username)
|
|
||||||
settings.setValue("auth-token", self.token.token)
|
|
||||||
settings.setValue("processor", self.processor.name())
|
|
||||||
self.processor.save_settings(settings)
|
|
132
main.py
132
main.py
@@ -6,7 +6,6 @@ from PythonQt.QtUiTools import QUiLoader
|
|||||||
from multiprocessing import Pool,Process
|
from multiprocessing import Pool,Process
|
||||||
|
|
||||||
from seafapi import *
|
from seafapi import *
|
||||||
from settings import SeafScreencloudSettings
|
|
||||||
from processors import DummyProcessor, DefaultProcessor, EncryptedProcessor
|
from processors import DummyProcessor, DefaultProcessor, EncryptedProcessor
|
||||||
###############################
|
###############################
|
||||||
## This is a temporary fix, should be removed when a newer python version is used ##
|
## This is a temporary fix, should be removed when a newer python version is used ##
|
||||||
@@ -14,27 +13,26 @@ import logging
|
|||||||
logging.captureWarnings(True)
|
logging.captureWarnings(True)
|
||||||
###############################
|
###############################
|
||||||
|
|
||||||
|
|
||||||
class SeafileUploader():
|
class SeafileUploader():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.set = SeafScreencloudSettings()
|
self.processor = DummyProcessor()
|
||||||
|
self.seaf_lib = None
|
||||||
|
self.seaf_path = "/"
|
||||||
self.libs = None
|
self.libs = None
|
||||||
self.uil = QUiLoader()
|
self.uil = QUiLoader()
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
self.pool = Pool(2)
|
self.pool = Pool(2)
|
||||||
|
self.seaf_client = None
|
||||||
|
self.link_expiry = None
|
||||||
|
|
||||||
def showSettingsUI(self, parentWidget):
|
def showSettingsUI(self, parentWidget):
|
||||||
self.parentWidget = parentWidget
|
self.parentWidget = parentWidget
|
||||||
# self.set.processor.configure(parentWidget)
|
#self.processor.configure(parentWidget)
|
||||||
self.settingsDialog = self.uil.load(
|
self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget)
|
||||||
QFile(workingDir + "/settings.ui"), parentWidget)
|
self.settingsDialog.group_account.widget_loggedIn.loginButton.connect("clicked()", self.startAuthenticationProcess)
|
||||||
self.settingsDialog.group_account.widget_loggedIn.loginButton.connect(
|
|
||||||
"clicked()", self.startAuthenticationProcess)
|
|
||||||
#self.settingsDialog.group_name.input_name.connect("textChanged(QString)", self.nameFormatEdited)
|
#self.settingsDialog.group_name.input_name.connect("textChanged(QString)", self.nameFormatEdited)
|
||||||
self.settingsDialog.group_location.widget_location.pathEdit.connect(
|
self.settingsDialog.group_location.widget_location.pathEdit.connect("textChanged(QString)", self.locationUpdate)
|
||||||
"textChanged(QString)", self.locationUpdate)
|
self.settingsDialog.group_location.widget_location.libraryEditDrop.connect("currentIndexChanged(QString)", self.locationUpdate)
|
||||||
self.settingsDialog.group_location.widget_location.libraryEditDrop.connect(
|
|
||||||
"currentIndexChanged(QString)", self.locationUpdate)
|
|
||||||
self.settingsDialog.connect("accepted()", self.saveSettings)
|
self.settingsDialog.connect("accepted()", self.saveSettings)
|
||||||
|
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
@@ -46,11 +44,11 @@ class SeafileUploader():
|
|||||||
drop.clear()
|
drop.clear()
|
||||||
drop.setEnabled(False)
|
drop.setEnabled(False)
|
||||||
select = 0
|
select = 0
|
||||||
if self.set.client() and self.set.client().ping():
|
if self.seaf_client and self.seaf_client.ping():
|
||||||
self.libs = self.set.client().libraries()
|
self.libs = (self.seaf_client or self.seaf_lib.client).libraries()
|
||||||
i=0
|
i=0
|
||||||
for lib in self.libs:
|
for lib in self.libs:
|
||||||
if self.set.library is not None and (lib.id == self.set.library.id or lib.name == self.set.library.name):
|
if self.seaf_lib is not None and lib.id == self.seaf_lib.id:
|
||||||
select = i
|
select = i
|
||||||
print("set %s" % lib.name)
|
print("set %s" % lib.name)
|
||||||
drop.addItem(lib.name)
|
drop.addItem(lib.name)
|
||||||
@@ -59,22 +57,16 @@ class SeafileUploader():
|
|||||||
drop.setEnabled(True)
|
drop.setEnabled(True)
|
||||||
|
|
||||||
def updateUi(self):
|
def updateUi(self):
|
||||||
self.settingsDialog.group_account.widget_loggedIn.usernameEdit.setText(
|
self.settingsDialog.group_account.widget_loggedIn.usernameEdit.setText(self.access_token.username if not (self.access_token is None) else "")
|
||||||
self.set.token.username if not (self.set.token is None) else "")
|
self.settingsDialog.group_account.widget_loggedIn.serverUrlEdit.setText(self.seaf_url or "https://seaf.shimun.net")
|
||||||
self.settingsDialog.group_account.widget_loggedIn.serverUrlEdit.setText(
|
self.settingsDialog.group_account.widget_loggedIn.loginButton.setText("Logout" if self.access_token is not None else "Login")
|
||||||
self.set.url or "https://seaf.shimun.net")
|
|
||||||
self.settingsDialog.group_account.widget_loggedIn.loginButton.setText(
|
|
||||||
"Logout" if self.set.token is not None else "Login")
|
|
||||||
#
|
#
|
||||||
if self.set.token is None and len(self.settingsDialog.group_account.widget_loggedIn.passwordEdit.text) > 0:
|
if self.access_token is None and len(self.settingsDialog.group_account.widget_loggedIn.passwordEdit.text) > 0:
|
||||||
self.settingsDialog.group_account.widget_loggedIn.passwordEdit.setText(
|
self.settingsDialog.group_account.widget_loggedIn.passwordEdit.setText("X" * 8)
|
||||||
"X" * 8)
|
|
||||||
for elm in [self.settingsDialog.group_account.widget_loggedIn.usernameEdit, self.settingsDialog.group_account.widget_loggedIn.serverUrlEdit, self.settingsDialog.group_account.widget_loggedIn.passwordEdit]:
|
for elm in [self.settingsDialog.group_account.widget_loggedIn.usernameEdit, self.settingsDialog.group_account.widget_loggedIn.serverUrlEdit, self.settingsDialog.group_account.widget_loggedIn.passwordEdit]:
|
||||||
elm.setEnabled(self.set.token is None)
|
elm.setEnabled(self.access_token is None)
|
||||||
self.settingsDialog.group_location.setEnabled(
|
self.settingsDialog.group_location.setEnabled(self.access_token is not None)
|
||||||
self.set.token is not None)
|
self.settingsDialog.group_location.widget_location.pathEdit.setText(self.lib_path or "/")
|
||||||
self.settingsDialog.group_location.widget_location.pathEdit.setText(
|
|
||||||
self.set.library_path or "/")
|
|
||||||
self.settingsDialog.linkCopyCheck.setChecked(self.copyLink)
|
self.settingsDialog.linkCopyCheck.setChecked(self.copyLink)
|
||||||
self.populateLibrarySelector()
|
self.populateLibrarySelector()
|
||||||
self.settingsDialog.adjustSize()
|
self.settingsDialog.adjustSize()
|
||||||
@@ -83,30 +75,56 @@ class SeafileUploader():
|
|||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
settings.beginGroup("uploaders")
|
settings.beginGroup("uploaders")
|
||||||
settings.beginGroup("seafile")
|
settings.beginGroup("seafile")
|
||||||
self.set.load(settings)
|
self.seaf_url = settings.value("seafile-url", "")
|
||||||
|
(self.lib_id,self.lib_name) = str(settings.value("library", "/")).split("/")
|
||||||
|
self.lib_path = settings.value("library-path", "")
|
||||||
self.copyLink = settings.value("copy-link", "true") in ['true', True]
|
self.copyLink = settings.value("copy-link", "true") in ['true', True]
|
||||||
self.nameFormat = settings.value(
|
self.link_expiry = settings.value("link-expiry", None)
|
||||||
"name-format", "Screenshot %Y-%m-%d %H_%M_%S")
|
if settings.value("auth-token", False) and settings.value("auth-username", False):
|
||||||
|
self.access_token = SeafileToken(settings.value("auth-username", False),settings.value("auth-token", False))
|
||||||
|
else:
|
||||||
|
self.access_token = None
|
||||||
|
self.nameFormat = settings.value("name-format", "Screenshot %Y-%m-%d %H_%M_%S")
|
||||||
self.upload_scheme = settings.value("upload-scheme", "regular")
|
self.upload_scheme = settings.value("upload-scheme", "regular")
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
|
if self.seaf_url and self.access_token:
|
||||||
|
self.seaf_client = SeafileClient(self.seaf_url,self.access_token.username,token=self.access_token)
|
||||||
|
if self.seaf_client.ping():
|
||||||
|
for lib in self.seaf_client.libraries():
|
||||||
|
if lib.id == self.lib_id:
|
||||||
|
self.seaf_lib = lib
|
||||||
|
if self.seaf_lib and self.seaf_path:
|
||||||
|
self.processor = EncryptedProcessor(self.seaf_lib,self.lib_path)#DefaultProcessor(self.seaf_lib,self.lib_path)
|
||||||
|
|
||||||
|
|
||||||
def saveSettings(self):
|
def saveSettings(self):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
settings.beginGroup("uploaders")
|
settings.beginGroup("uploaders")
|
||||||
settings.beginGroup("seafile")
|
settings.beginGroup("seafile")
|
||||||
self.set.save(settings)
|
|
||||||
try:
|
try:
|
||||||
self.copyLink = self.settingsDialog.linkCopyCheck.checked
|
self.copyLink = self.settingsDialog.linkCopyCheck.checked
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
settings.setValue("copy-link", self.copyLink)
|
settings.setValue("copy-link", self.copyLink)
|
||||||
|
if self.link_expiry:
|
||||||
|
settings.setValue("link-expiry", self.link_expiry)
|
||||||
|
if self.access_token is not None:
|
||||||
|
settings.setValue("auth-username", self.access_token.username )
|
||||||
|
settings.setValue("auth-token", self.access_token.token)
|
||||||
|
settings.setValue("seafile-url", self.seaf_url)
|
||||||
|
if self.seaf_lib is not None:
|
||||||
|
settings.setValue("library", "%s/%s" % (self.seaf_lib.id,self.seaf_lib.name))
|
||||||
|
settings.setValue("library-path", self.lib_path)
|
||||||
settings.setValue("name-format", self.nameFormat)
|
settings.setValue("name-format", self.nameFormat)
|
||||||
|
settings.setValue("upload-scheme", self.upload_scheme)
|
||||||
|
#settings.setValue("name-format", self.settingsDialog.group_name.input_name.text)
|
||||||
|
print(self.seaf_lib, self.lib_path)
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
|
|
||||||
def isConfigured(self):
|
def isConfigured(self):
|
||||||
return self.set.library and self.set.processor.is_configured()
|
return self.access_token and self.seaf_url and self.processor.is_configured()
|
||||||
|
|
||||||
def getFilename(self):
|
def getFilename(self):
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
@@ -115,12 +133,11 @@ class SeafileUploader():
|
|||||||
def upload(self, screenshot, name):
|
def upload(self, screenshot, name):
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
#Make sure we have a up to date token
|
#Make sure we have a up to date token
|
||||||
if not self.set.library:
|
if not self.seaf_lib:
|
||||||
ScreenCloud.setError("Not configured properly")
|
ScreenCloud.setError("Not configured properly")
|
||||||
return False
|
return False
|
||||||
#Save to a temporary file
|
#Save to a temporary file
|
||||||
timestamp = time.time()
|
timestamp = time.time()
|
||||||
|
|
||||||
def tempfile(name):
|
def tempfile(name):
|
||||||
try:
|
try:
|
||||||
return QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + name
|
return QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + name
|
||||||
@@ -132,33 +149,31 @@ class SeafileUploader():
|
|||||||
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
|
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
|
||||||
#Upload!
|
#Upload!
|
||||||
link=None
|
link=None
|
||||||
# if True:
|
if True:
|
||||||
try:
|
#try:
|
||||||
link = self.set.processor.upload(tmpFilename, self.getFilename())
|
link = self.processor.upload(tmpFilename,self.getFilename())
|
||||||
if self.copyLink:
|
if self.copyLink:
|
||||||
ScreenCloud.setUrl(link)
|
ScreenCloud.setUrl(link)
|
||||||
except Exception as e:
|
#except Exception as e:
|
||||||
ScreenCloud.setError("Failed to upload to seafile. Using: %s\n\n%s" % (
|
# ScreenCloud.setError("Failed to upload to seafile. " + e.message)
|
||||||
self.set.processor.name(), e.message))
|
# return False
|
||||||
return False
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def startAuthenticationProcess(self):
|
def startAuthenticationProcess(self):
|
||||||
self.saveSettings()
|
self.saveSettings()
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
|
|
||||||
if self.set.token is not None:
|
if self.access_token is not None:
|
||||||
self.logOut()
|
self.logOut()
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.settingsDialog.group_account.widget_loggedIn.serverUrlEdit.text \
|
if self.settingsDialog.group_account.widget_loggedIn.serverUrlEdit.text \
|
||||||
and self.settingsDialog.group_account.widget_loggedIn.usernameEdit.text \
|
and self.settingsDialog.group_account.widget_loggedIn.usernameEdit.text \
|
||||||
and self.settingsDialog.group_account.widget_loggedIn.passwordEdit.text:
|
and self.settingsDialog.group_account.widget_loggedIn.passwordEdit.text:
|
||||||
self.set.url = self.settingsDialog.group_account.widget_loggedIn.serverUrlEdit.text
|
self.seaf_url = self.settingsDialog.group_account.widget_loggedIn.serverUrlEdit.text
|
||||||
if True:
|
if True:
|
||||||
#try:
|
#try:
|
||||||
self.login(self.settingsDialog.group_account.widget_loggedIn.usernameEdit.text,
|
self.login(self.settingsDialog.group_account.widget_loggedIn.usernameEdit.text,self.settingsDialog.group_account.widget_loggedIn.passwordEdit.text)
|
||||||
self.settingsDialog.group_account.widget_loggedIn.passwordEdit.text)
|
|
||||||
self.saveSettings()
|
self.saveSettings()
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
self.populateLibrarySelector()
|
self.populateLibrarySelector()
|
||||||
@@ -170,32 +185,31 @@ class SeafileUploader():
|
|||||||
def locationUpdate(self):
|
def locationUpdate(self):
|
||||||
drop = self.settingsDialog.group_location.widget_location.libraryEditDrop
|
drop = self.settingsDialog.group_location.widget_location.libraryEditDrop
|
||||||
selected_lib = drop.currentText
|
selected_lib = drop.currentText
|
||||||
if not drop.isEnabled():
|
if not drop.isEnabled(): return #not populated
|
||||||
return # not populated
|
self.lib_path = self.settingsDialog.group_location.widget_location.pathEdit.text
|
||||||
self.set.library_path = self.settingsDialog.group_location.widget_location.pathEdit.text
|
print(self.lib_path, selected_lib)
|
||||||
print(self.set.library_path, selected_lib)
|
if self.libs is None: return
|
||||||
if self.libs is None:
|
|
||||||
return
|
|
||||||
for lib in self.libs:
|
for lib in self.libs:
|
||||||
if lib.name == selected_lib:
|
if lib.name == selected_lib:
|
||||||
self.set.library = lib
|
self.seaf_lib = lib
|
||||||
print("%s user selected" % selected_lib)
|
print("%s user selected" % selected_lib)
|
||||||
|
|
||||||
|
|
||||||
def login(self,user,password):
|
def login(self,user,password):
|
||||||
cli = SeafileClient(self.set.url, user, password)
|
cli = SeafileClient(self.seaf_url,user,password)
|
||||||
self.set.token = cli.obtain_token()
|
self.access_token = cli.obtain_token()
|
||||||
|
|
||||||
def logOut(self):
|
def logOut(self):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
settings.beginGroup("uploaders")
|
settings.beginGroup("uploaders")
|
||||||
settings.beginGroup("seafile")
|
settings.beginGroup("seafile")
|
||||||
settings.remove("auth-token")
|
settings.remove("auth-token")
|
||||||
self.set.token = None
|
self.access_token = None
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
self.updateUi()
|
self.updateUi()
|
||||||
|
|
||||||
def nameFormatEdited(self, nameFormat):
|
def nameFormatEdited(self, nameFormat):
|
||||||
self.settingsDialog.group_name.label_example.setText(
|
self.settingsDialog.group_name.label_example.setText(ScreenCloud.formatFilename(nameFormat, False))
|
||||||
ScreenCloud.formatFilename(nameFormat, False))
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
mkdir -p modules
|
rm -rf modules
|
||||||
pip3 install --install-option="--prefix=$PWD" -r requirements.txt "$@"
|
mkdir modules
|
||||||
mv lib/python3.*/site-packages/* modules/
|
pip3 install --install-option="--prefix=$PWD" -r requirements.txt
|
||||||
|
mv lib/python3.5/site-packages/* modules/
|
||||||
cp imports/* -r modules/
|
cp imports/* -r modules/
|
||||||
|
Reference in New Issue
Block a user