How to use _export method in Airtest

Best Python code snippet using Airtest

ClientGUISerialisable.py

Source:ClientGUISerialisable.py Github

copy

Full Screen

1import os2from qtpy import QtWidgets as QW3from hydrus.core import HydrusData4from hydrus.core import HydrusGlobals as HG5from hydrus.core import HydrusPaths6from hydrus.core import HydrusSerialisable7from hydrus.client import ClientSerialisable8from hydrus.client.gui import ClientGUIFunctions9from hydrus.client.gui import ClientGUIScrolledPanels10from hydrus.client.gui import QtPorting as QP11from hydrus.client.gui.widgets import ClientGUICommon12class PNGExportPanel( ClientGUIScrolledPanels.ReviewPanel ):13 14 def __init__( self, parent, payload_obj, title = None, description = None, payload_description = None ):15 16 ClientGUIScrolledPanels.ReviewPanel.__init__( self, parent )17 18 self._payload_obj = payload_obj19 20 self._filepicker = QP.FilePickerCtrl( self, wildcard = 'PNG (*.png)' )21 self._filepicker.SetSaveMode( True )22 23 flp_width = ClientGUIFunctions.ConvertTextToPixelWidth( self._filepicker, 64 )24 25 self._filepicker.setMinimumWidth( flp_width )26 27 self._title = QW.QLineEdit( self )28 29 self._payload_description = QW.QLineEdit( self )30 31 self._text = QW.QLineEdit( self )32 33 self._width = QP.MakeQSpinBox( self, min=100, max=4096 )34 35 self._export = ClientGUICommon.BetterButton( self, 'export', self.Export )36 37 #38 39 if payload_description is None:40 41 ( payload_description, payload_bytes ) = ClientSerialisable.GetPayloadDescriptionAndBytes( self._payload_obj )42 43 else:44 45 payload_bytes = ClientSerialisable.GetPayloadBytes( self._payload_obj )46 47 payload_description += ' - {}'.format( HydrusData.ToHumanBytes( len( payload_bytes ) ) )48 49 50 self._payload_description.setText( payload_description )51 52 self._payload_description.setEnabled( False )53 54 self._width.setValue( 512 )55 56 last_png_export_dir = HG.client_controller.new_options.GetNoneableString( 'last_png_export_dir' )57 58 if title is not None:59 60 name = title61 62 elif isinstance( self._payload_obj, HydrusSerialisable.SerialisableBaseNamed ):63 64 name = self._payload_obj.GetName()65 66 else:67 68 name = payload_description69 70 71 self._title.setText( name )72 73 if description is not None:74 75 self._text.setText( description )76 77 78 if last_png_export_dir is not None:79 80 filename = name + '.png'81 82 filename = HydrusPaths.SanitizeFilename( filename )83 84 path = os.path.join( last_png_export_dir, filename )85 86 self._filepicker.SetPath( path )87 88 89 self._Update()90 91 #92 93 rows = []94 95 rows.append( ( 'export path: ', self._filepicker ) )96 rows.append( ( 'title: ', self._title ) )97 rows.append( ( 'payload description: ', self._payload_description ) )98 rows.append( ( 'your description (optional): ', self._text ) )99 rows.append( ( 'png width: ', self._width ) )100 rows.append( ( '', self._export ) )101 102 gridbox = ClientGUICommon.WrapInGrid( self, rows )103 104 self.widget().setLayout( gridbox )105 106 self._filepicker.filePickerChanged.connect( self._Update )107 self._title.textChanged.connect( self._Update )108 109 110 def _Update( self ):111 112 problems = []113 114 path = self._filepicker.GetPath()115 116 if path == '' or path is None:117 118 problems.append( 'select a path' )119 120 121 if path is not None and not os.path.exists( os.path.dirname( path ) ):122 123 problems.append( 'please select a directory that exists' )124 125 126 if self._title.text() == '':127 128 problems.append( 'set a title' )129 130 131 if len( problems ) == 0:132 133 self._export.setText( 'export' )134 135 self._export.setEnabled( True )136 137 else:138 139 self._export.setText( ' and '.join(problems) )140 141 self._export.setEnabled( False )142 143 144 145 def Export( self ):146 147 width = self._width.value()148 149 payload_description = self._payload_description.text()150 payload_bytes = ClientSerialisable.GetPayloadBytes( self._payload_obj )151 152 title = self._title.text()153 text = self._text.text()154 path = self._filepicker.GetPath()155 156 if path is not None and path != '':157 158 base_dir = os.path.dirname( path )159 160 HG.client_controller.new_options.SetNoneableString( 'last_png_export_dir', base_dir )161 162 163 if not path.endswith( '.png' ):164 165 path += '.png'166 167 168 ClientSerialisable.DumpToPNG( width, payload_bytes, title, payload_description, text, path )169 170 self._export.setText( 'done!' )171 172 HG.client_controller.CallLaterQtSafe( self._export, 2.0, 'png export set text', self._export.setText, 'export' )173 174 175class PNGsExportPanel( ClientGUIScrolledPanels.ReviewPanel ):176 177 def __init__( self, parent, payload_objs ):178 179 ClientGUIScrolledPanels.ReviewPanel.__init__( self, parent )180 181 self._payload_objs = payload_objs182 183 self._directory_picker = QP.DirPickerCtrl( self )184 185 dp_width = ClientGUIFunctions.ConvertTextToPixelWidth( self._directory_picker, 52 )186 187 self._directory_picker.setMinimumWidth( dp_width )188 189 self._width = QP.MakeQSpinBox( self, min=100, max=4096 )190 191 self._export = ClientGUICommon.BetterButton( self, 'export', self.Export )192 193 #194 195 last_png_export_dir = HG.client_controller.new_options.GetNoneableString( 'last_png_export_dir' )196 197 if last_png_export_dir is not None:198 199 self._directory_picker.SetPath( last_png_export_dir )200 201 202 self._width.setValue( 512 )203 204 self._Update()205 206 #207 208 rows = []209 210 rows.append( ( 'export path: ', self._directory_picker ) )211 rows.append( ( 'png width: ', self._width ) )212 rows.append( ( '', self._export ) )213 214 gridbox = ClientGUICommon.WrapInGrid( self, rows )215 216 self.widget().setLayout( gridbox )217 218 self._directory_picker.dirPickerChanged.connect( self._Update )219 220 221 def _Update( self ):222 223 problems = []224 225 path = self._directory_picker.GetPath()226 227 if path is None or path == '':228 229 problems.append( 'select a path' )230 231 232 if len( problems ) == 0:233 234 self._export.setText( 'export' )235 236 self._export.setEnabled( True )237 238 else:239 240 self._export.setText( ' and '.join(problems) )241 242 self._export.setEnabled( False )243 244 245 246 def Export( self ):247 248 width = self._width.value()249 250 directory = self._directory_picker.GetPath()251 252 last_png_export_dir = directory253 254 if last_png_export_dir is not None and last_png_export_dir != '':255 256 HG.client_controller.new_options.SetNoneableString( 'last_png_export_dir', last_png_export_dir )257 258 259 for obj in self._payload_objs:260 261 ( payload_description, payload_bytes ) = ClientSerialisable.GetPayloadDescriptionAndBytes( obj )262 263 title = obj.GetName()264 text = ''265 path = os.path.join( directory, title )266 267 if not path.endswith( '.png' ):268 269 path += '.png'270 271 272 ClientSerialisable.DumpToPNG( width, payload_bytes, title, payload_description, text, path )273 274 275 self._export.setText( 'done!' )276 277 HG.client_controller.CallLaterQtSafe( self._export, 2.0, 'png export set text', self._export.setText, 'export' )278 ...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1import os2import sys3import pandas4import numpy5sys.path.append(os.path.abspath('./lib'))6import dataPrep7import driftCorrection8import orderedParameter9import utils10excelFile = 'analysisLog.xlsx'11df = pandas.read_excel(excelFile,names=['inputDir','fps','pixelSize','flux'])12df.dropna(subset=['inputDir'],inplace=True)13for inputDir,fps,pixelSize,flux in df.values:14 print ('Processing %s' %(inputDir))15 16 if (os.name=='nt'):17 inputDir = inputDir.replace('/scratch/utkur','Z:')18 19 # dp = dataPrep.dataPrep(inputDir)20 # dp.convertGatanMovie()21 # dp.averageFrames(dp.outputPNGDir,dp.outputPNGDir+'_avg',20,'png')22 # dp.averageFrames(dp.outputNPYDir,dp.outputNPYDir+'_avg',10,'npy')23 # dp.averageFrames(dp.outputPNGDir,dp.outputDir,dp.numFrames,'png')24 # dp.rmdir(dp.outputPNGDir)25 # dp.rmdir(dp.outputNPYDir)26 27 # drift = driftCorrection.driftCorrection(inputDir,sigma=10)28 # drift.findDrift()29 # drift.smoothDrift()30 # drift.generateImages(numpy.load(drift.driftParamsSmoothFile),scale=0.25,radius=100)31 32 # utils.makeBeamBlockerMask(inputDir+'_Export/000001.png',inputDir+'_Export/beamBlockerMask.png')33 34 op = orderedParameter.orderedParameter(inputDir,inputDir+'_Export/output/data/driftCorrectionSmoothParams.npy',inputDir+'_Export/beamBlockerMask.png',pixelSize)35 op.calculateOP(distanceRangePixel=[100,1000],stepSize=100)36 # # op.calculateOP(distanceRangePixel=[100,1000],stepSize=50)37 38 # op.linePlot(array=inputDir+'_Export/output/data/meanArr-100_1000_100.npy',saveFile=inputDir+'_Export/output/plots/meanArr-100_1000_100.png')39 # op.linePlot(array=inputDir+'_Export/output/data/medianArr-100_1000_100.npy',saveFile=inputDir+'_Export/output/plots/medianArr-100_1000_100.png')40 # op.linePlot(array=inputDir+'_Export/output/data/stdArr-100_1000_100.npy',saveFile=inputDir+'_Export/output/plots/stdArr-100_1000_100.png')41 # op.linePlot(array=inputDir+'_Export/output/data/ordParamArr_mean-100_1000_100.npy',saveFile=inputDir+'_Export/output/plots/ordParamArr_mean-100_1000_100.png')42 # op.linePlot(array=inputDir+'_Export/output/data/ordParamArr_median-100_1000_100.npy',saveFile=inputDir+'_Export/output/plots/ordParamArr_median-100_1000_100.png')43 44 # op.linePlot(array=inputDir+'_Export/output/data/meanArr-100_1000_50.npy',saveFile=inputDir+'_Export/output/plots/meanArr-100_1000_50.png')45 # op.linePlot(array=inputDir+'_Export/output/data/medianArr-100_1000_50.npy',saveFile=inputDir+'_Export/output/plots/medianArr-100_1000_50.png')46 # op.linePlot(array=inputDir+'_Export/output/data/stdArr-100_1000_50.npy',saveFile=inputDir+'_Export/output/plots/stdArr-100_1000_50.png')47 # op.linePlot(array=inputDir+'_Export/output/data/ordParamArr_mean-100_1000_50.npy',saveFile=inputDir+'_Export/output/plots/ordParamArr_mean-100_1000_50.png')...

