<s> '''<STR_LIT>''' <EOL> import os , time <EOL> from interfaces . adb_interface import AdbInterface <EOL> from bboxcoverage import BBoxCoverage <EOL> from running_strategies import IntentInvocationStrategy <EOL> import smtplib <EOL> import email . utils <EOL> from email . mime . text import MIMEText <EOL> APK_DIR_SOURCES = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> SMTP_SERVER = '<STR_LIT>' <EOL> SMTP_PORT = <NUM_LIT> <EOL> SENDER = "<STR_LIT>" <EOL> PASSWORD = "<STR_LIT>" <EOL> TO_EMAIL = "<STR_LIT>" <EOL> def sendMessage ( subj , email_message ) : <EOL> msg = MIMEText ( email_message ) <EOL> msg [ '<STR_LIT>' ] = email . utils . formataddr ( ( '<STR_LIT>' , TO_EMAIL ) ) <EOL> msg [ '<STR_LIT>' ] = email . utils . formataddr ( ( '<STR_LIT>' , SENDER ) ) <EOL> msg [ '<STR_LIT>' ] = subj <EOL> server = smtplib . SMTP ( SMTP_SERVER , SMTP_PORT ) <EOL> try : <EOL> server . set_debuglevel ( True ) <EOL> server . ehlo ( ) <EOL> if server . has_extn ( '<STR_LIT>' ) : <EOL> server . starttls ( ) <EOL> server . ehlo ( ) <EOL> server . login ( SENDER , PASSWORD ) <EOL> server . sendmail ( SENDER , [ TO_EMAIL ] , msg . as_string ( ) ) <EOL> finally : <EOL> server . quit ( ) <EOL> def getExecutionDevice ( ) : <EOL> '''<STR_LIT>''' <EOL> dev_list = AdbInterface . getDeviceSerialsList ( ) <EOL> devNum = len ( dev_list ) <EOL> if devNum <= <NUM_LIT:0> : <EOL> print "<STR_LIT>" <EOL> return <EOL> if devNum == <NUM_LIT:1> : <EOL> return dev_list [ <NUM_LIT:0> ] <EOL> choice = None <EOL> if devNum > <NUM_LIT:1> : <EOL> print "<STR_LIT>" <EOL> for i in xrange ( <NUM_LIT:0> , devNum ) : <EOL> print "<STR_LIT>" % ( ( i + <NUM_LIT:1> ) , dev_list [ i ] ) <EOL> while not choice : <EOL> try : <EOL> choice = int ( raw_input ( ) ) <EOL> if choice not in range ( <NUM_LIT:1> , devNum + <NUM_LIT:1> ) : <EOL> choice = None <EOL> print '<STR_LIT>' <EOL> except ValueError : <EOL> print '<STR_LIT>' <EOL> return dev_list [ choice - <NUM_LIT:1> ] <EOL> def getSubdirs ( rootDir ) : <EOL> return [ os . path . join ( rootDir , name ) for name in os . listdir ( rootDir ) <EOL> if os . path . isdir ( os . path . join ( rootDir , name ) ) ] <EOL> def getInstrApkInFolder ( folder ) : <EOL> for f in os . listdir ( folder ) : <EOL> if f . endswith ( "<STR_LIT>" ) : <EOL> filepath = os . path . join ( folder , f ) <EOL> return filepath <EOL> return None <EOL> def runMainIntentsStrategy ( adb , androidManifest , delay = <NUM_LIT:10> ) : <EOL> automaticTriggeringStrategy = IntentInvocationStrategy ( adbDevice = adb , pathToAndroidManifest = androidManifest ) <EOL> automaticTriggeringStrategy . run ( delay = delay ) <EOL> adb = AdbInterface ( ) <EOL> device = getExecutionDevice ( ) <EOL> if not device : <EOL> exit ( <NUM_LIT:1> ) <EOL> adb . setTargetSerial ( device ) <EOL> bboxcoverage = BBoxCoverage ( ) <EOL> for apk_dir_source in APK_DIR_SOURCES : <EOL> print "<STR_LIT>" % apk_dir_source <EOL> result_directories = getSubdirs ( apk_dir_source ) <EOL> for directory in result_directories : <EOL> apk_file = getInstrApkInFolder ( directory ) <EOL> if apk_file : <EOL> print "<STR_LIT>" % apk_file <EOL> try : <EOL> bboxcoverage . initAlreadyInstrApkEnv ( pathToInstrApk = apk_file , resultsDir = directory ) <EOL> except : <EOL> print "<STR_LIT>" <EOL> continue <EOL> try : <EOL> bboxcoverage . installApkOnDevice ( ) <EOL> except : <EOL> print "<STR_LIT>" <EOL> bboxcoverage . uninstallPackage ( ) <EOL> try : <EOL> bboxcoverage . installApkOnDevice ( ) <EOL> except : <EOL> continue <EOL> package_name = bboxcoverage . getPackageName ( ) <EOL> params = { } <EOL> params [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> params [ "<STR_LIT>" ] = package_name <EOL> params [ "<STR_LIT>" ] = bboxcoverage . androidManifest . getMainActivity ( ) <EOL> try : <EOL> bboxcoverage . startTesting ( ) <EOL> except : <EOL> print "<STR_LIT>" <EOL> bboxcoverage . uninstallPackage ( ) <EOL> continue <EOL> try : <EOL> runMainIntentsStrategy ( adb = adb , androidManifest = bboxcoverage . androidManifestFile , delay = <NUM_LIT:10> ) <EOL> except : <EOL> print "<STR_LIT>" <EOL> bboxcoverage . uninstallPackage ( ) <EOL> continue <EOL> try : <EOL> bboxcoverage . stopTesting ( "<STR_LIT>" , paramsToWrite = params ) <EOL> except : <EOL> print "<STR_LIT>" <EOL> bboxcoverage . uninstallPackage ( ) <EOL> continue <EOL> time . sleep ( <NUM_LIT:3> ) <EOL> bboxcoverage . uninstallPackage ( ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> sendMessage ( "<STR_LIT>" , "<STR_LIT>" % apk_dir_source ) </s>
