def __init__(self, username, password, hierarchy, gateway_id, environment_prefix): '''Configuration path''' dict_configuration_path = utility.getConfigurationPath() self.json_templates_path = dict_configuration_path[ "json_templates_path"] self.excel_templates_path = dict_configuration_path[ "excel_templates_path"] self.json_files_path = dict_configuration_path["json_files_path"] self.excel_files_path = dict_configuration_path["excel_files_path"] self.hierarchy_file_path = dict_configuration_path["hierarchy_path"] '''Data''' self.dict_configuration_path = utility.getConfigurationPath self.username = username self.password = password self.name_hierarchy = utility.getSubstring(os.path.basename(hierarchy), stop=".") self.hierarchy_path = os.path.join(self.hierarchy_file_path, self.name_hierarchy + ".xml") self.serial_number, self.match_group_value, self.dict_meters = self.getDataFromHierarchy( ) self.gateway_id = gateway_id self.environment_prefix = environment_prefix self.match_group_value = self.name_hierarchy.split( "_")[1] + "_" + self.match_group_value self.dict_meter_template = self.createDictMeterTemplate()
def __init__(self, site_name, hierarchy_name, environment_prefix, dict_meters): '''Set path''' dict_configuration_path = utility.getConfigurationPath() self.json_templates_path = dict_configuration_path[ "json_templates_path"] self.excel_templates_path = dict_configuration_path[ "excel_templates_path"] self.json_files_path = dict_configuration_path["json_files_path"] self.excel_files_path = dict_configuration_path["excel_files_path"] self.hierarchy_file_path = dict_configuration_path["hierarchy_path"] '''Set Data''' self.site_name = site_name self.hierarchy_name = hierarchy_name self.environment_prefix = environment_prefix '''Dict''' self.dict_from_template = self.getTemplateData(hierarchy_name) self.dict_from_json_configuration = utility.readJsonFile( os.path.join(os.path.realpath(''), "configuration", "trandIdConfiguration.json")) self.dict_meters = self.createDictMeterData(dict_meters) self.createExcelSheet()
def __init__(self, parent=None): super(MainInterface, self).__init__(parent) '''Configuration path''' dict_configuration_path = utility.getConfigurationPath() self.json_templates_path = dict_configuration_path[ "json_templates_path"] self.excel_templates_path = dict_configuration_path[ "excel_templates_path"] self.json_files_path = dict_configuration_path["json_files_path"] self.excel_files_path = dict_configuration_path["excel_files_path"] self.hierarchy_path = dict_configuration_path["hierarchy_path"] '''Window settings''' self.setWindowTitle("JaSONx") self.setFixedSize(1050, 600) self.setWindowIcon( QtGui.QIcon(os.path.join(os.path.realpath(''), "image", "logo.png"))) '''Font settings''' font = QtGui.QFont() font.setPointSize(13) fontToolbar = QtGui.QFont() fontToolbar.setPointSize(10) self.setFont(font) '''Label settings''' self.title_label = QtWidgets.QLabel() self.user_name_label = QtWidgets.QLabel() self.password_label = QtWidgets.QLabel() self.match_group_value_label = QtWidgets.QLabel() self.combo_box_hierarchy_label = QtWidgets.QLabel() self.gateway_id_label = QtWidgets.QLabel() self.combo_box_environment_prefix_label = QtWidgets.QLabel() self.title_label.setAlignment(QtCore.Qt.AlignCenter) '''Label text''' self.title_label.setPixmap( QtGui.QPixmap( os.path.join(os.path.realpath(''), "image", "title.png"))) self.user_name_label.setText("Username: "******"Password: "******"Hierarchy: ") self.gateway_id_label.setText("Gateway id: ") self.combo_box_environment_prefix_label.setText("Environment prefix: ") '''Textbox settings''' self.user_name_text = QtWidgets.QLineEdit(self) self.password_text = QtWidgets.QLineEdit(self) '''Combobox settings''' self.combo_box_hierarchy = QtWidgets.QComboBox() self.combo_box_hierarchy.addItems( utility.createFileList(self.hierarchy_path, ".xml")) self.combo_box_environment_prefix = QtWidgets.QComboBox() self.combo_box_environment_prefix.addItems( utility.readJsonFile( os.path.join(os.path.realpath(''), "configuration", "environmentPrefixConfiguration.json"))) self.combo_box_gateway_id = QtWidgets.QComboBox() self.combo_box_gateway_id.addItems( utility.readJsonFile( os.path.join(os.path.realpath(''), "configuration", "gatewayIdConfiguration.json"))) '''Button settings''' self.button = QtWidgets.QPushButton("Send data") self.button.setStyleSheet( "background-color: #8b0000; color: white; height:50; border-radius:10" ) self.button.setFont(font) self.button.clicked.connect(self.on_pushButton_clicked) '''Grid layout''' grid = QtWidgets.QGridLayout() grid.addWidget(self.user_name_label, 0, 0) grid.addWidget(self.user_name_text, 0, 1) grid.addWidget(self.password_label, 1, 0) grid.addWidget(self.password_text, 1, 1) grid.addWidget(self.gateway_id_label, 2, 0) grid.addWidget(self.combo_box_gateway_id, 2, 1) grid.addWidget(self.combo_box_environment_prefix_label, 3, 0) grid.addWidget(self.combo_box_environment_prefix, 3, 1) grid.addWidget(self.combo_box_hierarchy_label, 4, 0) grid.addWidget(self.combo_box_hierarchy, 4, 1) '''Vertical layout''' vbox = QtWidgets.QVBoxLayout() vbox.addWidget(self.title_label) vbox.addLayout(grid) vbox.addWidget(self.button) '''Layout QWidget''' layout = QtWidgets.QWidget() layout.setLayout(vbox) '''Layout QMainWindow''' self.setCentralWidget(layout) '''TOOLBAR''' toolbar = self.addToolBar('Toolbar') toolbar.setMovable(False) toolbar.setIconSize(QtCore.QSize(40, 40)) toolbar.setFont(fontToolbar) toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) '''Icon toolbar''' '''Exit application''' exit_act = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "icon", "exiticon.png")), '', self) exit_act.setShortcut('Ctrl+Q') exit_act.setStatusTip('Close application') '''Add Hierarchy xml''' add_xml_hierarchy_act = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "icon", "xmlicon.png")), 'Hierarchy', self) add_xml_hierarchy_act.setShortcut('Ctrl+H') add_xml_hierarchy_act.setStatusTip('Add Hierarchy XML') '''Add template json''' add_json_template_act = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "icon", "jsonicon.png")), 'Template', self) add_json_template_act.setShortcut('Ctrl+T') add_json_template_act.setStatusTip('Add JSON Template') '''Refresh application''' refresh_act = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "icon", "refreshicon.png")), '', self) refresh_act.setShortcut('Ctrl+R') refresh_act.setStatusTip('Refresh application') '''Add evironment prefix''' add_environment_prefix_act = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "icon", "addlisticon.png")), 'Environment prefix', self) add_environment_prefix_act.setShortcut('Ctrl+P') add_environment_prefix_act.setStatusTip('Add environment prefix') '''Add gateway id''' add_gateway_id_act = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "icon", "addlisticon.png")), 'Gateway id', self) add_gateway_id_act.setShortcut('Ctrl+Y') add_gateway_id_act.setStatusTip('Add gateway id') '''acThing''' acThing_act = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "acthing.png")), 'acThing', self) acThing_act.setShortcut('Ctrl+I') acThing_act.setStatusTip('Open acThing Interface') '''Excel Append''' excel_append_act = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "icon", "excelicon.png")), 'Append', self) excel_append_act.setShortcut('Ctrl+Z') excel_append_act.setStatusTip('Open Excel Append Interface') '''ACTION TOOLBAR''' toolbar.addAction(exit_act) toolbar.addSeparator() toolbar.addSeparator() toolbar.addSeparator() toolbar.addAction(add_xml_hierarchy_act) toolbar.addAction(add_json_template_act) toolbar.addAction(add_environment_prefix_act) toolbar.addAction(add_gateway_id_act) toolbar.addSeparator() toolbar.addSeparator() toolbar.addSeparator() toolbar.addAction(acThing_act) toolbar.addAction(excel_append_act) toolbar.addSeparator() toolbar.addSeparator() toolbar.addSeparator() toolbar.addAction(refresh_act) '''TOOOLBAR TRIGGERED''' exit_act.triggered.connect(self.closeFunction) add_xml_hierarchy_act.triggered.connect(self.addHierarchy) add_json_template_act.triggered.connect(self.addJsonTemplate) refresh_act.triggered.connect(self.refreshWindow) add_environment_prefix_act.triggered.connect(self.addEnvironmentPrefix) add_gateway_id_act.triggered.connect(self.addGatewayId) acThing_act.triggered.connect(self.openActThingInterface) excel_append_act.triggered.connect(self.openExcelAppendInterface) '''MENU SETTINGS''' '''Configuration Json path''' configJsonPathAct = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "menu", "json.png")), 'Json output', self) configJsonPathAct.setShortcut('Ctrl+J') configJsonPathAct.setStatusTip('') configJsonPathAct.triggered.connect(self.changePathJsonFile) '''Configuration Hierarchy path''' configHierarchyPathAct = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "menu", "xml.png")), 'Hierarchy', self) configHierarchyPathAct.setShortcut('Ctrl+X') configHierarchyPathAct.setStatusTip('') configHierarchyPathAct.triggered.connect(self.changePathHierarchy) '''Configuration Template path''' configTemplatePathAct = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "menu", "json.png")), 'Template', self) configTemplatePathAct.setShortcut('Ctrl+L') configTemplatePathAct.setStatusTip('') configTemplatePathAct.triggered.connect(self.changePathTemplate) '''Configuration Excel path''' configExcelPathAct = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "menu", "excel.png")), 'Excel output', self) configExcelPathAct.setShortcut('Ctrl+E') configExcelPathAct.setStatusTip('') configExcelPathAct.triggered.connect(self.changePathExcel) '''Configuration Excel Final path''' configExcelFinalPathAct = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "menu", "excel.png")), 'Excel Final output', self) configExcelFinalPathAct.setShortcut('Ctrl+S') configExcelFinalPathAct.setStatusTip('') configExcelFinalPathAct.triggered.connect(self.changePathExcelFinal) '''Reset paths default''' resetPathAct = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "menu", "reset.png")), 'Reset Path to Default', self) resetPathAct.setShortcut('Ctrl+D') resetPathAct.setStatusTip('') resetPathAct.triggered.connect(self.resetDefaultPath) '''User Guide''' UserGuideAct = QtWidgets.QAction( QtGui.QIcon( os.path.join(os.path.realpath(''), "image", "menu", "guide.png")), 'Open User Guide', self) UserGuideAct.setShortcut('Ctrl+G') UserGuideAct.setStatusTip('') UserGuideAct.triggered.connect(self.openUserGuide) '''Add bar menu''' menubar = self.menuBar() '''Menu path population''' fileMenu = menubar.addMenu('&Change Path') fileMenu.addAction(configJsonPathAct) fileMenu.addAction(configHierarchyPathAct) fileMenu.addAction(configTemplatePathAct) fileMenu.addAction(configExcelPathAct) fileMenu.addAction(configExcelFinalPathAct) fileMenu.addAction(resetPathAct) '''Menu Info - User Guide''' fileMenu2 = menubar.addMenu('&Info') fileMenu2.addAction(UserGuideAct)
''' JaSONx GUI Version @author = "Jury Francia, Simone Olivieri, Vic Zagranowski" @version = "3.1.2.0" @email = "[email protected], [email protected], [email protected]" ''' import utility import os import shutil '''Configuration path''' dict_configuration_path = utility.getConfigurationPath() json_templates_path = dict_configuration_path["json_templates_path"] excel_templates_path = dict_configuration_path["excel_templates_path"] json_files_path = dict_configuration_path["json_files_path"] excel_files_path = dict_configuration_path["excel_files_path"] hierarchy_path = dict_configuration_path["hierarchy_path"] excel_final_path = dict_configuration_path["excel_final_path"] '''Path for json file generated''' def change_json_path(path): if (os.path.exists(os.path.join(path, "json_files")) == False): os.mkdir(os.path.join(path, "json_files")) dict_configuration_path["json_files_path"] = os.path.join( path, "json_files") utility.saveJsonFile( os.path.join(os.path.realpath(''), "configuration", "pathConfiguration.json"), dict_configuration_path) return True