def finish_visualization_process(self):

        while True:
            line = self.proc.stdout.readline().rstrip()

            if line != '****FAB SUBPROCESS COMPLETE****':
                logging.debug(line)
            else:
                break

        server_instance = aws.get_aws_instance(self.server_name)
        aws.set_processing_server_state(server_instance, 'stopped')
Esempio n. 2
0
    def create_tiles(self):

        server_instance = aws.get_aws_instance(self.server_name)
        aws.set_server_instance_type(server_instance, 'm4.16xlarge')

        # Required so that the machine now knows it's an m4.16xlarge
        server_instance.update()
        server_ip = aws.set_processing_server_state(server_instance, 'running')

        abspath = os.path.abspath(__file__)
        gfw_sync_dir = os.path.dirname(os.path.dirname(abspath))

        utilities_dir = os.path.join(gfw_sync_dir, 'utilities')
        tokens_dir = os.path.join(gfw_sync_dir, 'tokens')

        pem_file = os.path.join(tokens_dir, 'chofmann-wri.pem')
        host_name = 'ubuntu@{0}'.format(server_ip)

        region_str, year_str = self.lookup_region_year_from_source()

        fab_path = r"C:\PYTHON27\ArcGISx6410.6\Scripts\fab.exe"
        cmd = [fab_path, 'kickoff:{0},{1},{2},{3}'.format(self.name, region_str, year_str, self.gfw_env)]
        cmd += ['-i', pem_file, '-H', host_name]
        logging.debug('Running fabric: {0}'.format(cmd))

        has_error = False

        try:
            subprocess.check_call(cmd, cwd=utilities_dir)
        except subprocess.CalledProcessError:
            has_error = True

        if has_error:

            aws.set_processing_server_state(server_instance, 'stopped')
            logging.debug('Unsuccessful tile creation. Exiting.')

            logging.debug('Killing related EMR clusters if there are any')
            aws.kill_emr_cluster(self.name)

            sys.exit(1)

        else:
            aws.set_processing_server_state(server_instance, 'stopped')
    def start_visualization_process(self):

        server_instance = aws.get_aws_instance(self.server_name)
        aws.set_server_instance_type(server_instance, 'm4.10xlarge')

        # Required so that the machine now knows it's an m4.10xlarge
        server_instance.update()
        server_ip = aws.set_processing_server_state(server_instance, 'running')

        abspath = os.path.abspath(__file__)
        gfw_sync_dir = os.path.dirname(os.path.dirname(abspath))

        utilities_dir = os.path.join(gfw_sync_dir, 'utilities')
        tokens_dir = os.path.join(gfw_sync_dir, 'tokens')

        pem_file = os.path.join(tokens_dir, 'chofmann-wri.pem')
        host_name = 'ubuntu@{0}'.format(server_ip)

        regions_to_update = ','.join(self.lookup_regions_from_source())

        cmd = ['fab', 'kickoff:{0},{1}'.format(self.name, regions_to_update), '-i', pem_file, '-H', host_name]
        logging.debug('Running fabric: {0}'.format(cmd))

        self.proc = subprocess.Popen(cmd, cwd=utilities_dir, stdout=subprocess.PIPE)