Full Screen

Full Screen

test_core.py

Source:test_core.py Github

copy

Full Screen

1from pysb.testing import *2from pysb.core import *3from functools import partial4def test_component_names_valid():5 for name in 'a', 'B', 'AbC', 'dEf', '_', '_7', '__a01b__999x_x___':6 c = Component(name, _export=False)7 eq_(c.name, name)8def test_component_names_invalid():9 for name in 'a!', '!B', 'A!bC~`\\', '_!', '_!7', '__a01b 999x_x___!':10 assert_raises(InvalidComponentNameError, Component, name, _export=False)11def test_monomer():12 sites = ['x', 'y', 'z']13 states = {'y': ['foo', 'bar', 'baz'], 'x': ['e']}14 m = Monomer('A', sites, states, _export=False)15 assert_equal(m.sites, sites)16 assert_equal(m.site_states, states)17 assert_equal(type(m()), MonomerPattern)18 assert_raises(ValueError, Monomer, 'A', 'x', _export=False)19 assert_raises(Exception, Monomer, 'A', 'x', 'x', _export=False)20 assert_raises(Exception, Monomer, 'A', ['x'], {'y': ['a']}, _export=False)21 assert_raises(Exception, Monomer, 'A', ['x'], {'x': [1]}, _export=False)22@with_model23def test_monomer_model():24 Monomer('A')25 ok_(A in model.monomers)26 ok_(A in model.all_components())27 ok_(A not in model.all_components() - model.monomers)28@with_model29def test_initial():30 Monomer('A', ['s'])31 Parameter('A_0')32 Initial(A(s=None), A_0)33 assert_raises_iice = partial(assert_raises, InvalidInitialConditionError,34 Initial)35 assert_raises_iice('not a complexpattern', A_0)36 assert_raises_iice(A(), A_0)37 assert_raises_iice(A(s=None), A_0)38 assert_raises_iice(MatchOnce(A(s=None)), A_0)39@with_model40def test_model_pickle():41 import pickle42 A = Monomer('A', _export=False)43 B = Monomer('B', ['x', 'y'], {'x': ['e', 'f']}, _export=False)44 k = Parameter('k', 1.0, _export=False)45 r = Rule('r', A() + B(x='e', y=WILD) >> A() % B(x='f', y=None), k,46 _export=False)47 o = Observable('o', A() % B(), _export=False)48 e = Expression('e', k * o, _export=False)49 c = Compartment('c', None, 3, k, _export=False)50 for comp in [A, B, k, r, o, e, c]:51 model.add_component(comp)52 model.add_component(c)53 Initial(A() ** c, k)54 assert_equal(len(model.all_components()), 7)55 model2 = pickle.loads(pickle.dumps(model))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful