Skip to content

Commit

Permalink
more python3 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lwahlmeier committed Feb 28, 2017
1 parent 8bf07be commit c427bd7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ownSyncUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ def addFile(self, newFile, path):
that file name will be used as its name.
"""
self.log.debug("Adding New File: %s/%s"%(path, os.path.basename(newFile)))
fp = open(newFile, "r")
data = open(newFile, "rb").read()
if path not in self.DIRS:
self.mkdir(path)
r, c = self.http.request(self.url+"/%s/%s"%(urlquote(path), urlquote(os.path.basename(newFile))), "PUT", body=fp.read())
r, c = self.http.request(str("{}/{}/{}".format(self.url, urlquote(path), urlquote(os.path.basename(newFile)))), "PUT", body=data)

def getLocalDIRS(self, path):
DIRS = dict()
Expand Down Expand Up @@ -284,12 +284,12 @@ def syncFROM(self, path, base="/"):
if f[:len(base)] == base:
newfile = fixPath(f[len(base):])
if newfile not in FILES:
self.log.info("Creating New file %s"%(f))
open("%s/%s"%(path,newfile), "w").write(self.getFile(f))
self.log.info("Creating New file {} {}".format(f, newfile))
open("%s/%s"%(path,newfile), "wb").write(self.getFile(f))
os.utime("%s/%s"%(path,newfile), (self.FILES[f]['lastMod']/1000, self.FILES[f]['lastMod']/1000))
elif FILES[newfile]['lastMod'] != self.FILES[f]['lastMod']:
self.log.info("Downloading Updated file %s"%(f))
open("%s/%s"%(path,newfile), "w").write(self.getFile(f))
open("%s/%s"%(path,newfile), "wb").write(self.getFile(f))
os.utime("%s/%s"%(path,newfile), (self.FILES[f]['lastMod']/1000, self.FILES[f]['lastMod']/1000))

for f in FILES:
Expand Down

0 comments on commit c427bd7

Please sign in to comment.