<s> """<STR_LIT>""" <EOL> import getpass <EOL> import os <EOL> import shutil <EOL> import sys <EOL> import tempfile <EOL> from google . appengine . tools import sdk_update_checker <EOL> from google . appengine . tools . devappserver2 import runtime_factories <EOL> def generate_gcd_app ( app_id ) : <EOL> """<STR_LIT>""" <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> user_format = '<STR_LIT>' <EOL> else : <EOL> try : <EOL> user_name = getpass . getuser ( ) <EOL> except Exception : <EOL> user_format = '<STR_LIT>' <EOL> else : <EOL> user_format = '<STR_LIT>' % user_name <EOL> tempdir = tempfile . gettempdir ( ) <EOL> version = sdk_update_checker . GetVersionObject ( ) <EOL> sdk_version = version [ '<STR_LIT>' ] if version else '<STR_LIT>' <EOL> gcd_path = os . path . join ( tempdir , <EOL> '<STR_LIT>' % ( sdk_version , <EOL> app_id , user_format ) ) <EOL> if not os . path . exists ( gcd_path ) : <EOL> os . mkdir ( gcd_path ) <EOL> webinf_path = os . path . join ( gcd_path , '<STR_LIT>' ) <EOL> os . mkdir ( webinf_path ) <EOL> filter_path = os . path . join ( webinf_path , '<STR_LIT>' ) <EOL> os . mkdir ( filter_path ) <EOL> if runtime_factories . java_runtime : <EOL> filter_jar = _get_filter_jar ( ) <EOL> shutil . copy ( filter_jar , filter_path ) <EOL> with open ( os . path . join ( gcd_path , '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT:w>' ) as f : <EOL> f . write ( """<STR_LIT>""" ) <EOL> gcd_app_xml = os . path . join ( gcd_path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> with open ( gcd_app_xml , '<STR_LIT:w>' ) as f : <EOL> f . write ( """<STR_LIT>""" % app_id ) <EOL> return gcd_app_xml <EOL> def _get_filter_jar ( ) : <EOL> """<STR_LIT>""" <EOL> java_dir = os . environ . get ( '<STR_LIT>' , None ) <EOL> if not java_dir : <EOL> tools_dir = os . path . abspath ( os . path . dirname ( os . path . dirname ( __file__ ) ) ) <EOL> java_dir = os . path . join ( tools_dir , '<STR_LIT>' ) <EOL> filter_dir = os . path . join ( java_dir , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> filter_jar = os . path . join ( filter_dir , '<STR_LIT>' ) <EOL> return filter_jar </s>
