Best Python code snippet using lisa_python
_tst__qt_wgt__sequence_chart.py
Source:_tst__qt_wgt__sequence_chart.py
1# coding:utf-82import collections3import functools4from lxbasic import bsc_configure, bsc_core5from lxutil import utl_core6import lxutil_gui.proxy.widgets as prx_widgets7class W(prx_widgets.PrxToolWindow):8 def __init__(self, *args, **kwargs):9 super(W, self).__init__(*args, **kwargs)10 self._name_width = 24011 #12 self._configure_group = prx_widgets.PrxExpandedGroup()13 self.set_widget_add(self._configure_group)14 self._configure_group.set_expanded(True)15 self._configure_node = prx_widgets.PrxNode()16 self._configure_group.set_widget_add(self._configure_node)17 self._configure_node.set_name_width(self._name_width)18 self._directory_port = self._configure_node.set_port_add(19 prx_widgets.PrxDirectoryOpenPort(20 'directory', 'directory'21 )22 )23 self._name_pattern_port = self._configure_node.set_port_add(24 prx_widgets.PrxStringPort(25 'name-pattern', 'name-pattern'26 )27 )28 self._name_pattern_port.set('*.%04d.*exr')29 self._frame_range_port = self._configure_node.set_port_add(30 prx_widgets.PrxIntegerArrayPort(31 'frame_range', 'frame-range'32 )33 )34 #35 self._frame_range_port.set_value_size(2)36 self._frame_range_port.set([1001, 1100])37 self._directory_port.set(38 '/data/f/sequence_chart_test'39 )40 #41 self._sequence_group = prx_widgets.PrxExpandedGroup()42 self._sequence_group.set_name('Sequence(s)')43 self._sequence_group.set_layout_alignment_to_top()44 self._sequence_group.set_expanded(True)45 self._sequence_group.set_size_mode(1)46 self._sequence_scroll_area = prx_widgets.PrxScrollArea()47 self.set_widget_add(self._sequence_group)48 self._sequence_group.set_widget_add(49 self._sequence_scroll_area50 )51 #52 self._check_button = prx_widgets.PrxPressItem()53 self._check_button.set_name('Check')54 self._check_button.set_press_clicked_connect_to(55 self._set_check_run_56 )57 self.set_button_add(self._check_button)58 #59 # self._directory_port.set_changed_connect_to(60 # self._set_check_run_61 # )62 @classmethod63 def _get_check_dict_(cls, directory_path, name_pattern):64 array_dict = collections.OrderedDict()65 file_dict = collections.OrderedDict()66 _ = bsc_core.DirectoryMtd.get_all_file_paths__(directory_path)67 if _:68 g_p = utl_core.GuiProgressesRunner(69 maximum=len(_)70 )71 for i_file_path in _:72 g_p.set_update()73 i_opt = bsc_core.StorageFileOpt(i_file_path)74 i_match_args = bsc_core.MultiplyFileNameMtd.get_match_args(75 i_opt.name, name_pattern76 )77 if i_match_args:78 i_pattern, i_numbers = i_match_args79 if len(i_numbers) == 1:80 i_relative_path_dir_path = bsc_core.DirectoryMtd.get_file_relative_path(81 directory_path, i_opt.directory_path82 )83 i_key = '{}/{}'.format(84 i_relative_path_dir_path, i_pattern85 )86 array_dict.setdefault(87 i_key, []88 ).append(i_numbers[0])89 file_dict.setdefault(90 i_key, []91 ).append(i_file_path)92 #93 g_p.set_stop()94 return file_dict, array_dict95 def _get_data_build_(self, *args, **kwargs):96 directory_path = self._directory_port.get()97 name_pattern = self._name_pattern_port.get()98 #99 self._file_dict, self._array_dict = {}, {}100 if directory_path:101 self._file_dict, self._array_dict = self._get_check_dict_(102 directory_path,103 name_pattern=name_pattern104 )105 def _set_gui_build_(self, frame_range):106 def show_in_explorer_fnc_(file_path_):107 bsc_core.StorageFileOpt(file_path_).set_open_in_system()108 def set_frame_range_fnc_(frame_range_):109 self._frame_range_port.set(frame_range_)110 self._set_gui_update_(frame_range_)111 #112 self._sequence_scroll_area.set_clear()113 #114 self._sequence_chart_dict = {}115 #116 self._check_button.set_status(bsc_configure.Status.Stopped)117 self._check_button.set_statuses([])118 #119 status = bsc_configure.Status.Completed120 element_statuses = []121 if self._array_dict:122 g_p = utl_core.GuiProgressesRunner(123 maximum=len(self._array_dict)124 )125 start_frame, end_frame = frame_range126 for k, i_frame_array in self._array_dict.items():127 g_p.set_update()128 if i_frame_array:129 i_chart_data = (i_frame_array, frame_range, k)130 i_s_c = prx_widgets.PrxSequenceChart()131 i_s_c.set_name_width(self._name_width)132 i_s_c.set_height(20)133 #134 self._sequence_scroll_area.set_widget_add(135 i_s_c136 )137 i_s_c.set_chart_data(138 i_chart_data139 )140 #141 i_file_path = self._file_dict[k][0]142 i_start_frame, i_end_frame = i_s_c.get_index_range()143 i_s_c.set_menu_raw(144 [145 ('Show', ),146 (147 'Show in Explorer',148 None,149 functools.partial(show_in_explorer_fnc_, i_file_path)150 ),151 (152 'Show in RV',153 None,154 functools.partial(utl_core.RvLauncher().set_file_open, i_file_path)155 ),156 ('Extend',),157 (158 'Use Start-frame',159 None,160 functools.partial(set_frame_range_fnc_, (i_start_frame, end_frame)),161 ),162 (163 'Use End-frame',164 None,165 functools.partial(set_frame_range_fnc_, (i_start_frame, end_frame))166 )167 ]168 )169 #170 i_status = i_s_c.get_status()171 if i_status is bsc_configure.Status.Error:172 status = i_status173 #174 element_statuses.append(i_status)175 #176 self._sequence_chart_dict[k] = i_s_c177 #178 g_p.set_stop()179 #180 if element_statuses:181 self._check_button.set_status(182 status183 )184 self._check_button.set_statuses(185 element_statuses186 )187 def _set_gui_update_(self, frame_range):188 if self._array_dict:189 pass190 def _set_check_run_(self):191 frame_range = self._frame_range_port.get()192 #193 method_args = [194 (self._get_data_build_, ()),195 (self._set_gui_build_, (frame_range, ))196 ]197 if method_args:198 g_p = utl_core.GuiProgressesRunner(199 maximum=len(method_args)200 )201 for method, args in method_args:202 g_p.set_update()203 method(*args)204 #205 g_p.set_stop()206 def test(self):207 pass208if __name__ == '__main__':209 import sys210 #211 from PySide2 import QtWidgets212 #213 app = QtWidgets.QApplication(sys.argv)214 #215 w = W()216 w.set_definition_window_size((960, 640))217 w.set_window_show()218 #...
IConfigurator.py
Source:IConfigurator.py
...13 """14 for pod_name, pod in topology.pods.items():15 for node_name, node in pod.items():16 if type(node) != Server:17 self._configure_node(lab, node)18 for node_name, node in topology.aggregation_layer.items():19 self._configure_node(lab, node)20 @abstractmethod21 def _configure_node(self, lab, node):22 """23 abstract method, write the protocol configuration for the node24 :param lab: a Laboratory object (used to take information about the laboratory dir)25 :param node: a FatTree object that represents a clos topology26 :return:27 """...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!