def setup_u_server(options): """ Actually starts a upaxBlockingServer running, then invokes wrapped code, then closes server in a finally block. """ no_changes = options.no_changes u_path = options.u_path using_sha = not options.using_sha3 verbose = options.verbose check_using_sha(using_sha) u_server = upax.BlockingServer(u_path, using_sha) options.u_server = u_server u_log = u_server.log options.u_log = u_log if verbose: print("there were %7u files in %s at the beginning of the run" % ( len(u_log), u_path)) # # --------------------------------------------------------------- # # XXX This code expects a collection of files in inDir; it posts # # each to u_path -- and so is not relevant for our purposes. THIS # # IS HERE AS AN EXAMPLE OF HOW TO WRITE DATA TO uServer # # --------------------------------------------------------------- # src = args.pgmNameAndVersion # what goes in the logEntry src field # files = os.listdir(args.inDir) # for file in files: # pathToFile = os.path.join(args.inDir, file) # if using_sha == Q.USING_SHA1: # hash = u.fileSHA1(pathToFile) # elif using_sha == Q.USING_SHA2: # hash = u.fileSHA2(pathToFile) # elif using_sha == Q.USING_SHA3: # hash = u.fileSHA3(pathToFile) # if no_changes: # if verbose: print 'would add %s %s' % (hash, pathToFile) # else: # uServer.put (pathToFile, hash, src) # if verbose: # print "there are %7u files in %s at the end of the run" % ( # len(log), u_path) # FOO try: setup_the_app(options) finally: u_server.close()
def do_test_with_openssl_key(self, using_sha): check_using_sha(using_sha) # import an openSSL-generated 2048-bit key (this becomes a # string constant in this program) with open('openssl2k.pem', 'r') as file: pem_key = file.read() key = rsa.importKey(pem_key) assert key is not None self.assertTrue(key.has_private()) nnn = Node(using_sha, key) self.check_node(nnn, using_sha) # The _RSAobj.publickey() returns a raw key. self.assertEqual(key.publickey().exportKey(), nnn.pub_key.exportKey())