Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print "then you can edit this file and add details of"
print "your freesites, and run it again."
print
print "Note - freesites are only updated if they have"
print "changed since the last update, because a hash"
print "of each site gets stored in the config"
sys.exit(0)
if __name__ == '__main__':
if '-h' in sys.argv:
help()
if '-v' in sys.argv:
verbosity = fcp.DETAIL
s = SiteMgr()
s.update()
s.shutdown()
def save(self):
"""
Saves the node state
"""
self.log(DETAIL, "save: saving site config to %s" % self.path)
try:
self.log(DEBUG, "save: waiting for lock")
self.fileLock.acquire()
self.log(DEBUG, "save: got lock")
confDir = os.path.split(self.path)[0]
tmpFile = os.path.join(self.basedir, ".tmp-%s" % self.name)
f = file(tmpFile, "w")
self.log(DETAIL, "save: writing to temp file %s" % tmpFile)
pp = pprint.PrettyPrinter(width=72, indent=2, stream=f)
js = json.JSONEncoder(indent=2)
import fcp
# ------------------------------------------
# state where our FCP port is
fcpHost = "127.0.0.1"
# ------------------------------------------
# create a node connection object
#
# we're setting a relatively high verbosity so you
# can see the traffic
node = fcp.FCPNode(host=fcpHost, verbosity=fcp.DETAIL)
# -----------------------------------------------
# now, perform a simple direct insert of a string
# val = raw_input("Please enter a string to insert: ")
# ksk = raw_input("Please enter a short KSK key name: ")
val = "testinsert"
ksk = "testinsertkey" + uuid.uuid4().hex
uri = "KSK@" + ksk
print "Inserting %s, containing '%s'" % (uri, val)
# do the put - note that 'data=' inserts a string directly
# note too that mimetype is optional, defaulting to text/plain
node.put("KSK@"+ksk, data=val, mimetype="text/plain")
rec['uri'] = ''
rec['id'] = ''
physFiles.append(rec)
physDict[rec['name']] = rec
# now, analyse both sets of records, and determine if update is needed
# firstly, purge deleted files
# also, pick up records without URIs, or which are already marked as changed
for name, rec in self.filesDict.items():
# generated files never trigger a reupload.
if name in self.generatedTextData:
continue
if name not in physDict:
# file has disappeared, remove it and flag an update
log(DETAIL, "scan: file %s has been removed" % name)
del self.filesDict[name]
self.files.remove(rec)
structureChanged = True
elif rec['state'] in ('changed', 'waiting'):
# already known to be changed
structureChanged = True
elif (not rec.get('uri', None) and
rec.get('target', 'separate') == 'separate'):
# file has no URI but was not part of a container
structureChanged = True
rec['state'] = 'changed'
# secondly, add new/changed files we just checked on disk
for name, rec in physDict.items():
if name not in self.filesDict:
# new file - add it and flag update