# Hash - use Django chunks, so can handle big files decently hasher = hashlib.sha256() for chunk in asset_file.chunks(): hasher.update(chunk) asset.hash_value = 'SHA256|' + hasher.hexdigest() # Save asset.save() return True ## Returns the 'emptymap asset', a basis for new maps @staticmethod def get_emptymap(): owner = UserAccount.get_initial_asset_creator() ret = AssetInfo.objects.filter(location='base/emptymap.tar.gz') ret = filter(lambda r: r.owners.all()[0].uuid == owner.uuid, ret)[0] return ret store_asset.connect(AssetInfo.calculate_metadata, weak=False) classes = [UserAccount, ServerInstance, Activity, AssetInfo] for _class in classes: intensity_uuid_model(_class) # Set home dir, to our parent (ignored if already set) import intensity.conf as intensity_conf intensity_conf.set_home_dir()
# Dev: 100-165 reqs/sec # CherryPy: 170-200 reqs/sec # # $ ab -n 1000 -c 10 http://localhost:8000/static/robots.txt (static content) # Dev: 333 reqs/sec # CherryPy: 333 reqs/sec import os, sys import cherrypy import intensity.conf as intensity_conf if len(sys.argv) >= 2: intensity_conf.set_home_dir(sys.argv[1]) else: intensity_conf.set_home_dir() # Use environment # Auth servers serve using HTTPS, with a certificate in a subdirectory # called ssl/, and use a different settings.py file # (settings_production_auth.py). auth = bool(int(intensity_conf.get('Network', 'auth'))) # Start and stop the CherryPy engine #######cherrypy.config.update({'environment': 'embedded'}) if cherrypy.__version__ < '3.1': print "Starting engine..." cherrypy.engine.start(blocking=False)
for chunk in asset_file.chunks(): hasher.update(chunk) asset.hash_value = 'SHA256|' + hasher.hexdigest() # Save asset.save() return True ## Returns the 'emptymap asset', a basis for new maps @staticmethod def get_emptymap(): owner = UserAccount.get_initial_asset_creator() ret = AssetInfo.objects.filter(location='base/emptymap.tar.gz') ret = filter(lambda r: r.owners.all()[0].uuid == owner.uuid, ret)[0] return ret store_asset.connect(AssetInfo.calculate_metadata, weak=False) classes = [UserAccount, ServerInstance, Activity, AssetInfo] for _class in classes: intensity_uuid_model(_class) # Set home dir, to our parent (ignored if already set) import intensity.conf as intensity_conf intensity_conf.set_home_dir()
# $ ab -n 1000 -c 10 http://localhost:8000/faq/ (dynamic content) # Dev: 100-165 reqs/sec # CherryPy: 170-200 reqs/sec # # $ ab -n 1000 -c 10 http://localhost:8000/static/robots.txt (static content) # Dev: 333 reqs/sec # CherryPy: 333 reqs/sec import os, sys import cherrypy import intensity.conf as intensity_conf if len(sys.argv) >= 2: intensity_conf.set_home_dir(sys.argv[1]) else: intensity_conf.set_home_dir() # Use environment # Auth servers serve using HTTPS, with a certificate in a subdirectory # called ssl/, and use a different settings.py file # (settings_production_auth.py). auth = bool(int(intensity_conf.get('Network', 'auth'))) # Start and stop the CherryPy engine #######cherrypy.config.update({'environment': 'embedded'}) if cherrypy.__version__ < '3.1': print "Starting engine..." cherrypy.engine.start(blocking=False)