def post(self): script = self.request.get('script', '') if not script: self.abort(400, 'No script uploaded') bot_code.store_bot_config(script.encode('utf-8', 'replace')) self.get()
def test_store_bot_config(self): # When a new start bot script is uploaded, we should recalculate the # version hash since it will have changed. v1 = bot_code.get_bot_version('http://localhost') bot_code.store_bot_config('dummy_script') v2 = bot_code.get_bot_version('http://localhost') v3 = bot_code.get_bot_version('http://localhost:8080') self.assertNotEqual(v1, v2) self.assertNotEqual(v1, v3) self.assertNotEqual(v2, v3)
def post(self): script = self.request.get('script', '') if not script: self.abort(400, 'No script uploaded') # Make sure the script is valid utf-8. For some odd reason, the script # instead may or may not be an unicode instance. This depends if it is on # AppEngine production or not. if isinstance(script, str): script = script.decode('utf-8', 'replace') script = script.encode('utf-8') bot_code.store_bot_config(script) self.get()
def put_bot_config(self, request): """Stores a new version of bot_config.py.""" key = bot_code.store_bot_config(request.content.encode('utf-8')) obj = key.get() return swarming_rpcs.FileContent( who=obj.who.to_bytes() if obj.who else None, when=obj.created_ts, version=obj.version)