Esempio n. 1
0
 def update_buttons_state(self):
     self.facadeController = FacadeDeviceServerController()
     if self.facadeController.server_exists():
         self.facadeserver_button.setText("Update Facadedevice Server")
         self.elindevices_button.setEnabled(True)
     else:
         self.facadeserver_button.setText("Create Facadedevice Server")
         self.elindevices_button.setEnabled(False)
Esempio n. 2
0
class mainWidget(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.create_layout()
        self.update_buttons_state()
        self.connect_slots()

    def create_layout(self):
        self.facadeserver_button = QPushButton(self)
        self.elindevices_button = QPushButton(self)
        self.devlist_edit = QPlainTextEdit(self)
        self.elindevices_button.setText("Get list of devices and 'current' attribute values")

        self.layout = QVBoxLayout(self)
        self.layout.addWidget(self.facadeserver_button, 0)
        self.layout.addWidget(self.elindevices_button, 1)
        self.layout.addWidget(self.devlist_edit, 2)

    def update_buttons_state(self):
        self.facadeController = FacadeDeviceServerController()
        if self.facadeController.server_exists():
            self.facadeserver_button.setText("Update Facadedevice Server")
            self.elindevices_button.setEnabled(True)
        else:
            self.facadeserver_button.setText("Create Facadedevice Server")
            self.elindevices_button.setEnabled(False)

    def connect_slots(self):
        self.connect(self.facadeserver_button, QtCore.SIGNAL("clicked()"), self.create_server)
        self.connect(self.elindevices_button, QtCore.SIGNAL("clicked()"), self.get_devs_and_attr_list)

    def create_server(self):
        print("Creating/Updating Facadedevice server...")
        self.facadeController.create_server()
        self.update_buttons_state()
        print("...done")

    def get_devs_and_attr_list(self):
        facades = self.facadeController.get_facadedevice_names()
        devs_and_attrs = CurrentAttributeHelper.get_devs_and_attributes(facades)

        self.devlist_edit.clear()
        self.devlist_edit.setPlainText(devs_and_attrs)
class CommandLineInterface(object):
    def __init__(self):
        self.facadeController = FacadeDeviceServerController()

    def start(self):
        selected_option = None
        while selected_option is not Options.QUIT:
            selected_option = self.show_menu()
            if selected_option is Options.CREATE_SERVER:
                self.create_server()
            elif selected_option is Options.GET_LIST:
                self.get_list()

    def show_menu(self):
        if self.facadeController.server_exists():
            options = "Select option:\n[U]pdate Facedevice Server, [G]et devs and attrs list, [Q]uit: "
            allowed_choices = ("U", "G", "Q")
        else:
            options = "Select option:\n[C]reate Facadedevice Server, [Q]uit: "
            allowed_choices = ("C", "Q")

        choice = raw_input(options)
        if choice not in allowed_choices:
            return Options.OTHER
        elif choice == "U" or choice == "C":
            return Options.CREATE_SERVER
        elif choice == "G":
            return Options.GET_LIST
        elif choice == "Q":
            return Options.QUIT

    def create_server(self):
        self.facadeController.create_server()

    def get_list(self):
        facades = self.facadeController.get_facadedevice_names()
        devs_and_attrs = CurrentAttributeHelper.get_devs_and_attributes(
            facades)
        print(devs_and_attrs)
class CommandLineInterface(object):
    def __init__(self):
        self.facadeController = FacadeDeviceServerController()

    def start(self):
        selected_option = None
        while selected_option is not Options.QUIT:
            selected_option = self.show_menu()
            if selected_option is Options.CREATE_SERVER:
                self.create_server()
            elif selected_option is Options.GET_LIST:
                self.get_list()

    def show_menu(self):
        if self.facadeController.server_exists():
            options = "Select option:\n[U]pdate Facedevice Server, [G]et devs and attrs list, [Q]uit: "
            allowed_choices = ("U", "G", "Q")
        else:
            options = "Select option:\n[C]reate Facadedevice Server, [Q]uit: "
            allowed_choices = ("C", "Q")

        choice = raw_input(options)
        if choice not in allowed_choices:
            return Options.OTHER
        elif choice == "U" or choice == "C":
            return Options.CREATE_SERVER
        elif choice == "G":
            return Options.GET_LIST
        elif choice == "Q":
            return Options.QUIT

    def create_server(self):
        self.facadeController.create_server()

    def get_list(self):
        facades = self.facadeController.get_facadedevice_names()
        devs_and_attrs = CurrentAttributeHelper.get_devs_and_attributes(facades)
        print(devs_and_attrs)
 def __init__(self):
     self.facadeController = FacadeDeviceServerController()
 def __init__(self):
     self.facadeController = FacadeDeviceServerController()