Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions git-annex-remote-owncloud
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ if dbglevel:

sys.path.append(pwd + '/lib')

import CommonFunctions as common
import owncloudannex.CommonFunctions as common

import davlib
import owncloudannex.davlib as davlib
client = False
encAuth = False
cache = {}

def login(user, pword):
common.log("")
global client, encAuth

base = conf["url"]
base = base[base.find("//") + 2: base.find("/", 8)]
encAuth = {"Authorization": "Basic %s" % ( base64.encodestring(user+":"+pword).strip() ) }
Expand Down Expand Up @@ -96,7 +96,7 @@ class BufferReader(io.BytesIO):

def postFile(subject, filename, folder):
common.log("%s to %s - %s" % ( repr(filename), folder[0], subject))

tmp_file = findInFolder(subject, folder)
if tmp_file:
common.log("File already exists: " + repr(tmp_file))
Expand Down Expand Up @@ -142,7 +142,7 @@ def findInFolder(subject, folder="/"):
common.log("Returning from cache")
return cache[tmp_path]
else:
common.log("No match in cache")
common.log("No match in cache")

try:
bla = client.propfind(tpath, depth=1, extra_hdrs=encAuth)
Expand All @@ -162,14 +162,14 @@ def findInFolder(subject, folder="/"):
tmp_file = urllib.unquote_plus(tmp_file)
tmp_file = tmp_file.replace(host, "")
common.log("folder1: " + tmp_file + " - " + tmp_path, 3)
if tmp_file[len(tmp_file) - 1] == "/":
tmp_file = tmp_file[:len(tmp_file) - 1]
if tmp_file[len(tmp_file) - 1] == "/":
tmp_file = tmp_file[:len(tmp_file) - 1]
cache[tmp_file] = tmp_file.replace(base, "/")

common.log("Updated cache: " + repr(cache), 3)
for tmp_file in cache.keys():
common.log("folder: " + tmp_file + " - " + tmp_path, 3)
if tmp_file == tmp_path:
if tmp_file == tmp_path:
common.log("Done: " + repr(cache[tmp_file]))
return cache[tmp_file]

Expand Down Expand Up @@ -203,7 +203,7 @@ def getFile(subject, filename, folder):
return response._read_chunked(amt)

if amt is None:
# unbounded read
# unbounded read
if response.length is None:
s = response.fp.read()
common.log("READING fp", 2)
Expand All @@ -221,24 +221,24 @@ def getFile(subject, filename, folder):
s += response._safe_read(tsize)
common.progress(response.length, len(s))
response.length = 0
response.close() # we read everything
response.close() # we read everything
return s

if response.length is not None:
if amt > response.length:
# clip the read to the "end of response"
# clip the read to the "end of response"
amt = response.length

# we do not use _safe_read() here because this may be a .will_close
# connection, and the user is reading more bytes than will be provided
# (for example, reading in 1k chunks)
# we do not use _safe_read() here because this may be a .will_close
# connection, and the user is reading more bytes than will be provided
# (for example, reading in 1k chunks)
s = response.fp.read(amt)
if response.length is not None:
response.length -= len(s)
if not response.length:
response.close()
return s

tmp_file = findInFolder(subject, folder)
if tmp_file:
base = conf["url"][conf["url"].find("/", 8):]
Expand Down
240 changes: 0 additions & 240 deletions lib/qp_xml.py

This file was deleted.

4 changes: 2 additions & 2 deletions lib/CommonFunctions.py → owncloudannex/CommonFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def read(self, n=-1):
if self._callback:
try:
self._callback(*self._cb_args, **self._cb_kwargs)
except: # catches exception from the callback
except: # catches exception from the callback
raise CancelledError('The upload was cancelled.')
return chunk

Expand Down Expand Up @@ -504,7 +504,7 @@ def updateWanted(size, filetypes):
expr += "("
org_filetypes = re.compile("include=(.*?) ").findall(old_wanted)
for t in filetypes:
expr += "include=*." + t + " or "
expr += "include=*." + t + " or "
expr = expr.strip()
if expr.rfind(" ") > -1:
expr = expr[:expr.rfind(" ")]
Expand Down
Empty file added owncloudannex/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions lib/davlib.py → owncloudannex/davlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, *args, **kw):
self.default_port = 443
else:
self.default_port = 80

apply(httplib.HTTPSConnection.__init__, (self,) + args, kw)

def connect(self):
Expand Down Expand Up @@ -332,4 +332,3 @@ def get_lock(self, url, owner='', timeout=None, depth=None):
response = self.lock(url, owner, timeout, depth)
response.parse_lock_response()
return response.locktoken

Loading