Ejemplo n.º 1
0
 def edit(self):
     """
     Runs interactive procedure to edit module.
     Returns connection status and response.
     """
     log('Provide new module information (leave fields blank if you don\'t want to change)'
         )
     self.name = wrh_input(message='New module\'s name: ',
                           allowed_empty=True) or self.name
     self.gpio = wrh_input(
         message="Please input new IP address of ESP8266 device: ",
         allowed_empty=True) or self.gpio
     self.port = npinput(
         "Please input new port on which module will be listening for commands: ",
         allowed_empty=True) or self.port
Ejemplo n.º 2
0
 def run_registration_procedure(self, new_id):
     """
     Runs interactive procedure to register new module.
     """
     log(f'*** Registering new {self.TYPE_NAME} module ***')
     self.id = new_id
     self.name = wrh_input('Module name: ')
Ejemplo n.º 3
0
 def edit(self):
     """
     Runs interactive procedure to edit module.
     Returns connection status and response.
     """
     log('Provide new module information (leave fields blank if you don\'t want to change)'
         )
     log('Please note that changes other than name will always succeed')
     log('Name changing requires active Internet connection')
     self.name = wrh_input(message='New module\'s name: ',
                           allowed_empty=True) or self.name
     self.address = wrh_input(
         message="Please input new Rango Iryga IP address: ",
         allowed_empty=True) or self.address
     self.port = iinput(
         "Please input new port on which this module will be listening for commands: ",
         allowed_empty=True) or self.port
 def edit(self):
     """
     Runs interactive procedure to edit module.
     Returns connection status and response.
     """
     log('Provide new module information (leave fields blank if you don\'t want to change)'
         )
     self.name = wrh_input(message='New module\'s name: ',
                           allowed_empty=True) or self.name
     self.port = iinput(
         "Please input new port on which this module will be listening for commands: ",
         allowed_empty=True) or self.port
     new_api_location = wrh_input(
         message="Please input new GoogleAPI key location: ",
         allowed_empty=True)
     if new_api_location:
         self.api_location = new_api_location
         self.drive = GoogleDriveManager(self.api_location, self.id)
Ejemplo n.º 5
0
 def edit(self):
     """
     Runs interactive procedure to edit module.
     Returns connection status and response.
     """
     log('Provide new module information (leave fields blank if you don\'t want to change)'
         )
     self.name = wrh_input(message='New module\'s name: ',
                           allowed_empty=True) or self.name
     self.camera_address = wrh_input(
         message="Please input new IP address of camera: ",
         allowed_empty=True) or self.camera_address
     self.camera_port = wrh_input(
         message=
         "Please input new port on which IP camera can be accessed: ",
         allowed_empty=True) or self.camera_port
     self.port = iinput(
         "Please input new port on which streamed images can be accessed: ",
         allowed_empty=True) or self.port
Ejemplo n.º 6
0
 def _modify_client(self, session):
     log('\n*** Existing clients ***')
     [
         log(f'{client.id} --- {client.name}', Color.BLUE)
         for client in self.wrh_clients.values()
     ]
     client_id = npinput(message='Id of client to edit: ')
     to_edit = session.query(WRHClient).filter(
         WRHClient.id == client_id).first()
     if to_edit:
         to_edit.name = wrh_input(message='Input new name of the client: ')
Ejemplo n.º 7
0
 def edit(self):
     """
     Runs interactive procedure to edit module.
     Returns connection status and response.
     """
     log('Provide new module information (leave fields blank if you don\'t want to change)'
         )
     self.name = wrh_input(message='New module\'s name: ',
                           allowed_empty=True) or self.name
     self.gpio = wrh_input(
         message=
         "Please input new name of the webcam device (usually /dev/video# where # is the specific number): ",
         allowed_empty=True) or self.gpio
     self.port = iinput(
         "Please input new port on which streamed images can be accessed: ",
         allowed_empty=True) or self.port
     self.login = wrh_input(
         message="Please input new login used to access the video stream: ",
         allowed_empty=True) or self.login
     self.password = wrh_input(
         message=
         "Please input new password used to access the video stream: ",
         allowed_empty=True) or self.password
Ejemplo n.º 8
0
 def run_registration_procedure(self, new_id):
     """
     Runs interactive procedure to register new module.
     """
     base_module.Module.run_registration_procedure(self, new_id)
     self.gpio = ninput(
         "Please input name of the webcam device (usually /dev/video#, # is the specific number): "
     )
     self.port = iinput(
         "Please input port on which streamed images can be accessed: ")
     self.login = wrh_input(
         message=
         "Please input login used to access the video stream (press ENTER if none): ",
         allowed_empty=True)
     self.password = ninput(
         "Please input password used to access the video stream: "
     ) if self.login else ""
Ejemplo n.º 9
0
 def edit(self):
     """
     Runs interactive procedure to edit module.
     Returns connection status and response.
     """
     log('Provide new module information (leave fields blank if you don\'t want to change)'
         )
     self.name = wrh_input(message='New module\'s name: ',
                           allowed_empty=True) or self.name
     self.gpio = iinput(
         "Please input new gpio pin number to which sensor is connected: ",
         allowed_empty=True) or self.gpio
     self.interval = iinput(
         "Please input new interval (in minutes) for taking consecutive measurements: ",
         allowed_empty=True) or self.interval
     self.port = iinput(
         "Please input new port on which this module will be listening for commands: ",
         allowed_empty=True) or self.port
Ejemplo n.º 10
0
 def run_interactive(self):
     log('*** Existing clients ***')
     [
         log(f'{client.id} --- {client.name}', Color.BLUE)
         for client in self.wrh_clients.values()
     ]
     choices = {
         1: ('Add new WRH client', self._add_new_client),
         2: ('Edit existing WRH client', self._modify_client),
         3: ('Delete existing WRH client', self._delete_client),
         4: ('Start work', self.start_work),
         5: ('Exit', lambda: None)
     }
     choice = -1
     while choice != 5:
         [log(f'{k}) {v[0]}') for k, v in choices.items()]
         choice = wrh_input(message='> ',
                            input_type=int,
                            sanitizer=lambda x: 1 <= x <= len(choices),
                            allowed_exceptions=(ValueError, ))
         choices[choice][1]()  # run selected procedure
         if choice in (1, 2, 3):
             log('Sucess!\n\n', Color.GREEN)
Ejemplo n.º 11
0
 def _add_new_client(self, session):
     log('\n*** Adding new WRH client ***')
     client_name = wrh_input(message='Input name of new client: ')
     client = WRHClient(name=client_name,
                        token=self._generate_client_token(client_name))
     session.add(client)