#NEWLINE# def screenshot( self , filename = None , scale = 1.0 , quality = 100 ) : #NEWLINE# #INDENT# if ( self . sdk_version ( ) >= 18 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# req = urllib2 . Request ( ( '%s?scale=%f&quality=%f' % ( req . screenshot_uri , scale , quality ) ) ) #NEWLINE# result = urllib2 . urlopen ( req , timeout = 30 ) #NEWLINE# if filename : #NEWLINE# #INDENT# with open ( filename , 'wb' ) as f : #NEWLINE# #INDENT# f . write ( result . read ( ) ) #NEWLINE# return filename #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return result . read ( ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# return None