Пример #1
0
 def download(self):
     try:
         orngServerFiles.download(*(self.args + (self.advance, )))
     except Exception, ex:
         self.emit(SIGNAL("finish(QString)"), QString(str(ex)))
         self.exit(1)
         print >> sys.stderr, "error: ", ex
         return
import orngServerFiles
import os
reload(orngServerFiles)

domain = "demo"
filename = "orngServerFiles.py"

print "Downloading domain: %s, file: %s" % (domain, filename) 
orngServerFiles.download(domain, filename, verbose=False)
print "Needs update? %s (should be False)" % orngServerFiles.needs_update(domain, filename)

# change the access and modified time of the local file
# this is stored in the .info file (does not depend on the actual datetime
# values that we could access through os.stat(path) or set using us.utime)
path = orngServerFiles.localpath(domain, filename) + ".info"
f = file(path)
str = [f.readline()] # first line
s = "1800" + f.readline()[4:] # second line with date, change it
print "Changing date to", s.strip() 
str += [s]
str += f.readlines() # remaining lines
f.close()
f = file(path, "w")
f.writelines(str)
f.close()

print "Needs update? %s (should be True)" % orngServerFiles.needs_update(domain, filename)
print "Updating ..."
orngServerFiles.update(domain, filename, verbose=False)
print "Needs update? %s (should be False)" % orngServerFiles.needs_update(domain, filename)
Пример #3
0
import orngServerFiles

# remove a file from a local repository and download it from the server
filename = "urllib2_file.py"
print orngServerFiles.listfiles("demo")
orngServerFiles.remove("demo", filename)
orngServerFiles.download("demo", filename, verbose=False)

info = orngServerFiles.info("demo", filename)
print "%s: size=%s, datetime=%s" % (filename, info["size"], info["datetime"])
import orngServerFiles
import os
reload(orngServerFiles)

domain = "demo"
filename = "orngServerFiles.py"

print "Downloading domain: %s, file: %s" % (domain, filename)
orngServerFiles.download(domain, filename, verbose=False)
print "Needs update? %s (should be False)" % orngServerFiles.needs_update(
    domain, filename)

# change the access and modified time of the local file
# this is stored in the .info file (does not depend on the actual datetime
# values that we could access through os.stat(path) or set using us.utime)
path = orngServerFiles.localpath(domain, filename) + ".info"
f = file(path)
str = [f.readline()]  # first line
s = "1800" + f.readline()[4:]  # second line with date, change it
print "Changing date to", s.strip()
str += [s]
str += f.readlines()  # remaining lines
f.close()
f = file(path, "w")
f.writelines(str)
f.close()

print "Needs update? %s (should be True)" % orngServerFiles.needs_update(
    domain, filename)
print "Updating ..."
orngServerFiles.update(domain, filename, verbose=False)