<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import os <EOL> import sys <EOL> import subprocess <EOL> import gzip <EOL> import shutil <EOL> import argparse <EOL> sys . dont_write_bytecode = True <EOL> DEVNULL = open ( os . path . devnull , "<STR_LIT:w>" ) <EOL> SETUP_DIR = os . path . dirname ( os . path . realpath ( __file__ ) ) <EOL> CURRENT_STEP = <NUM_LIT:0> <EOL> os . chdir ( SETUP_DIR ) <EOL> sys . path . insert ( <NUM_LIT:0> , "<STR_LIT:.>" ) <EOL> from rplibs . six . moves import input <EOL> if sys . version_info . major == <NUM_LIT:2> : <EOL> from rplibs . colorama import init as init_colorama <EOL> from rplibs . colorama import Fore , Style <EOL> init_colorama ( ) <EOL> else : <EOL> class Dummy ( object ) : <EOL> def __getattr__ ( self , key ) : <EOL> return "<STR_LIT>" <EOL> Fore = Dummy ( ) <EOL> Style = Dummy ( ) <EOL> def parse_cmd_args ( ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , help = "<STR_LIT>" , action = "<STR_LIT:store_true>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , help = "<STR_LIT>" , action = "<STR_LIT:store_true>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , help = "<STR_LIT>" , action = "<STR_LIT:store_true>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , help = "<STR_LIT>" , action = "<STR_LIT:store_true>" ) <EOL> return parser . parse_args ( ) <EOL> CMD_ARGS = parse_cmd_args ( ) <EOL> def color ( string , col ) : <EOL> """<STR_LIT>""" <EOL> return col + string + Style . RESET_ALL <EOL> def error ( msg ) : <EOL> """<STR_LIT>""" <EOL> print ( "<STR_LIT:\n>" + color ( "<STR_LIT>" , Fore . RED + Style . BRIGHT ) , msg ) <EOL> print ( color ( "<STR_LIT>" , <EOL> Fore . RED + Style . BRIGHT ) ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def print_step ( title ) : <EOL> """<STR_LIT>""" <EOL> global CURRENT_STEP <EOL> CURRENT_STEP += <NUM_LIT:1> <EOL> print ( "<STR_LIT>" , str ( CURRENT_STEP ) . zfill ( <NUM_LIT:2> ) , "<STR_LIT>" , color ( title , Fore . CYAN + Style . BRIGHT ) ) <EOL> def exec_python_file ( pth , args = None ) : <EOL> """<STR_LIT>""" <EOL> basedir = os . path . dirname ( os . path . abspath ( os . path . join ( SETUP_DIR , pth ) ) ) + "<STR_LIT:/>" <EOL> print ( "<STR_LIT>" , Fore . YELLOW + Style . BRIGHT + pth + Style . RESET_ALL ) <EOL> pth = os . path . basename ( pth ) <EOL> os . chdir ( basedir ) <EOL> cmd = [ sys . executable , "<STR_LIT>" , pth ] + ( args or [ ] ) <EOL> if CMD_ARGS . verbose : <EOL> print ( "<STR_LIT>" , '<STR_LIT:U+0020>' . join ( cmd ) ) <EOL> print ( "<STR_LIT>" , basedir ) <EOL> try : <EOL> output = subprocess . check_output ( cmd , stderr = sys . stderr ) <EOL> except subprocess . CalledProcessError as msg : <EOL> print ( color ( "<STR_LIT>" + pth + "<STR_LIT:'>" , Fore . YELLOW + Style . BRIGHT ) ) <EOL> print ( "<STR_LIT>" , msg , "<STR_LIT:\n>" , msg . output . decode ( "<STR_LIT:utf-8>" , errors = "<STR_LIT:ignore>" ) ) <EOL> error ( "<STR_LIT>" ) <EOL> except IOError as msg : <EOL> print ( "<STR_LIT>" , msg ) <EOL> error ( "<STR_LIT>" ) <EOL> if CMD_ARGS . verbose : <EOL> print ( output . decode ( "<STR_LIT:utf-8>" , errors = "<STR_LIT:ignore>" ) ) <EOL> os . chdir ( SETUP_DIR ) <EOL> def extract_gz_files ( pth ) : <EOL> """<STR_LIT>""" <EOL> files = os . listdir ( pth ) <EOL> for fname in files : <EOL> fullpath = os . path . join ( pth , fname ) <EOL> if os . path . isfile ( fullpath ) and fname . endswith ( "<STR_LIT>" ) : <EOL> print ( "<STR_LIT>" , fname ) <EOL> try : <EOL> with open ( fullpath [ : - <NUM_LIT:3> ] , '<STR_LIT:wb>' ) as dest , gzip . open ( fullpath , '<STR_LIT:rb>' ) as src : <EOL> shutil . copyfileobj ( src , dest ) <EOL> except IOError as msg : <EOL> error ( "<STR_LIT>" + fname + "<STR_LIT>" + str ( msg ) ) <EOL> elif os . path . isdir ( fullpath ) : <EOL> extract_gz_files ( fullpath ) <EOL> def check_file_exists ( fpath ) : <EOL> """<STR_LIT>""" <EOL> return os . path . isfile ( os . path . join ( SETUP_DIR , fpath ) ) <EOL> def ask_download_samples ( ) : <EOL> """<STR_LIT>""" <EOL> query = "<STR_LIT>" <EOL> if get_user_choice ( query ) : <EOL> print_step ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> exec_python_file ( "<STR_LIT>" ) <EOL> def get_user_choice ( query ) : <EOL> """<STR_LIT>""" <EOL> print ( "<STR_LIT:\n>" ) <EOL> query = color ( query , Fore . GREEN + Style . BRIGHT ) + "<STR_LIT:U+0020>" <EOL> while True : <EOL> user_choice = input ( query ) . strip ( ) . lower ( ) <EOL> if user_choice in [ "<STR_LIT:y>" , "<STR_LIT:yes>" , "<STR_LIT:1>" ] : <EOL> return True <EOL> if user_choice in [ "<STR_LIT:n>" , "<STR_LIT>" , "<STR_LIT:0>" ] : <EOL> return False <EOL> print ( color ( "<STR_LIT>" + user_choice + "<STR_LIT:'>" , Fore . RED + Style . BRIGHT ) ) <EOL> def write_flag ( flag_location , flag_value ) : <EOL> """<STR_LIT>""" <EOL> flag_location = os . path . join ( SETUP_DIR , flag_location ) <EOL> try : <EOL> with open ( flag_location , "<STR_LIT:w>" ) as handle : <EOL> handle . write ( "<STR_LIT:1>" if flag_value else "<STR_LIT:0>" ) <EOL> except IOError as msg : <EOL> error ( "<STR_LIT>" + flag_location + "<STR_LIT>" + str ( msg ) ) <EOL> def check_cmake ( ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> subprocess . call ( [ "<STR_LIT>" , "<STR_LIT>" ] , stdout = subprocess . PIPE ) <EOL> except Exception as msg : <EOL> print ( "<STR_LIT:\n>" ) <EOL> print ( color ( "<STR_LIT>" , Fore . RED + Style . BRIGHT ) ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( msg ) <EOL> error ( "<STR_LIT>" ) <EOL> def check_panda_version ( ) : <EOL> """<STR_LIT>""" <EOL> from panda3d . core import PointLight <EOL> if not hasattr ( PointLight ( "<STR_LIT>" ) , "<STR_LIT>" ) : <EOL> print ( "<STR_LIT:\n>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" , color ( "<STR_LIT>" , Fore . MAGENTA + Style . BRIGHT ) , <EOL> "<STR_LIT>" ) <EOL> error ( "<STR_LIT>" ) <EOL> def setup ( ) : <EOL> """<STR_LIT>""" <EOL> print ( "<STR_LIT:->" * <NUM_LIT> ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT:->" * <NUM_LIT> ) <EOL> print_step ( "<STR_LIT>" ) <EOL> try : <EOL> from panda3d . core import NodePath <EOL> except ImportError : <EOL> print ( "<STR_LIT:\n>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> error ( "<STR_LIT>" ) <EOL> check_panda_version ( ) <EOL> if not CMD_ARGS . skip_native : <EOL> query = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if get_user_choice ( query ) : <EOL> check_cmake ( ) <EOL> write_flag ( "<STR_LIT>" , True ) <EOL> if not CMD_ARGS . skip_update : <EOL> print_step ( "<STR_LIT>" ) <EOL> exec_python_file ( "<STR_LIT>" ) <EOL> print_step ( "<STR_LIT>" ) <EOL> exec_python_file ( "<STR_LIT>" , [ "<STR_LIT>" ] if CMD_ARGS . clean else [ ] ) <EOL> else : <EOL> write_flag ( "<STR_LIT>" , False ) <EOL> print_step ( "<STR_LIT>" ) <EOL> extract_gz_files ( os . path . join ( SETUP_DIR , "<STR_LIT>" ) ) <EOL> print_step ( "<STR_LIT>" ) <EOL> exec_python_file ( "<STR_LIT>" ) <EOL> print_step ( "<STR_LIT>" ) <EOL> exec_python_file ( "<STR_LIT>" ) <EOL> print_step ( "<STR_LIT>" ) <EOL> exec_python_file ( "<STR_LIT>" ) <EOL> print_step ( "<STR_LIT>" ) <EOL> exec_python_file ( "<STR_LIT>" ) <EOL> print_step ( "<STR_LIT>" ) <EOL> exec_python_file ( "<STR_LIT>" ) <EOL> write_flag ( "<STR_LIT>" , True ) <EOL> print ( color ( "<STR_LIT>" , Fore . GREEN + Style . BRIGHT ) ) <EOL> ask_download_samples ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> setup ( ) </s>
