<s> __author__ = '<STR_LIT>' <EOL> import inspect <EOL> import os <EOL> import sys <EOL> __is_py2exe__ = hasattr ( sys , '<STR_LIT>' ) <EOL> def scalyr_init ( ) : <EOL> """<STR_LIT>""" <EOL> if not __is_py2exe__ : <EOL> __add_scalyr_package_to_path ( ) <EOL> def __determine_package_root ( ) : <EOL> """<STR_LIT>""" <EOL> if not __is_py2exe__ : <EOL> base = os . getcwd ( ) <EOL> file_path = inspect . stack ( ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> if not os . path . isabs ( file_path ) : <EOL> file_path = os . path . join ( base , file_path ) <EOL> file_path = os . path . dirname ( os . path . realpath ( file_path ) ) <EOL> else : <EOL> return os . path . dirname ( unicode ( sys . executable , sys . getfilesystemencoding ( ) ) ) <EOL> return file_path <EOL> __package_root__ = __determine_package_root ( ) <EOL> def get_package_root ( ) : <EOL> """<STR_LIT>""" <EOL> return __package_root__ <EOL> def get_install_root ( ) : <EOL> """<STR_LIT>""" <EOL> parent_of_package_install = os . path . dirname ( get_package_root ( ) ) <EOL> if __is_py2exe__ : <EOL> return parent_of_package_install <EOL> elif os . path . basename ( parent_of_package_install ) != '<STR_LIT>' : <EOL> return parent_of_package_install <EOL> else : <EOL> return os . path . dirname ( parent_of_package_install ) <EOL> def __add_scalyr_package_to_path ( ) : <EOL> """<STR_LIT>""" <EOL> sys . path . append ( os . path . dirname ( get_package_root ( ) ) ) <EOL> sys . path . append ( os . path . join ( get_package_root ( ) , '<STR_LIT>' ) ) <EOL> def __determine_version ( ) : <EOL> """<STR_LIT>""" <EOL> in_install = os . path . join ( get_install_root ( ) , '<STR_LIT>' ) <EOL> in_package = os . path . join ( get_package_root ( ) , '<STR_LIT>' ) <EOL> if os . path . isfile ( in_package ) : <EOL> version_path = in_package <EOL> elif os . path . isfile ( in_install ) : <EOL> version_path = in_install <EOL> else : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> version_fp = open ( version_path , '<STR_LIT:r>' ) <EOL> try : <EOL> return version_fp . readline ( ) . strip ( ) <EOL> finally : <EOL> version_fp . close ( ) <EOL> SCALYR_VERSION = __determine_version ( ) <EOL> PACKAGE_INSTALL = <NUM_LIT:1> <EOL> TARBALL_INSTALL = <NUM_LIT:2> <EOL> DEV_INSTALL = <NUM_LIT:3> <EOL> MSI_INSTALL = <NUM_LIT:4> <EOL> def __determine_install_type ( ) : <EOL> """<STR_LIT>""" <EOL> install_root = get_install_root ( ) <EOL> if os . path . exists ( os . path . join ( install_root , '<STR_LIT>' ) ) : <EOL> install_type = TARBALL_INSTALL <EOL> elif os . path . exists ( os . path . join ( install_root , '<STR_LIT>' ) ) : <EOL> install_type = DEV_INSTALL <EOL> elif hasattr ( sys , '<STR_LIT>' ) : <EOL> install_type = MSI_INSTALL <EOL> else : <EOL> install_type = PACKAGE_INSTALL <EOL> return install_type <EOL> INSTALL_TYPE = __determine_install_type ( ) </s>
