def main(): """main function with high level control flow""" # If we were asked to retrieve the mainfest file, do so... if _commandlineoptions.retrievemanifestfrom: # We need to download this file... rawmanifestdata = lib.retrieve_rawmanifest( _commandlineoptions.retrievemanifestfrom) # ...make sure it is valid... manifestdict = lib.parse_manifest(rawmanifestdata) # ...and write it out if it's okay open(_commandlineoptions.manifestfilename, "wb").write(rawmanifestdata) else: # Simply read it in from disk rawmanifestdata = open(_commandlineoptions.manifestfilename, "rb").read() manifestdict = lib.parse_manifest(rawmanifestdata) # we will check that the files are in the release # find the list of files filelist = lib.get_filenames_in_release(manifestdict) if (manifestdict['blockcount'] < _commandlineoptions.numberofmirrors * 8) and _commandlineoptions.redundancy != None: print( "Block count too low to use chunks! Try reducing the block size or add more files to the database." ) sys.exit(1) if _commandlineoptions.printfiles: print("Manifest - Blocks:", manifestdict['blockcount'], "x", manifestdict['blocksize'], "Byte - Files:\n", filelist) if _commandlineoptions.timing: _timing_log.write(str(manifestdict['blocksize']) + "\n") _timing_log.write(str(manifestdict['blockcount']) + "\n") # ensure the requested files are in there... for filename in _commandlineoptions.filestoretrieve: if filename not in filelist: print("The file", filename, "is not listed in the manifest.") sys.exit(2) # don't run PIR if we're just printing the filenames in the manifest if len(_commandlineoptions.filestoretrieve) > 0: request_files_from_mirrors(_commandlineoptions.filestoretrieve, _commandlineoptions.redundancy, _commandlineoptions.rng, _commandlineoptions.parallel, manifestdict)
def main(): """main function with high level control flow""" # If we were asked to retrieve the mainfest file, do so... if _commandlineoptions.retrievemanifestfrom: # We need to download this file... rawmanifestdata = lib.retrieve_rawmanifest(_commandlineoptions.retrievemanifestfrom) # ...make sure it is valid... manifestdict = lib.parse_manifest(rawmanifestdata) # ...and write it out if it's okay open(_commandlineoptions.manifestfilename, "wb").write(rawmanifestdata) else: # Simply read it in from disk rawmanifestdata = open(_commandlineoptions.manifestfilename, "rb").read() manifestdict = lib.parse_manifest(rawmanifestdata) # we will check that the files are in the release # find the list of files filelist = lib.get_filenames_in_release(manifestdict) if (manifestdict['blockcount'] < _commandlineoptions.numberofmirrors * 8) and _commandlineoptions.redundancy != None: print("Block count too low to use chunks! Try reducing the block size or add more files to the database.") sys.exit(1) if _commandlineoptions.printfiles: print("Manifest - Blocks:", manifestdict['blockcount'], "x", manifestdict['blocksize'], "Byte - Files:\n", filelist) if _commandlineoptions.timing: _timing_log.write(str(manifestdict['blocksize']) + "\n") _timing_log.write(str(manifestdict['blockcount']) + "\n") # ensure the requested files are in there... for filename in _commandlineoptions.filestoretrieve: if filename not in filelist: print("The file", filename, "is not listed in the manifest.") sys.exit(2) # don't run PIR if we're just printing the filenames in the manifest if len(_commandlineoptions.filestoretrieve) > 0: request_files_from_mirrors(_commandlineoptions.filestoretrieve, _commandlineoptions.redundancy, _commandlineoptions.rng, _commandlineoptions.parallel, manifestdict)
def retrieve_manifest_dict(): global _commandlineoptions # If we were asked to retrieve the mainfest file, do so... if _commandlineoptions.retrievemanifestfrom: # We need to download this file... rawmanifestdata = lib.retrieve_rawmanifest(_commandlineoptions.retrievemanifestfrom) # ...make sure it is valid... manifestdict = lib.parse_manifest(rawmanifestdata) # ...and write it out if it's okay open(_commandlineoptions.manifestfilename, "wb").write(rawmanifestdata) else: # Read manifest from disk rawmanifestdata = open(_commandlineoptions.manifestfilename, "rb").read() manifestdict = lib.parse_manifest(rawmanifestdata) return manifestdict
def retrieve_manifest_dict(): global _commandlineoptions # If we were asked to retrieve the mainfest file, do so... if _commandlineoptions.retrievemanifestfrom: # We need to download this file... rawmanifestdata = lib.retrieve_rawmanifest( _commandlineoptions.retrievemanifestfrom) # ...make sure it is valid... manifestdict = lib.parse_manifest(rawmanifestdata) # ...and write it out if it's okay open(_commandlineoptions.manifestfilename, "w").write(rawmanifestdata) else: # Simply read it in from disk rawmanifestdata = open(_commandlineoptions.manifestfilename).read() manifestdict = lib.parse_manifest(rawmanifestdata) return manifestdict
def main(): global _global_rawmanifestdata global _global_rawmirrorlist # read in the manifest file rawmanifestdata = open(_commandlineoptions.manifestfilename, 'rb').read() # an ugly hack, but Python's request handlers don't have an easy way to thread to handle it pass arguments _global_rawmanifestdata = rawmanifestdata _global_rawmirrorlist = msgpack.packb([]) # I do this just for the sanity / corruption check manifestdict = lib.parse_manifest(rawmanifestdata) # vendor ip if _commandlineoptions.ip == None: vendorip = manifestdict['vendorhostname'] else: vendorip = _commandlineoptions.ip # vendor port if _commandlineoptions.port == None: vendorport = manifestdict['vendorport'] else: vendorport = _commandlineoptions.port # We should detach here. I don't do it earlier so that error # messages are written to the terminal... I don't do it later so that any # threads don't exist already. If I do put it much later, the code hangs... if _commandlineoptions.daemonize: daemon.daemonize() # we're now ready to handle clients! _log('ready to start servers!') # first, let's fire up the RAID-PIR server start_vendor_service(manifestdict, vendorip, vendorport)