<s> import subprocess <EOL> import platform <EOL> s1 = """<STR_LIT>""" <EOL> s2 = """<STR_LIT>""" <EOL> s3 = """<STR_LIT>""" <EOL> s4 = """<STR_LIT>""" <EOL> def applescript ( input ) : <EOL> if platform . system ( ) != "<STR_LIT>" : <EOL> return <EOL> command = "<STR_LIT>" % input <EOL> try : <EOL> return subprocess . check_call ( command , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> shell = True ) <EOL> except Exception as e : <EOL> pass <EOL> def _insertJavascript ( urlMatch , js ) : <EOL> apps = appsRunning ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> urlMatch = "<STR_LIT>" + "<STR_LIT>" . join ( urlMatch ) + "<STR_LIT>" <EOL> if apps [ '<STR_LIT>' ] : <EOL> applescript ( s1 % ( urlMatch , js ) ) <EOL> if apps [ '<STR_LIT>' ] : <EOL> applescript ( s2 % ( urlMatch , js ) ) <EOL> def browserReload ( url ) : <EOL> _insertJavascript ( url , s3 ) <EOL> def browserReloadCSS ( url ) : <EOL> _insertJavascript ( url , s4 ) <EOL> def appsRunning ( l ) : <EOL> psdata = subprocess . check_output ( [ '<STR_LIT>' ] , shell = True ) <EOL> retval = { } <EOL> for app in l : retval [ app ] = app in psdata <EOL> return retval </s>
