Best Python code snippet using fMBT_python
file_properties.py
Source:file_properties.py
1# coding: utf-82"""3 NSX-T Manager API4 VMware NSX-T Manager REST API # noqa: E5015 OpenAPI spec version: 2.5.1.0.06 7 Generated by: https://github.com/swagger-api/swagger-codegen.git8"""9import pprint10import re # noqa: F40111import six12class FileProperties(object):13 """NOTE: This class is auto generated by the swagger code generator program.14 Do not edit the class manually.15 """16 """17 Attributes:18 swagger_types (dict): The key is attribute name19 and the value is attribute type.20 attribute_map (dict): The key is attribute name21 and the value is json key in definition.22 """23 swagger_types = {24 '_self': 'SelfResourceLink',25 'links': 'list[ResourceLink]',26 'schema': 'str',27 'created_epoch_ms': 'int',28 'modified_epoch_ms': 'int',29 'name': 'str',30 'size': 'int'31 }32 if hasattr(Resource, "swagger_types"):33 swagger_types.update(Resource.swagger_types)34 attribute_map = {35 '_self': '_self',36 'links': '_links',37 'schema': '_schema',38 'created_epoch_ms': 'created_epoch_ms',39 'modified_epoch_ms': 'modified_epoch_ms',40 'name': 'name',41 'size': 'size'42 }43 if hasattr(Resource, "attribute_map"):44 attribute_map.update(Resource.attribute_map)45 def __init__(self, _self=None, links=None, schema=None, created_epoch_ms=None, modified_epoch_ms=None, name=None, size=None, *args, **kwargs): # noqa: E50146 """FileProperties - a model defined in Swagger""" # noqa: E50147 self.__self = None48 self._links = None49 self._schema = None50 self._created_epoch_ms = None51 self._modified_epoch_ms = None52 self._name = None53 self._size = None54 self.discriminator = None55 if _self is not None:56 self._self = _self57 if links is not None:58 self.links = links59 if schema is not None:60 self.schema = schema61 self.created_epoch_ms = created_epoch_ms62 self.modified_epoch_ms = modified_epoch_ms63 self.name = name64 self.size = size65 Resource.__init__(self, *args, **kwargs)66 @property67 def _self(self):68 """Gets the _self of this FileProperties. # noqa: E50169 :return: The _self of this FileProperties. # noqa: E50170 :rtype: SelfResourceLink71 """72 return self.__self73 @_self.setter74 def _self(self, _self):75 """Sets the _self of this FileProperties.76 :param _self: The _self of this FileProperties. # noqa: E50177 :type: SelfResourceLink78 """79 self.__self = _self80 @property81 def links(self):82 """Gets the links of this FileProperties. # noqa: E50183 The server will populate this field when returing the resource. Ignored on PUT and POST. # noqa: E50184 :return: The links of this FileProperties. # noqa: E50185 :rtype: list[ResourceLink]86 """87 return self._links88 @links.setter89 def links(self, links):90 """Sets the links of this FileProperties.91 The server will populate this field when returing the resource. Ignored on PUT and POST. # noqa: E50192 :param links: The links of this FileProperties. # noqa: E50193 :type: list[ResourceLink]94 """95 self._links = links96 @property97 def schema(self):98 """Gets the schema of this FileProperties. # noqa: E50199 Schema for this resource # noqa: E501100 :return: The schema of this FileProperties. # noqa: E501101 :rtype: str102 """103 return self._schema104 @schema.setter105 def schema(self, schema):106 """Sets the schema of this FileProperties.107 Schema for this resource # noqa: E501108 :param schema: The schema of this FileProperties. # noqa: E501109 :type: str110 """111 self._schema = schema112 @property113 def created_epoch_ms(self):114 """Gets the created_epoch_ms of this FileProperties. # noqa: E501115 File creation time in epoch milliseconds # noqa: E501116 :return: The created_epoch_ms of this FileProperties. # noqa: E501117 :rtype: int118 """119 return self._created_epoch_ms120 @created_epoch_ms.setter121 def created_epoch_ms(self, created_epoch_ms):122 """Sets the created_epoch_ms of this FileProperties.123 File creation time in epoch milliseconds # noqa: E501124 :param created_epoch_ms: The created_epoch_ms of this FileProperties. # noqa: E501125 :type: int126 """127 if created_epoch_ms is None:128 raise ValueError("Invalid value for `created_epoch_ms`, must not be `None`") # noqa: E501129 self._created_epoch_ms = created_epoch_ms130 @property131 def modified_epoch_ms(self):132 """Gets the modified_epoch_ms of this FileProperties. # noqa: E501133 File modification time in epoch milliseconds # noqa: E501134 :return: The modified_epoch_ms of this FileProperties. # noqa: E501135 :rtype: int136 """137 return self._modified_epoch_ms138 @modified_epoch_ms.setter139 def modified_epoch_ms(self, modified_epoch_ms):140 """Sets the modified_epoch_ms of this FileProperties.141 File modification time in epoch milliseconds # noqa: E501142 :param modified_epoch_ms: The modified_epoch_ms of this FileProperties. # noqa: E501143 :type: int144 """145 if modified_epoch_ms is None:146 raise ValueError("Invalid value for `modified_epoch_ms`, must not be `None`") # noqa: E501147 self._modified_epoch_ms = modified_epoch_ms148 @property149 def name(self):150 """Gets the name of this FileProperties. # noqa: E501151 File name # noqa: E501152 :return: The name of this FileProperties. # noqa: E501153 :rtype: str154 """155 return self._name156 @name.setter157 def name(self, name):158 """Sets the name of this FileProperties.159 File name # noqa: E501160 :param name: The name of this FileProperties. # noqa: E501161 :type: str162 """163 if name is None:164 raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501165 self._name = name166 @property167 def size(self):168 """Gets the size of this FileProperties. # noqa: E501169 Size of the file in bytes # noqa: E501170 :return: The size of this FileProperties. # noqa: E501171 :rtype: int172 """173 return self._size174 @size.setter175 def size(self, size):176 """Sets the size of this FileProperties.177 Size of the file in bytes # noqa: E501178 :param size: The size of this FileProperties. # noqa: E501179 :type: int180 """181 if size is None:182 raise ValueError("Invalid value for `size`, must not be `None`") # noqa: E501183 self._size = size184 def to_dict(self):185 """Returns the model properties as a dict"""186 result = {}187 for attr, _ in six.iteritems(self.swagger_types):188 value = getattr(self, attr)189 if isinstance(value, list):190 result[attr] = list(map(191 lambda x: x.to_dict() if hasattr(x, "to_dict") else x,192 value193 ))194 elif hasattr(value, "to_dict"):195 result[attr] = value.to_dict()196 elif isinstance(value, dict):197 result[attr] = dict(map(198 lambda item: (item[0], item[1].to_dict())199 if hasattr(item[1], "to_dict") else item,200 value.items()201 ))202 else:203 result[attr] = value204 if issubclass(FileProperties, dict):205 for key, value in self.items():206 result[key] = value207 return result208 def to_str(self):209 """Returns the string representation of the model"""210 return pprint.pformat(self.to_dict())211 def __repr__(self):212 """For `print` and `pprint`"""213 return self.to_str()214 def __eq__(self, other):215 """Returns true if both objects are equal"""216 if not isinstance(other, FileProperties):217 return False218 return self.__dict__ == other.__dict__219 def __ne__(self, other):220 """Returns true if both objects are not equal"""...
MainForm.py
Source:MainForm.py
1from ast import Not2from PyQt5 import QtGui, uic3from PyQt5.QtWidgets import (QMessageBox,QTextEdit, QWidget, QVBoxLayout, QHBoxLayout,QLabel, QApplication,QLineEdit,QFrame,QPushButton,QFileDialog,QGridLayout,QDesktopWidget)4from PyQt5.QtGui import QFont5import sys # We need sys so that we can pass argv to QApplication6import os7import os.path8import HexFileAppender9class MainForm(QWidget): 10 def selectFolder(self):11 srcFilePath = ""12 destFilePath = "" 13 mainProgramStartAddr = 0x0802000014 mainProgramSize = 0xA000015 if(os.path.exists('.property')): 16 fileProperties = open('.property','r')17 srcFilePath = fileProperties.readline().strip()18 destFilePath = fileProperties.readline().strip()19 mainProgramStartAddr = int(fileProperties.readline().strip(),16)20 mainProgramSize = int(fileProperties.readline().strip(),16)21 fileProperties.close()22 else:23 srcFilePath = os.path.abspath(os.curdir).replace('\\','/',20)+'/'24 destFilePath = os.path.abspath(os.curdir).replace('\\','/',20)+'/'25 fileProperties = open('.property','w+')26 fileProperties.write(srcFilePath + '\n')27 fileProperties.write(destFilePath + '\n')28 fileProperties.write('0x'+format(mainProgramStartAddr, 'X') + '\n')29 fileProperties.write('0x'+format(mainProgramSize, 'X') + '\n')30 fileProperties.close()31 srcFilePath = QFileDialog.getOpenFileName(self,"Open sorce .hex file", srcFilePath, "Files (*.hex)")[0]32 if(srcFilePath==''):33 return34 destFilePath = QFileDialog.getSaveFileName(self,"Open destination .hex file", destFilePath, "Files (*.hex)")[0] #, "Files (*.hex)"35 if(destFilePath==''):36 return37 HexFileAppender.appentHexFile(srcFilePath,destFilePath,'0x'+format(mainProgramStartAddr, 'X'),'0x'+format(mainProgramSize, 'X'))38 if(os.path.exists('.property')): 39 fileProperties = open('.property','w+')40 fileProperties.write(srcFilePath + '\n') #os.path.dirname(41 fileProperties.write(destFilePath + '\n') #os.path.dirname(42 fileProperties.write('0x'+format(mainProgramStartAddr, 'X') + '\n')43 fileProperties.write('0x'+format(mainProgramSize, 'X') + '\n')44 fileProperties.close()45 msgBox = QMessageBox()46 msgBox.setIcon(QMessageBox.Information)47 msgBox.setText("File Was Created")48 msgBox.setWindowTitle("Notice")49 msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)50 returnValue = msgBox.exec()51 def __init__(self):52 super().__init__()53 self.setFont(QFont('Arial', 12))54 mainVLayout = QVBoxLayout()55 self.selectFolderBTN = QPushButton("Select files")56 self.selectFolderBTN.setMinimumSize(170,40)57 self.selectFolderBTN.clicked.connect(self.selectFolder)58 mainVLayout.addWidget(self.selectFolderBTN)59 self.setLayout(mainVLayout)60 self.setGeometry(0,0,400,200)61 self.setMinimumHeight(200)62 self.setWindowTitle('Vibo monitoring app')63 qtRectangle = self.frameGeometry()64 centerPoint = QDesktopWidget().availableGeometry().center()65 qtRectangle.moveCenter(centerPoint)66 self.move(qtRectangle.topLeft())67 self.show()68if __name__ == '__main__':69 app = QApplication(sys.argv)70 w = MainForm()...
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!!