def download_sensor(self, job): """Download the sensor for the given job, if a sensor is available. Return the path to the sensor file. If no sensor is available return None. Keyword arguments: job -- the job for which this sensor is downloaded """ if job.sensor: request = Request(job.sensor.file_url) download_dir = self.download_dir + "sensor/" \ + str(job.sensor.id) + "/" # try to download until successful success = False delay_iterator = get_polling_delay_it() while not success: try: request.get_file(download_dir, job.sensor.original_filename) success = True except HTTPError, e: log.error("Error in download_sample: " + str(e)) time.sleep(delay_iterator.next()) return download_dir + job.sensor.original_filename
def download_vm(self, job): """Download the vm for the given job. Keyword arguments: job -- the vm for this job is downloaded """ request = Request(job.virtual_machine.file_url) download_dir = self.download_dir + "vm/" \ + str(job.virtual_machine.id) + "/" request.get_file(download_dir, job.virtual_machine.original_filename) return download_dir + job.virtual_machine.original_filename
def download_sample(self, job): """Download the sample for the given job. Keyword arguments: job -- the job for which this sample is downloaded """ request = Request(job.sample.file_url) download_dir = self.download_dir + "sample/" \ + str(job.sample.id) + "/" # for now we try to download until we succeed, death or glory! success = False delay_iterator = get_polling_delay_it() while not success: try: request.get_file(download_dir, job.sample.original_filename) success = True except HTTPError, e: log.error("Error in download_sample: " + str(e)) time.sleep(delay_iterator.next())