<s> """<STR_LIT>""" <EOL> import os <EOL> import subprocess <EOL> tableau_dir = '<STR_LIT>' <EOL> cust_binary = "<STR_LIT>" % tableau_dir <EOL> tableau_url = '<STR_LIT>' '<STR_LIT>' <EOL> tableau_key = '<STR_LIT>' <EOL> def activate_license ( tableau_key ) : <EOL> """<STR_LIT>""" <EOL> apply_new_license_cmd = "<STR_LIT>" "<STR_LIT>" % ( <EOL> cust_binary , tableau_url , tableau_key <EOL> ) <EOL> print "<STR_LIT>" <EOL> subprocess . call ( apply_new_license_cmd , shell = True ) <EOL> def get_installed_licenses ( ) : <EOL> """<STR_LIT>""" <EOL> installed_keys = subprocess . check_output ( <EOL> "<STR_LIT>" % cust_binary , shell = True <EOL> ) <EOL> for line in installed_keys . split ( '<STR_LIT:\n>' ) : <EOL> if '<STR_LIT>' in line : <EOL> return line . split ( ) [ <NUM_LIT:2> ] <EOL> return None <EOL> def install_flex_agent ( ) : <EOL> """<STR_LIT>""" <EOL> if not os . path . exists ( '<STR_LIT>' ) : <EOL> try : <EOL> print '<STR_LIT>' <EOL> subprocess . call ( <EOL> "<STR_LIT>" <EOL> '<STR_LIT>' <EOL> % tableau_dir , shell = True <EOL> ) <EOL> except Exception as e : <EOL> print "<STR_LIT>" % e <EOL> raise <EOL> def retire_license ( active_license ) : <EOL> """<STR_LIT>""" <EOL> retire_cmd = "<STR_LIT>" "<STR_LIT>" % ( cust_binary , active_license , tableau_url ) <EOL> if '<STR_LIT>' in active_license : <EOL> retire_cmd = "<STR_LIT>" % ( cust_binary , active_license ) <EOL> print "<STR_LIT>" % active_license <EOL> subprocess . call ( retire_cmd , shell = True ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> install_flex_agent ( ) <EOL> licenses = get_installed_licenses ( ) <EOL> if licenses : <EOL> retire_license ( licenses ) <EOL> activate_license ( tableau_key ) </s>
